Browse Source

Fixed prefab issues with Character. Added notes field.

master
chrisgregan 10 years ago
parent
commit
91c55cf0f2
  1. BIN
      Assets/Example/Characters/Ciara.prefab
  2. 2
      Assets/Example/Characters/Ciara.prefab.meta
  3. BIN
      Assets/Example/Characters/Shay.prefab
  4. 2
      Assets/Example/Characters/Shay.prefab.meta
  5. BIN
      Assets/Example/Characters/Skipper.prefab
  6. 2
      Assets/Example/Characters/Skipper.prefab.meta
  7. BIN
      Assets/Example/Scenes/Example.unity
  8. 2
      Assets/Fungus/Dialog/Commands/Choose.cs
  9. 2
      Assets/Fungus/Dialog/Commands/Say.cs
  10. 43
      Assets/Fungus/Dialog/Editor/CharacterEditor.cs
  11. 6
      Assets/Fungus/Dialog/Editor/SayEditor.cs
  12. 9
      Assets/Fungus/Dialog/Scripts/Character.cs
  13. 6
      Assets/Fungus/Dialog/Scripts/Dialog.cs

BIN
Assets/Example/Characters/Urchin Girl.prefab → Assets/Example/Characters/Ciara.prefab

Binary file not shown.

2
Assets/Example/Characters/Roamer.prefab.meta → Assets/Example/Characters/Ciara.prefab.meta

@ -1,4 +1,4 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 68e611507bef949a8be6528922662936 guid: 211b4d79191e74f759aee0ffc1011aaf
NativeFormatImporter: NativeFormatImporter:
userData: userData:

BIN
Assets/Example/Characters/Roamer.prefab → Assets/Example/Characters/Shay.prefab

Binary file not shown.

2
Assets/Example/Characters/Urchin Girl.prefab.meta → Assets/Example/Characters/Shay.prefab.meta

@ -1,4 +1,4 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3191a22b2027f496799374d6613d74a0 guid: 1c597b2bba1ea4ab0b505f29307dfe5c
NativeFormatImporter: NativeFormatImporter:
userData: userData:

BIN
Assets/Example/Characters/Skipper.prefab

Binary file not shown.

2
Assets/Example/Characters/Skipper.prefab.meta

@ -1,4 +1,4 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a98bc2f48ea5f4460817c1e508f936ca guid: 1a6ae8948ffd6480e83b5774d9f1b2ae
NativeFormatImporter: NativeFormatImporter:
userData: userData:

BIN
Assets/Example/Scenes/Example.unity

Binary file not shown.

2
Assets/Fungus/Dialog/Commands/Choose.cs

@ -118,7 +118,7 @@ namespace Fungus.Script
if (character != null) if (character != null)
{ {
GUILayout.Label(character.characterName); GUILayout.Label(character.nameText);
GUILayout.Space(10); GUILayout.Space(10);
} }

2
Assets/Fungus/Dialog/Commands/Say.cs

@ -76,7 +76,7 @@ namespace Fungus.Script
if (character != null) if (character != null)
{ {
GUILayout.Label(character.characterName); GUILayout.Label(character.nameText);
GUILayout.Space(10); GUILayout.Space(10);
} }

43
Assets/Fungus/Dialog/Editor/CharacterEditor.cs

@ -10,8 +10,19 @@ namespace Fungus.Script
{ {
Material spriteMaterial; Material spriteMaterial;
SerializedProperty nameTextProp;
SerializedProperty nameColorProp;
SerializedProperty profileSpriteProp;
SerializedProperty notesProp;
void OnEnable() 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"); Shader shader = Shader.Find("Sprites/Default");
if (shader != null) if (shader != null)
{ {
@ -27,45 +38,35 @@ namespace Fungus.Script
public override void OnInspectorGUI() public override void OnInspectorGUI()
{ {
Character t = target as Character; serializedObject.Update();
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
string characterName = EditorGUILayout.TextField(new GUIContent("Name Text", "Name of the character display in the dialog"), EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog"));
t.characterName);
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"), EditorGUILayout.PropertyField(profileSpriteProp, new GUIContent("Image", "Character image sprite to display in the dialog"));
t.characterColor);
Sprite characterImage = EditorGUILayout.ObjectField(new GUIContent("Image", "Character image sprite to display in the dialog"), EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)"));
t.characterImage,
typeof(Sprite),
true) as Sprite;
EditorGUILayout.Separator(); EditorGUILayout.Separator();
if (characterImage != null && Character t = target as Character;
if (t.profileSprite != null &&
spriteMaterial != null) spriteMaterial != null)
{ {
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); 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)); Rect imagePreviewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(150), GUILayout.ExpandWidth(false));
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();
DrawPreview(imagePreviewRect, DrawPreview(imagePreviewRect, t.profileSprite.texture);
characterImage.texture);
} }
if (EditorGUI.EndChangeCheck()) serializedObject.ApplyModifiedProperties();
{
Undo.RecordObject(t, "Set Character");
t.characterName = characterName;
t.characterColor = characterColor;
t.characterImage = characterImage;
}
} }
public void DrawPreview(Rect previewRect, Texture2D texture) public void DrawPreview(Rect previewRect, Texture2D texture)

6
Assets/Fungus/Dialog/Editor/SayEditor.cs

@ -58,10 +58,10 @@ namespace Fungus.Script
string text = EditorGUILayout.TextArea(t.storyText, sayStyle, GUILayout.MinHeight(60)); string text = EditorGUILayout.TextArea(t.storyText, sayStyle, GUILayout.MinHeight(60));
if (t.character != null && if (t.character != null &&
t.character.characterImage != null && t.character.profileSprite != null &&
t.character.characterImage.texture != 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; float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false)); Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false));

9
Assets/Fungus/Dialog/Scripts/Character.cs

@ -8,9 +8,12 @@ namespace Fungus.Script
[ExecuteInEditMode] [ExecuteInEditMode]
public class Character : MonoBehaviour 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 string nameText; // 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 nameColor = Color.white;
public Color characterColor; public Sprite profileSprite;
[TextArea(5,10)]
public string notes;
static public List<Character> activeCharacters = new List<Character>(); static public List<Character> activeCharacters = new List<Character>();

6
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -71,16 +71,16 @@ namespace Fungus.Script
} }
else else
{ {
SetCharacterImage(character.characterImage); SetCharacterImage(character.profileSprite);
string characterName = character.characterName; string characterName = character.nameText;
if (characterName == "") if (characterName == "")
{ {
// Use game object name as default // Use game object name as default
characterName = character.name; characterName = character.name;
} }
SetCharacterName(characterName, character.characterColor); SetCharacterName(characterName, character.nameColor);
} }
} }

Loading…
Cancel
Save