You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.7 KiB
86 lines
3.7 KiB
8 years ago
|
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
|
||
|
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
|
||
9 years ago
|
|
||
10 years ago
|
using UnityEditor;
|
||
|
using UnityEngine;
|
||
10 years ago
|
using Rotorz.ReorderableList;
|
||
10 years ago
|
|
||
10 years ago
|
namespace Fungus
|
||
10 years ago
|
{
|
||
8 years ago
|
[CustomEditor (typeof(Character))]
|
||
|
public class CharacterEditor : Editor
|
||
|
{
|
||
|
protected SerializedProperty nameTextProp;
|
||
|
protected SerializedProperty nameColorProp;
|
||
|
protected SerializedProperty soundEffectProp;
|
||
|
protected SerializedProperty portraitsProp;
|
||
|
protected SerializedProperty portraitsFaceProp;
|
||
|
protected SerializedProperty descriptionProp;
|
||
|
protected SerializedProperty setSayDialogProp;
|
||
|
|
||
|
protected virtual void OnEnable()
|
||
|
{
|
||
|
nameTextProp = serializedObject.FindProperty ("nameText");
|
||
|
nameColorProp = serializedObject.FindProperty ("nameColor");
|
||
|
soundEffectProp = serializedObject.FindProperty ("soundEffect");
|
||
|
portraitsProp = serializedObject.FindProperty ("portraits");
|
||
|
portraitsFaceProp = serializedObject.FindProperty ("portraitsFace");
|
||
|
descriptionProp = serializedObject.FindProperty ("description");
|
||
|
setSayDialogProp = serializedObject.FindProperty("setSayDialog");
|
||
|
}
|
||
|
|
||
|
public override void OnInspectorGUI()
|
||
|
{
|
||
|
serializedObject.Update();
|
||
|
|
||
|
Character t = target as Character;
|
||
|
|
||
|
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"));
|
||
|
EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog."));
|
||
|
EditorGUILayout.PropertyField(setSayDialogProp);
|
||
|
EditorGUILayout.PropertyField(descriptionProp, new GUIContent("Description", "Notes about this story character (personality, attibutes, etc.)"));
|
||
|
|
||
8 years ago
|
if (t.Portraits != null &&
|
||
|
t.Portraits.Count > 0)
|
||
8 years ago
|
{
|
||
8 years ago
|
t.ProfileSprite = t.Portraits[0];
|
||
8 years ago
|
}
|
||
|
else
|
||
|
{
|
||
8 years ago
|
t.ProfileSprite = null;
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
if (t.ProfileSprite != null)
|
||
8 years ago
|
{
|
||
8 years ago
|
Texture2D characterTexture = t.ProfileSprite.texture;
|
||
8 years ago
|
float aspect = (float)characterTexture.width / (float)characterTexture.height;
|
||
|
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
|
||
|
if (characterTexture != null)
|
||
|
GUI.DrawTexture(previewRect,characterTexture,ScaleMode.ScaleToFit,true,aspect);
|
||
|
}
|
||
|
|
||
|
ReorderableListGUI.Title(new GUIContent("Portraits", "Character image sprites to display in the dialog"));
|
||
|
ReorderableListGUI.ListField(portraitsProp);
|
||
|
|
||
|
EditorGUILayout.HelpBox("All portrait images should use the exact same resolution to avoid positioning and tiling issues.", MessageType.Info);
|
||
|
|
||
|
EditorGUILayout.Separator();
|
||
|
|
||
|
string[] facingArrows = new string[]
|
||
|
{
|
||
|
"FRONT",
|
||
|
"<--",
|
||
|
"-->",
|
||
|
};
|
||
|
portraitsFaceProp.enumValueIndex = EditorGUILayout.Popup("Portraits Face", (int)portraitsFaceProp.enumValueIndex, facingArrows);
|
||
|
|
||
|
EditorGUILayout.Separator();
|
||
|
|
||
|
EditorUtility.SetDirty(t);
|
||
|
|
||
|
serializedObject.ApplyModifiedProperties();
|
||
|
}
|
||
|
|
||
|
}
|
||
10 years ago
|
}
|