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.
77 lines
2.6 KiB
77 lines
2.6 KiB
10 years ago
|
using UnityEditor;
|
||
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
10 years ago
|
using Rotorz.ReorderableList;
|
||
10 years ago
|
using System.Collections.Generic;
|
||
10 years ago
|
|
||
10 years ago
|
namespace Fungus
|
||
10 years ago
|
{
|
||
|
|
||
|
[CustomEditor (typeof(Character))]
|
||
|
public class CharacterEditor : Editor
|
||
|
{
|
||
10 years ago
|
protected SerializedProperty nameTextProp;
|
||
|
protected SerializedProperty nameColorProp;
|
||
10 years ago
|
protected SerializedProperty soundEffectProp;
|
||
10 years ago
|
protected SerializedProperty portraitsProp;
|
||
10 years ago
|
protected SerializedProperty portraitsFaceProp;
|
||
10 years ago
|
protected SerializedProperty notesProp;
|
||
10 years ago
|
|
||
10 years ago
|
protected virtual void OnEnable()
|
||
10 years ago
|
{
|
||
10 years ago
|
nameTextProp = serializedObject.FindProperty ("nameText");
|
||
|
nameColorProp = serializedObject.FindProperty ("nameColor");
|
||
10 years ago
|
soundEffectProp = serializedObject.FindProperty ("soundEffect");
|
||
10 years ago
|
portraitsProp = serializedObject.FindProperty ("portraits");
|
||
10 years ago
|
portraitsFaceProp = serializedObject.FindProperty ("portraitsFace");
|
||
10 years ago
|
notesProp = serializedObject.FindProperty ("notes");
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
public override void OnInspectorGUI()
|
||
|
{
|
||
10 years ago
|
serializedObject.Update();
|
||
10 years ago
|
|
||
10 years ago
|
Character t = target as Character;
|
||
|
|
||
10 years ago
|
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"));
|
||
10 years ago
|
EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog."));
|
||
10 years ago
|
EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)"));
|
||
10 years ago
|
if (t.portraits != null &&
|
||
|
t.portraits.Count > 0)
|
||
|
{
|
||
|
t.profileSprite = t.portraits[0];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
t.profileSprite = null;
|
||
|
}
|
||
10 years ago
|
|
||
|
if (t.profileSprite != null)
|
||
10 years ago
|
{
|
||
10 years ago
|
Texture2D characterTexture = t.profileSprite.texture;
|
||
|
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);
|
||
10 years ago
|
}
|
||
10 years ago
|
ReorderableListGUI.Title(new GUIContent("Portraits", "Character image sprites to display in the dialog"));
|
||
|
ReorderableListGUI.ListField(portraitsProp);
|
||
|
string[] facingArrows = new string[]
|
||
|
{
|
||
|
"FRONT",
|
||
|
"<--",
|
||
|
"-->",
|
||
|
};
|
||
|
portraitsFaceProp.enumValueIndex = EditorGUILayout.Popup("Portraits Face", (int)portraitsFaceProp.enumValueIndex, facingArrows);
|
||
|
|
||
|
EditorGUILayout.Separator();
|
||
|
|
||
|
EditorUtility.SetDirty(t);
|
||
10 years ago
|
|
||
10 years ago
|
serializedObject.ApplyModifiedProperties();
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
}
|
||
|
|
||
|
}
|