diff --git a/Assets/Example/Characters/Urchin Girl.prefab b/Assets/Example/Characters/Ciara.prefab similarity index 73% rename from Assets/Example/Characters/Urchin Girl.prefab rename to Assets/Example/Characters/Ciara.prefab index df0e8c40..3a05b82d 100644 Binary files a/Assets/Example/Characters/Urchin Girl.prefab and b/Assets/Example/Characters/Ciara.prefab differ diff --git a/Assets/Example/Characters/Roamer.prefab.meta b/Assets/Example/Characters/Ciara.prefab.meta similarity index 58% rename from Assets/Example/Characters/Roamer.prefab.meta rename to Assets/Example/Characters/Ciara.prefab.meta index c312a645..915c9c6a 100644 --- a/Assets/Example/Characters/Roamer.prefab.meta +++ b/Assets/Example/Characters/Ciara.prefab.meta @@ -1,4 +1,4 @@ fileFormatVersion: 2 -guid: 68e611507bef949a8be6528922662936 +guid: 211b4d79191e74f759aee0ffc1011aaf NativeFormatImporter: userData: diff --git a/Assets/Example/Characters/Roamer.prefab b/Assets/Example/Characters/Shay.prefab similarity index 73% rename from Assets/Example/Characters/Roamer.prefab rename to Assets/Example/Characters/Shay.prefab index 439909ae..1003cddf 100644 Binary files a/Assets/Example/Characters/Roamer.prefab and b/Assets/Example/Characters/Shay.prefab differ diff --git a/Assets/Example/Characters/Urchin Girl.prefab.meta b/Assets/Example/Characters/Shay.prefab.meta similarity index 58% rename from Assets/Example/Characters/Urchin Girl.prefab.meta rename to Assets/Example/Characters/Shay.prefab.meta index 97608461..62b59520 100644 --- a/Assets/Example/Characters/Urchin Girl.prefab.meta +++ b/Assets/Example/Characters/Shay.prefab.meta @@ -1,4 +1,4 @@ fileFormatVersion: 2 -guid: 3191a22b2027f496799374d6613d74a0 +guid: 1c597b2bba1ea4ab0b505f29307dfe5c NativeFormatImporter: userData: diff --git a/Assets/Example/Characters/Skipper.prefab b/Assets/Example/Characters/Skipper.prefab index eec19fd2..d833a433 100644 Binary files a/Assets/Example/Characters/Skipper.prefab and b/Assets/Example/Characters/Skipper.prefab differ diff --git a/Assets/Example/Characters/Skipper.prefab.meta b/Assets/Example/Characters/Skipper.prefab.meta index 0342b9c4..5da437f8 100644 --- a/Assets/Example/Characters/Skipper.prefab.meta +++ b/Assets/Example/Characters/Skipper.prefab.meta @@ -1,4 +1,4 @@ fileFormatVersion: 2 -guid: a98bc2f48ea5f4460817c1e508f936ca +guid: 1a6ae8948ffd6480e83b5774d9f1b2ae NativeFormatImporter: userData: diff --git a/Assets/Example/Scenes/Example.unity b/Assets/Example/Scenes/Example.unity index 91f47b7a..472728cc 100644 Binary files a/Assets/Example/Scenes/Example.unity and b/Assets/Example/Scenes/Example.unity differ diff --git a/Assets/Fungus/Dialog/Commands/Choose.cs b/Assets/Fungus/Dialog/Commands/Choose.cs index 38899868..f6d58765 100644 --- a/Assets/Fungus/Dialog/Commands/Choose.cs +++ b/Assets/Fungus/Dialog/Commands/Choose.cs @@ -118,7 +118,7 @@ namespace Fungus.Script if (character != null) { - GUILayout.Label(character.characterName); + GUILayout.Label(character.nameText); GUILayout.Space(10); } diff --git a/Assets/Fungus/Dialog/Commands/Say.cs b/Assets/Fungus/Dialog/Commands/Say.cs index 4ba2825a..868c55bb 100644 --- a/Assets/Fungus/Dialog/Commands/Say.cs +++ b/Assets/Fungus/Dialog/Commands/Say.cs @@ -76,7 +76,7 @@ namespace Fungus.Script if (character != null) { - GUILayout.Label(character.characterName); + GUILayout.Label(character.nameText); GUILayout.Space(10); } diff --git a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs index 2b510cf2..486c4070 100644 --- a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs +++ b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs @@ -10,8 +10,19 @@ namespace Fungus.Script { Material spriteMaterial; + SerializedProperty nameTextProp; + SerializedProperty nameColorProp; + SerializedProperty profileSpriteProp; + SerializedProperty notesProp; + void OnEnable() { + // Setup the SerializedProperties + nameTextProp = serializedObject.FindProperty ("nameText"); + nameColorProp = serializedObject.FindProperty ("nameColor"); + profileSpriteProp = serializedObject.FindProperty ("profileSprite"); + notesProp = serializedObject.FindProperty ("notes"); + Shader shader = Shader.Find("Sprites/Default"); if (shader != null) { @@ -27,45 +38,35 @@ namespace Fungus.Script public override void OnInspectorGUI() { - Character t = target as Character; + serializedObject.Update(); EditorGUI.BeginChangeCheck(); - string characterName = EditorGUILayout.TextField(new GUIContent("Name Text", "Name of the character display in the dialog"), - t.characterName); + EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog")); + + EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog")); - Color characterColor = EditorGUILayout.ColorField(new GUIContent("Name Color", "Color of name text display in the dialog"), - t.characterColor); + EditorGUILayout.PropertyField(profileSpriteProp, new GUIContent("Image", "Character image sprite to display in the dialog")); - Sprite characterImage = EditorGUILayout.ObjectField(new GUIContent("Image", "Character image sprite to display in the dialog"), - t.characterImage, - typeof(Sprite), - true) as Sprite; + EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)")); EditorGUILayout.Separator(); - if (characterImage != null && + Character t = target as Character; + if (t.profileSprite != null && spriteMaterial != null) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); - float aspect = (float)characterImage.texture.width / (float)characterImage.texture.height; + float aspect = (float)t.profileSprite.texture.width / (float)t.profileSprite.texture.height; Rect imagePreviewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(150), GUILayout.ExpandWidth(false)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); - DrawPreview(imagePreviewRect, - characterImage.texture); + DrawPreview(imagePreviewRect, t.profileSprite.texture); } - if (EditorGUI.EndChangeCheck()) - { - Undo.RecordObject(t, "Set Character"); - - t.characterName = characterName; - t.characterColor = characterColor; - t.characterImage = characterImage; - } + serializedObject.ApplyModifiedProperties(); } public void DrawPreview(Rect previewRect, Texture2D texture) diff --git a/Assets/Fungus/Dialog/Editor/SayEditor.cs b/Assets/Fungus/Dialog/Editor/SayEditor.cs index 019406ee..362ccd63 100644 --- a/Assets/Fungus/Dialog/Editor/SayEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SayEditor.cs @@ -58,10 +58,10 @@ namespace Fungus.Script string text = EditorGUILayout.TextArea(t.storyText, sayStyle, GUILayout.MinHeight(60)); if (t.character != null && - t.character.characterImage != null && - t.character.characterImage.texture != null) + t.character.profileSprite != null && + t.character.profileSprite.texture != null) { - Texture2D characterTexture = t.character.characterImage.texture; + Texture2D characterTexture = t.character.profileSprite.texture; float aspect = (float)characterTexture.width / (float)characterTexture.height; Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false)); diff --git a/Assets/Fungus/Dialog/Scripts/Character.cs b/Assets/Fungus/Dialog/Scripts/Character.cs index 24d8c74c..9f854ac6 100644 --- a/Assets/Fungus/Dialog/Scripts/Character.cs +++ b/Assets/Fungus/Dialog/Scripts/Character.cs @@ -8,9 +8,12 @@ namespace Fungus.Script [ExecuteInEditMode] public class Character : MonoBehaviour { - public string characterName; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad") - public Sprite characterImage; - public Color characterColor; + public string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad") + public Color nameColor = Color.white; + public Sprite profileSprite; + + [TextArea(5,10)] + public string notes; static public List activeCharacters = new List(); diff --git a/Assets/Fungus/Dialog/Scripts/Dialog.cs b/Assets/Fungus/Dialog/Scripts/Dialog.cs index c1fb0d4a..4d5b1578 100644 --- a/Assets/Fungus/Dialog/Scripts/Dialog.cs +++ b/Assets/Fungus/Dialog/Scripts/Dialog.cs @@ -71,16 +71,16 @@ namespace Fungus.Script } else { - SetCharacterImage(character.characterImage); + SetCharacterImage(character.profileSprite); - string characterName = character.characterName; + string characterName = character.nameText; if (characterName == "") { // Use game object name as default characterName = character.name; } - SetCharacterName(characterName, character.characterColor); + SetCharacterName(characterName, character.nameColor); } }