protected override void CustomInspectorGUI() { var tTransform = (TweenTransform)tween; EditorGUILayout.BeginHorizontal(); if (tTransform.IsBeginStateSet) { GUI.contentColor = Color.green; } EditorTools.DrawLabel("Begin transform", true, GUILayout.Width(150f)); GUI.contentColor = defaultContentColor; if (EditorTools.DrawButton("R", "Reset begin transform", (tTransform.beginTransform != null), 20f)) { EditorTools.RegisterUndo("Reset begin transform", tTransform); tTransform.beginTransform = null; } tTransform.beginTransform = (Transform)EditorGUILayout.ObjectField(tTransform.beginTransform, typeof(Transform), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (tTransform.IsEndStateSet) { GUI.contentColor = Color.green; } EditorTools.DrawLabel("End transform", true, GUILayout.Width(150f)); GUI.contentColor = defaultContentColor; if (EditorTools.DrawButton("R", "Reset end transform", (tTransform.endTransform != null), 20f)) { EditorTools.RegisterUndo("Reset end transform", tTransform); tTransform.endTransform = null; } tTransform.endTransform = (Transform)EditorGUILayout.ObjectField(tTransform.endTransform, typeof(Transform), true); EditorGUILayout.EndHorizontal(); }
protected override void CustomInspectorGUI() { var tPosition = (TweenPosition)tween; if (tPosition.IsBeginStateSet) { GUI.contentColor = Color.green; } EditorGUILayout.LabelField("Begin position"); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset position to zero", IsResetPositionValid(tPosition.beginPosition), 20f)) { EditorTools.RegisterUndo("Reset begin position", tPosition); tPosition.beginPosition = Vector3.zero; } EditorGUIUtility.LookLikeControls(15f, 0); tPosition.beginPosition = EditorTools.DrawVector3(tPosition.beginPosition); EditorGUIUtility.LookLikeControls(); if (EditorTools.DrawButton("S", "Set current position", IsSetPositionValid(tPosition.beginPosition, tPosition.CachedTransform.localPosition), 20f)) { EditorTools.RegisterUndo("Set begin position", tPosition); tPosition.beginPosition = tPosition.CachedTransform.localPosition; } EditorGUILayout.EndHorizontal(); if (tPosition.IsEndStateSet) { GUI.contentColor = Color.green; } EditorGUILayout.LabelField("End position"); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset position to zero", IsResetPositionValid(tPosition.endPosition), 20f)) { EditorTools.RegisterUndo("Reset end position", tPosition); tPosition.endPosition = Vector3.zero; } EditorGUIUtility.LookLikeControls(15f, 0); tPosition.endPosition = EditorTools.DrawVector3(tPosition.endPosition); EditorGUIUtility.LookLikeControls(); if (EditorTools.DrawButton("S", "Set current position", IsSetPositionValid(tPosition.endPosition, tPosition.CachedTransform.localPosition), 20f)) { EditorTools.RegisterUndo("Set end position", tPosition); tPosition.endPosition = tPosition.CachedTransform.localPosition; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Need Reclculate Position: ", GUILayout.MaxWidth(150)); tPosition.needRecalculatePositions = EditorGUILayout.Toggle(tPosition.needRecalculatePositions, GUILayout.MaxWidth(50)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Ignore Positions Recalculations: ", GUILayout.MaxWidth(150)); tPosition.useAbsolutePosValues = EditorGUILayout.Toggle(tPosition.useAbsolutePosValues, GUILayout.MaxWidth(50)); EditorGUILayout.EndHorizontal(); }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); if (ParameterType.Contains(Type.Width)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2194), 15f); from.x = EditorGUILayout.FloatField(from.x); } if (ParameterType.Contains(Type.Height)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2195), 10f); from.y = EditorGUILayout.FloatField(from.y); } EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); EditorTools.DrawInLine(() => { if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } EditorTools.DrawLabel("Curve", 50f); if (ParameterType.Contains(Type.Width)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2194), 15f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0]); } if (ParameterType.Contains(Type.Height)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2195), 10f); tweenCurves[1] = EditorGUILayout.CurveField(tweenCurves[1]); } }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); if (ParameterType.Contains(Type.Width)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2194), 15f); to.x = EditorGUILayout.FloatField(to.x); } if (ParameterType.Contains(Type.Height)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2195), 10f); to.y = EditorGUILayout.FloatField(to.y); } EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }
static public void DrawInvokeData(InvokeData invoke) { EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset script", (invoke.script != null), 20f)) { invoke.script = invoke.newScript = null; } if (invoke.script != null) { string title = invoke.script.GetType().ToString(); string tooltip = "Set component " + title; GUILayout.Label(new GUIContent(title, tooltip), GUILayout.MinWidth(20f), GUILayout.MaxWidth(90f)); } MonoBehaviour newScript = (MonoBehaviour)EditorGUILayout.ObjectField(invoke.script, typeof(MonoBehaviour), true); if (newScript != invoke.script) { invoke.newScript = newScript; } invoke.method = EditorGUILayout.TextField(invoke.method); EditorGUILayout.EndHorizontal(); if (invoke.newScript != null) { MonoBehaviour[] components = invoke.newScript.GetComponents <MonoBehaviour>(); if (components.Length > 1) { for (int j = 0; j < components.Length; j++) { if (EditorTools.DrawButton("Set " + components[j].GetType().ToString() + " script")) { invoke.script = components[j]; invoke.newScript = null; } } if (EditorTools.DrawButton("Undo")) { invoke.newScript = null; } EditorGUILayout.Space(); } else { invoke.script = components[0]; invoke.newScript = null; } } }
protected override void CustomInspectorGUI() { var tTextureOffset = (TweenTextureOffset)tween; if (tTextureOffset.IsBeginStateSet) { GUI.contentColor = Color.green; } EditorGUILayout.LabelField("Begin offset"); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset offset to zero", IsResetOffsetValid(tTextureOffset.beginOffset), 20f)) { EditorTools.RegisterUndo("Reset begin offset", tTextureOffset); tTextureOffset.beginOffset = Vector2.zero; } EditorGUIUtility.LookLikeControls(15f, 0); tTextureOffset.beginOffset = EditorTools.DrawVector2(tTextureOffset.beginOffset); EditorGUIUtility.LookLikeControls(); if (EditorTools.DrawButton("S", "Set current offset", IsSetOffsetValid(tTextureOffset.beginOffset, tTextureOffset.CurrentOffset), 20f)) { EditorTools.RegisterUndo("Set begin offset", tTextureOffset); tTextureOffset.beginOffset = tTextureOffset.CurrentOffset; } EditorGUILayout.EndHorizontal(); if (tTextureOffset.IsEndStateSet) { GUI.contentColor = Color.green; } EditorGUILayout.LabelField("End offset"); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset offset to zero", IsResetOffsetValid(tTextureOffset.endOffset), 20f)) { EditorTools.RegisterUndo("Reset end offset", tTextureOffset); tTextureOffset.endOffset = Vector2.zero; } EditorGUIUtility.LookLikeControls(15f, 0); tTextureOffset.endOffset = EditorTools.DrawVector2(tTextureOffset.endOffset); EditorGUIUtility.LookLikeControls(); if (EditorTools.DrawButton("S", "Set current offset", IsSetOffsetValid(tTextureOffset.endOffset, tTextureOffset.CurrentOffset), 20f)) { EditorTools.RegisterUndo("Set end offset", tTextureOffset); tTextureOffset.endOffset = tTextureOffset.CurrentOffset; } EditorGUILayout.EndHorizontal(); }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); if (ParameterType.Contains(Type.Color)) { from = EditorGUILayout.ColorField(from); } if (ParameterType.Contains(Type.Alpha)) { from.a = EditorGUILayout.Slider(from.a, 0f, 1f, GUILayout.MinWidth(80f)); } EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); EditorTools.DrawInLine(() => { if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } EditorTools.DrawLabel("Curve", 50f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0]); }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); if (ParameterType.Contains(Type.Color)) { to = EditorGUILayout.ColorField(to); } if (ParameterType.Contains(Type.Alpha)) { to.a = EditorGUILayout.Slider(to.a, 0f, 1f, GUILayout.MinWidth(80f)); } EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }
protected void DrawRunButtons(Tweener t) { EditorGUILayout.BeginHorizontal(); Color defaultColor = GUI.skin.button.normal.textColor; GUI.skin.button.normal.textColor = t.IsBeginStateSet ? Color.green : defaultColor; if (EditorTools.DrawButton("Begin " + t.GetType().ToString().Replace("Tween", "").ToLower())) { t.SetBeginState(); } GUI.skin.button.normal.textColor = t.IsEndStateSet ? Color.green : defaultColor; if (EditorTools.DrawButton("End " + t.GetType().ToString().Replace("Tween", "").ToLower())) { t.SetEndState(); } GUI.skin.button.normal.textColor = defaultColor; EditorGUILayout.EndHorizontal(); }
protected override void CustomInspectorGUI() { TweenGUICellSize currentTween = (TweenGUICellSize)tween; EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Begin size", true, GUILayout.Width(150f)); currentTween.beginSize = EditorGUILayout.FloatField(currentTween.beginSize, GUILayout.MinWidth(150f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("End size", true, GUILayout.Width(150f)); currentTween.endSize = EditorGUILayout.FloatField(currentTween.endSize, GUILayout.MinWidth(150f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Tween target", true, GUILayout.Width(100f)); if (EditorTools.DrawButton("R", "Reset target", IsResetTargetValid(currentTween), 20f)) { EditorTools.RegisterUndo("Reset target", currentTween); currentTween.Target = null; } currentTween.Target = (GUILayoutCell)EditorGUILayout.ObjectField(currentTween.Target, typeof(GUILayoutCell), true); EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { var trans = target as Transform; Vector3 pos, rot, scale; EditorGUILayout.PrefixLabel("Position"); EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("P", "Reset position", IsResetPositionValid(trans), 20f)) { EditorTools.RegisterUndo("Reset Position", trans); trans.localPosition = Vector3.zero; } EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 15f; pos = EditorTools.DrawVector3(trans.localPosition); EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 0f; EditorGUILayout.EndHorizontal(); EditorGUILayout.PrefixLabel("Rotation"); EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset rotation", IsResetRotationValid(trans), 20f)) { EditorTools.RegisterUndo("Reset Rotation", trans); trans.localEulerAngles = Vector3.zero; } EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 15f; rot = EditorTools.DrawVector3(trans.localEulerAngles); EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 0f; EditorGUILayout.EndHorizontal(); EditorGUILayout.PrefixLabel("Scale"); EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("S", "Reset scale", IsResetScaleValid(trans), 20f)) { EditorTools.RegisterUndo("Reset Scale", trans); trans.localScale = Vector3.one; } EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 15f; scale = EditorTools.DrawVector3(trans.localScale); EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 0f; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); useBuffer = EditorTools.DrawToggle(useBuffer, string.Empty, "Use buffer for copy and paste transform values ", true, 20f); if (EditorTools.DrawButton("Copy to buffer", useBuffer)) { bufferPosition = trans.localPosition; bufferRotation = trans.localEulerAngles; bufferScale = trans.localScale; } if (EditorTools.DrawButton("Paste from buffer", useBuffer)) { pos = bufferPosition; rot = bufferRotation; scale = bufferScale; } EditorGUILayout.EndHorizontal(); if (GUI.changed) { EditorTools.RegisterUndo("Transform Change", trans); trans.localPosition = EditorTools.Validate(pos); trans.localEulerAngles = EditorTools.Validate(rot); trans.localScale = EditorTools.Validate(scale); } }
public void DrawInspector() { if (enabled && !Application.isPlaying) { EditorTools.DrawInBox(Color.yellow, () => { var style = new GUIStyle(EditorStyles.boldLabel) { alignment = TextAnchor.MiddleCenter, wordWrap = true }; EditorTools.DrawLabel("It will playing automatically after load scene in play mode! (Uncheck enable if you need)", style); }); } EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Method", 70f); TweenMethod = ( Method )EditorGUILayout.EnumPopup(tweenMethod); }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Style", 70f); TweenStyle = ( Style )EditorGUILayout.EnumPopup(tweenStyle); if (tweenStyle != Style.Once) { EditorTools.DrawLabel("Cycles", 50f); CycleCount = EditorGUILayout.IntField(cycleCount); } }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Duration", 70f); Duration = EditorGUILayout.FloatField(tweenDuration); EditorTools.DrawLabel("Delay", 50f); startDelay = EditorGUILayout.FloatField(startDelay); }); EditorTools.DrawInLine(() => { var parametersForCreate = new [] { typeof(TransformTweening), typeof(ColorTweening), typeof(AlphaTweening), typeof(RectSizeTweening), typeof(FontSizeTweening), typeof(ScaleTweening), typeof(PositionTweening), typeof(ActiveTweening), typeof(WheelFrictionsTweening) }; EditorTools.DrawLabel("New Parameter", 100f); EditorTools.DrawSelector("Select for Add...", Color.green, parametersForCreate, parameter => parameter.Name, selected => AddParameter(selected)); }); parameters = GetComponents <TweeningParameter>(); ArrayTools.DoTimes(() => parameters.Length, index => { parameters[index].hideFlags = HideFlags.HideInInspector; EditorTools.DrawInBox(() => { if (parameters[index].needRemove) { var colors = new[] { EditorGUIUtility.isProSkin?Color.yellow: Color.black, Color.red, Color.green }; EditorTools.DrawQuestionDialogInLine("Remove this parameter?", 110f, () => { DestroyImmediate(parameters[index]); ArrayTools.RemoveAt(ref parameters, index); index--; }, () => { parameters[index].needRemove = false; }, colors); } else { EditorTools.DrawInLine(() => { EditorTools.DrawButton("R", "Remove", () => parameters[index].needRemove = true, EditorStyles.miniButton, Color.red, 20f); parameters[index].DrawTitle(); }); parameters[index].DrawInspector(); } }); return(index); }); }
public override void OnInspectorGUI() { var buttonScaler = (UIButtonScaler)target; defaultContentColor = GUI.contentColor; EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("My UIItem", true, GUILayout.Width(100f)); if (EditorTools.DrawButton("R", "Reset my UIItem", IsResetMyItemValid(buttonScaler), 20f)) { EditorTools.RegisterUndo("Reset my UIItem", buttonScaler); buttonScaler.myItem = buttonScaler.GetComponent <tk2dUIItem>(); } buttonScaler.myItem = (tk2dUIItem)EditorGUILayout.ObjectField(buttonScaler.MyItem, typeof(tk2dUIItem), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Use OnRelease instead of OnUp", true, GUILayout.Width(180f)); buttonScaler.useOnReleaseInsteadOfOnUp = EditorGUILayout.Toggle(buttonScaler.useOnReleaseInsteadOfOnUp); EditorTools.DrawLabel("Cached up scale on awake", true, GUILayout.Width(150f)); buttonScaler.cachedUpScaleOnAwake = EditorGUILayout.Toggle(buttonScaler.cachedUpScaleOnAwake); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Ignore TimeScale", true, GUILayout.Width(180f)); buttonScaler.isIgnoringTimeScale = EditorGUILayout.Toggle(buttonScaler.isIgnoringTimeScale); EditorGUILayout.EndHorizontal(); GUI.contentColor = Color.cyan; EditorGUILayout.LabelField("OnDown section ============================================================================================"); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tDuration", true, GUILayout.Width(100f)); const float defaultDownDuration = 0.1f; if (EditorTools.DrawButton(defaultDownDuration.ToString(), ("Set duration to " + defaultDownDuration), true, 30f)) { buttonScaler.downDuration = defaultDownDuration; } buttonScaler.downDuration = EditorGUILayout.Slider(buttonScaler.downDuration, 0f, 1f); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tMethod", true, GUILayout.Width(100f)); buttonScaler.downMethod = (Method)EditorGUILayout.EnumPopup(buttonScaler.downMethod); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tScale", true, GUILayout.Width(100f)); if (EditorTools.DrawButton("R", "Reset scale to one", IsResetScaleValid(buttonScaler.downScale), 20f)) { EditorTools.RegisterUndo("Reset down scale", buttonScaler); buttonScaler.downScale = Vector3.one; } EditorGUIUtility.LookLikeControls(15f, 0); buttonScaler.downScale = EditorTools.DrawVector3(buttonScaler.downScale); EditorGUIUtility.LookLikeControls(); if (EditorTools.DrawButton("S", "Set current scale", IsSetScaleValid(buttonScaler.downScale, buttonScaler.CachedTransform.localScale), 20f)) { EditorTools.RegisterUndo("Set down scale", buttonScaler); buttonScaler.downScale = buttonScaler.CachedTransform.localScale; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tCurve", true, GUILayout.Width(100f)); buttonScaler.useDownCurve = EditorTools.DrawToggle(buttonScaler.useDownCurve, string.Empty, "Use down curve", true, 15f); buttonScaler.downCurve = EditorGUILayout.CurveField(buttonScaler.downCurve); EditorGUILayout.EndHorizontal(); GUI.contentColor = Color.cyan; EditorGUILayout.LabelField("OnUp/OnRelease section ===================================================================================="); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tDuration", true, GUILayout.Width(100f)); const float defaultUpDuration = 0.5f; if (EditorTools.DrawButton(defaultUpDuration.ToString(), ("Set duration to " + defaultUpDuration), true, 30f)) { buttonScaler.upDuration = defaultUpDuration; } buttonScaler.upDuration = EditorGUILayout.Slider(buttonScaler.upDuration, 0f, 1f); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tMethod", true, GUILayout.Width(100f)); buttonScaler.upMethod = (Method)EditorGUILayout.EnumPopup(buttonScaler.upMethod); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tScale", true, GUILayout.Width(100f)); if (EditorTools.DrawButton("R", "Reset scale to one", IsResetScaleValid(buttonScaler.upScale), 20f)) { EditorTools.RegisterUndo("Reset up scale", buttonScaler); buttonScaler.upScale = Vector3.one; } EditorGUIUtility.LookLikeControls(15f, 0); buttonScaler.upScale = EditorTools.DrawVector3(buttonScaler.upScale); EditorGUIUtility.LookLikeControls(); if (EditorTools.DrawButton("S", "Set current scale", IsSetScaleValid(buttonScaler.upScale, buttonScaler.CachedTransform.localScale), 20f)) { EditorTools.RegisterUndo("Set up scale", buttonScaler); buttonScaler.upScale = buttonScaler.CachedTransform.localScale; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("\tCurve", true, GUILayout.Width(100f)); buttonScaler.useUpCurve = EditorTools.DrawToggle(buttonScaler.useUpCurve, string.Empty, "Use up curve", true, 15f); buttonScaler.upCurve = EditorGUILayout.CurveField(buttonScaler.upCurve); EditorGUILayout.EndHorizontal(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
override public void OnInspectorGUI() { EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Method", true, GUILayout.Width(150f)); tween.method = (Method)EditorGUILayout.EnumPopup(tween.method); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Steeper curves", true, GUILayout.Width(150f)); tween.steeperCurves = EditorGUILayout.Toggle(tween.steeperCurves); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("NotUsedForScreenAnimatingCondition", true, GUILayout.Width(150f)); tween.NotUsedForScreenAnimatingCondition = EditorGUILayout.Toggle(tween.NotUsedForScreenAnimatingCondition); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Style", true, GUILayout.Width(150f)); tween.style = (Style)EditorGUILayout.EnumPopup(tween.style); EditorGUILayout.EndHorizontal(); if (TweensCurves.Instance != null) { List <string> curves = TweensCurves.Instance.IdList; string currentId = tween.AnimationCurveId; int index = 0; if (curves.Exists(id => id.Equals(currentId))) { index = curves.IndexOf(currentId); } else { curves.Insert(index, currentId); } EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Curve ID", true, GUILayout.Width(150f)); int newIndex = EditorGUILayout.Popup(index, curves.ToArray()); EditorGUILayout.EndHorizontal(); if (newIndex != index) { tween.AnimationCurveId = curves[newIndex]; } } EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Curve", true, GUILayout.Width(150f)); tween.useCurve = EditorTools.DrawToggle(tween.useCurve, string.Empty, "Use curve", true, 15f); tween.animationCurve = EditorGUILayout.CurveField(tween.animationCurve); tween.animationCurve.RoundEdges(); if (TweensCurves.Instance != null) { if (EditorTools.DrawButton("S", "Save at prefab (don't forget apply!)", true, 20f)) { TweensCurves.Instance.AddCurve(tween.AnimationCurveId, tween.animationCurve); } if (EditorTools.DrawButton("U", "Update curve from prefab", true, 20f)) { tween.AnimationCurveId = tween.AnimationCurveId; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Ignore time scale", true, GUILayout.Width(150f)); tween.ignoreTimeScale = EditorGUILayout.Toggle(tween.ignoreTimeScale); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Set Begin State At Start", true, GUILayout.Width(150f)); tween.shouldSetBeginStateAtStart = EditorGUILayout.Toggle(tween.shouldSetBeginStateAtStart); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Duration", true, GUILayout.Width(150f)); const float defaultDuration = 1f; if (EditorTools.DrawButton(defaultDuration.ToString(), ("Set duration to " + defaultDuration), true, 20f)) { tween.duration = defaultDuration; } tween.duration = EditorGUILayout.Slider(tween.duration, 0f, 10f); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Scale duration", true, GUILayout.Width(150f)); const float defaultScaleDuration = 1f; if (EditorTools.DrawButton(defaultScaleDuration.ToString(), ("Set scale duration to " + defaultScaleDuration), true, 20f)) { tween.scaleDuration = defaultScaleDuration; } tween.scaleDuration = EditorGUILayout.Slider(tween.scaleDuration, 0f, 5f); EditorGUILayout.EndHorizontal(); EditorGUILayout.PrefixLabel("Call when finished"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Script"); EditorGUILayout.LabelField("Call method"); EditorGUILayout.EndHorizontal(); EditorTools.DrawInvokeData(tween.invokeWhenFinished); Color defaultContentColor = GUI.contentColor; GUI.contentColor = Color.cyan; EditorGUILayout.LabelField("============================================================================================"); GUI.contentColor = defaultContentColor; CustomInspectorGUI(); GUI.contentColor = Color.cyan; EditorGUILayout.LabelField("============================================================================================"); GUI.contentColor = defaultContentColor; if (Application.isPlaying) { DrawRunButtons(tween); } else { DrawStateSlider(tween); } EditorGUILayout.Space(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes ^ BaseType)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); if (ParameterType.Contains(Type.X)) { EditorTools.DrawLabel("X", 12.5f); from.x = EditorGUILayout.FloatField(from.x, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Y)) { EditorTools.DrawLabel("Y", 12.5f); from.y = EditorGUILayout.FloatField(from.y, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Z)) { EditorTools.DrawLabel("Z", 12.5f); from.z = EditorGUILayout.FloatField(from.z, GUILayout.MinWidth(30f)); } EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); EditorTools.DrawInLine(() => { if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } EditorTools.DrawLabel("Curve", 50f); if (ParameterType.Contains(Type.X)) { EditorTools.DrawLabel("X", 12.5f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0], GUILayout.MinWidth(45f)); } if (ParameterType.Contains(Type.Y)) { EditorTools.DrawLabel("Y", 12.5f); tweenCurves[1] = EditorGUILayout.CurveField(tweenCurves[1], GUILayout.MinWidth(45f)); } if (ParameterType.Contains(Type.Z)) { EditorTools.DrawLabel("Z", 12.5f); tweenCurves[2] = EditorGUILayout.CurveField(tweenCurves[2], GUILayout.MinWidth(45f)); } }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); if (ParameterType.Contains(Type.X)) { EditorTools.DrawLabel("X", 12.5f); to.x = EditorGUILayout.FloatField(to.x, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Y)) { EditorTools.DrawLabel("Y", 12.5f); to.y = EditorGUILayout.FloatField(to.y, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Z)) { EditorTools.DrawLabel("Z", 12.5f); to.z = EditorGUILayout.FloatField(to.z, GUILayout.MinWidth(30f)); } EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }
protected override void CustomInspectorGUI() { var tColor = (TweenColor)tween; EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("RGBA chanels mask", true, GUILayout.Width(150f)); Color defaultColor = GUI.backgroundColor; GUI.backgroundColor = Color.red; tColor.useChanelMask[0] = EditorGUILayout.Toggle(tColor.useChanelMask[0], GUILayout.Width(20f)); GUI.backgroundColor = Color.green; tColor.useChanelMask[1] = EditorGUILayout.Toggle(tColor.useChanelMask[1], GUILayout.Width(20f)); GUI.backgroundColor = Color.blue; tColor.useChanelMask[2] = EditorGUILayout.Toggle(tColor.useChanelMask[2], GUILayout.Width(20f)); GUI.backgroundColor = Color.white; tColor.useChanelMask[3] = EditorGUILayout.Toggle(tColor.useChanelMask[3], GUILayout.Width(20f)); GUI.backgroundColor = defaultColor; EditorGUILayout.EndHorizontal(); if (tColor.IsBeginStateSet) { GUI.contentColor = Color.green; } EditorGUILayout.LabelField("Begin " + (tColor.IsOnlyAlphaTween ? "alpha" : "color")); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset alpha value", IsResetColorValid(tColor.beginColor), 20f)) { EditorTools.RegisterUndo("Reset alpha value", tColor); tColor.beginColor.a = 0f; } if (tColor.IsOnlyAlphaTween) { tColor.beginColor.a = EditorGUILayout.Slider(tColor.beginColor.a, 0f, 1f); } else { tColor.beginColor = EditorGUILayout.ColorField(tColor.beginColor); } if (EditorTools.DrawButton("S", ("Set current " + (tColor.IsOnlyAlphaTween ? "alpha value" : "color")), IsSetColorValid(tColor.beginColor, tColor.CurrentColor, tColor.IsOnlyAlphaTween), 20f)) { EditorTools.RegisterUndo(("Set begin " + (tColor.IsOnlyAlphaTween ? "alpha value" : "color")), tColor); if (tColor.IsOnlyAlphaTween) { tColor.beginColor.a = tColor.CurrentColor.a; } else { tColor.beginColor = tColor.CurrentColor; } } EditorGUILayout.EndHorizontal(); if (tColor.IsEndStateSet) { GUI.contentColor = Color.green; } EditorGUILayout.LabelField("End " + (tColor.IsOnlyAlphaTween ? "alpha" : "color")); GUI.contentColor = defaultContentColor; EditorGUILayout.BeginHorizontal(); if (EditorTools.DrawButton("R", "Reset alpha value", IsResetColorValid(tColor.endColor), 20f)) { EditorTools.RegisterUndo("Reset alpha value", tColor); tColor.endColor.a = 0f; } if (tColor.IsOnlyAlphaTween) { tColor.endColor.a = EditorGUILayout.Slider(tColor.endColor.a, 0f, 1f); } else { tColor.endColor = EditorGUILayout.ColorField(tColor.endColor); } if (EditorTools.DrawButton("S", ("Set current " + (tColor.IsOnlyAlphaTween ? "alpha value" : "color")), IsSetColorValid(tColor.endColor, tColor.CurrentColor, tColor.IsOnlyAlphaTween), 20f)) { EditorTools.RegisterUndo(("Set end " + (tColor.IsOnlyAlphaTween ? "alpha value" : "color")), tColor); if (tColor.IsOnlyAlphaTween) { tColor.endColor.a = tColor.CurrentColor.a; } else { tColor.endColor = tColor.CurrentColor; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorTools.DrawLabel("Tween target", true, GUILayout.Width(100f)); if (EditorTools.DrawButton("R", "Reset target", IsResetTargetValid(tColor), 20f)) { EditorTools.RegisterUndo("Reset target", tColor); tColor.Target = null; } tColor.Target = (GameObject)EditorGUILayout.ObjectField(tColor.Target, typeof(GameObject), true); EditorGUILayout.EndHorizontal(); }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); from = EditorTools.DrawObjectField(from, true); EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } if (ParameterType.Contains(Type.Position)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Curve P", 50f); EditorTools.DrawLabel("X", 12.5f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Y", 12.5f); tweenCurves[1] = EditorGUILayout.CurveField(tweenCurves[1], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Z", 12.5f); tweenCurves[2] = EditorGUILayout.CurveField(tweenCurves[2], GUILayout.MinWidth(45f)); }); } if (ParameterType.Contains(Type.Rotation)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Curve R", 50f); tweenCurves[3] = EditorGUILayout.CurveField(tweenCurves[3]); }); } if (ParameterType.Contains(Type.Scale)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Curve S", 50f); EditorTools.DrawLabel("X", 12.5f); tweenCurves[4] = EditorGUILayout.CurveField(tweenCurves[4], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Y", 12.5f); tweenCurves[5] = EditorGUILayout.CurveField(tweenCurves[5], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Z", 12.5f); tweenCurves[6] = EditorGUILayout.CurveField(tweenCurves[6], GUILayout.MinWidth(45f)); }); } EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); to = EditorTools.DrawObjectField(to, true); EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }