|
|
@ -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) |
|
|
|