119 lines
3.4 KiB
C#
119 lines
3.4 KiB
C#
|
|
#if UNITY_EDITOR
|
||
|
|
//-------------------------------------------------
|
||
|
|
// NGUI: Next-Gen UI kit
|
||
|
|
// Copyright © 2011-2020 Tasharen Entertainment Inc
|
||
|
|
//-------------------------------------------------
|
||
|
|
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEditor;
|
||
|
|
|
||
|
|
[CustomEditor(typeof(UITweener), true)]
|
||
|
|
public class UITweenerEditor : Editor
|
||
|
|
{
|
||
|
|
public override void OnInspectorGUI ()
|
||
|
|
{
|
||
|
|
GUILayout.Space(6f);
|
||
|
|
EditorGUIUtility.labelWidth = 110f;
|
||
|
|
base.OnInspectorGUI();
|
||
|
|
DrawCommonProperties();
|
||
|
|
}
|
||
|
|
|
||
|
|
static public bool DrawHeader(string text, string key, bool forceOn, bool minimalistic)
|
||
|
|
{
|
||
|
|
bool state = EditorPrefs.GetBool(key, true);
|
||
|
|
|
||
|
|
if (!minimalistic) GUILayout.Space(3f);
|
||
|
|
if (!forceOn && !state) GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f);
|
||
|
|
GUILayout.BeginHorizontal();
|
||
|
|
GUI.changed = false;
|
||
|
|
|
||
|
|
if (minimalistic)
|
||
|
|
{
|
||
|
|
if (state) text = "\u25BC" + (char)0x200a + text;
|
||
|
|
else text = "\u25BA" + (char)0x200a + text;
|
||
|
|
|
||
|
|
GUILayout.BeginHorizontal();
|
||
|
|
GUI.contentColor = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.7f) : new Color(0f, 0f, 0f, 0.7f);
|
||
|
|
if (!GUILayout.Toggle(true, text, "PreToolbar2", GUILayout.MinWidth(20f))) state = !state;
|
||
|
|
GUI.contentColor = Color.white;
|
||
|
|
GUILayout.EndHorizontal();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
text = "<b><size=11>" + text + "</size></b>";
|
||
|
|
if (state) text = "\u25BC " + text;
|
||
|
|
else text = "\u25BA " + text;
|
||
|
|
if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) state = !state;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (GUI.changed) EditorPrefs.SetBool(key, state);
|
||
|
|
|
||
|
|
if (!minimalistic) GUILayout.Space(2f);
|
||
|
|
GUILayout.EndHorizontal();
|
||
|
|
GUI.backgroundColor = Color.white;
|
||
|
|
if (!forceOn && !state) GUILayout.Space(3f);
|
||
|
|
return state;
|
||
|
|
}
|
||
|
|
|
||
|
|
static public void BeginContents()
|
||
|
|
{
|
||
|
|
EditorGUILayout.BeginHorizontal(GUILayout.MinHeight(10f));
|
||
|
|
GUILayout.Space(10f);
|
||
|
|
GUILayout.BeginVertical();
|
||
|
|
GUILayout.Space(2f);
|
||
|
|
}
|
||
|
|
static public void EndContents()
|
||
|
|
{
|
||
|
|
GUILayout.Space(3f);
|
||
|
|
GUILayout.EndVertical();
|
||
|
|
EditorGUILayout.EndHorizontal();
|
||
|
|
GUILayout.Space(3f);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void DrawCommonProperties ()
|
||
|
|
{
|
||
|
|
UITweener tw = target as UITweener;
|
||
|
|
|
||
|
|
if (DrawHeader("Tweener", "Tweener", false , true))
|
||
|
|
{
|
||
|
|
BeginContents();
|
||
|
|
EditorGUIUtility.labelWidth = 110f;
|
||
|
|
|
||
|
|
GUI.changed = false;
|
||
|
|
|
||
|
|
UITweener.Style style = (UITweener.Style)EditorGUILayout.EnumPopup("Play Style", tw.style);
|
||
|
|
AnimationCurve curve = EditorGUILayout.CurveField("Animation Curve", tw.animationCurve, GUILayout.Width(170f), GUILayout.Height(62f));
|
||
|
|
|
||
|
|
GUILayout.BeginHorizontal();
|
||
|
|
float dur = EditorGUILayout.FloatField("Duration", tw.duration, GUILayout.Width(170f));
|
||
|
|
GUILayout.Label("seconds");
|
||
|
|
GUILayout.EndHorizontal();
|
||
|
|
|
||
|
|
GUILayout.BeginHorizontal();
|
||
|
|
float del = EditorGUILayout.FloatField("Start Delay", tw.delay, GUILayout.Width(170f));
|
||
|
|
GUILayout.Label("seconds");
|
||
|
|
GUILayout.EndHorizontal();
|
||
|
|
|
||
|
|
var deff = (UITweener.DelayAffects)EditorGUILayout.EnumPopup("Delay Affects", tw.delayAffects);
|
||
|
|
|
||
|
|
int tg = EditorGUILayout.IntField("Tween Group", tw.tweenGroup, GUILayout.Width(170f));
|
||
|
|
bool ts = EditorGUILayout.Toggle("Ignore TimeScale", tw.ignoreTimeScale);
|
||
|
|
bool fx = EditorGUILayout.Toggle("Use Fixed Update", tw.useFixedUpdate);
|
||
|
|
|
||
|
|
if (GUI.changed)
|
||
|
|
{
|
||
|
|
tw.animationCurve = curve;
|
||
|
|
tw.style = style;
|
||
|
|
tw.ignoreTimeScale = ts;
|
||
|
|
tw.tweenGroup = tg;
|
||
|
|
tw.duration = dur;
|
||
|
|
tw.delay = del;
|
||
|
|
tw.delayAffects = deff;
|
||
|
|
tw.useFixedUpdate = fx;
|
||
|
|
}
|
||
|
|
EndContents();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endif
|