public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(null); EditorGUIUtility.labelWidth = 80f; EditorGUIUtils.InspectorLogo(); VisualManagerPreset preset = this._src.preset; this._src.preset = (VisualManagerPreset)EditorGUILayout.EnumPopup("Preset", this._src.preset, new GUILayoutOption[0]); if ((preset != this._src.preset) && (this._src.preset == VisualManagerPreset.PoolingSystem)) { this._src.onEnableBehaviour = OnEnableBehaviour.RestartFromSpawnPoint; this._src.onDisableBehaviour = OnDisableBehaviour.Rewind; } GUILayout.Space(6f); bool flag = this._src.preset > VisualManagerPreset.Custom; OnEnableBehaviour onEnableBehaviour = this._src.onEnableBehaviour; OnDisableBehaviour onDisableBehaviour = this._src.onDisableBehaviour; this._src.onEnableBehaviour = (OnEnableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Enable", "Eventual actions to perform when this gameObject is activated"), this._src.onEnableBehaviour, new GUILayoutOption[0]); this._src.onDisableBehaviour = (OnDisableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Disable", "Eventual actions to perform when this gameObject is deactivated"), this._src.onDisableBehaviour, new GUILayoutOption[0]); if ((flag && (onEnableBehaviour != this._src.onEnableBehaviour)) || (onDisableBehaviour != this._src.onDisableBehaviour)) { this._src.preset = VisualManagerPreset.Custom; } if (GUI.changed) { EditorUtility.SetDirty(this._src); } }
private void OnGUI() { this.Connect(false); EditorGUIUtils.SetGUIStyles(this._footerSize); if (Application.isPlaying) { GUILayout.Space(40f); GUILayout.BeginHorizontal(); GUILayout.Space(40f); GUILayout.Label("DOTween Utility Panel\nis disabled while in Play Mode", EditorGUIUtils.wrapCenterLabelStyle, GUILayout.ExpandWidth(true)); GUILayout.Space(40f); GUILayout.EndHorizontal(); } else { Rect position = new Rect(0f, 0f, this._headerSize.x, 30f); this._selectedTab = GUI.Toolbar(position, this._selectedTab, this._tabLabels); int selectedTab = this._selectedTab; if (selectedTab == 1) { this.DrawPreferencesGUI(); } else { this.DrawSetupGUI(); } } }
void OnGUI() { Connect(); EditorGUIUtils.SetGUIStyles(_footerSize); if (Application.isPlaying) { GUILayout.Space(40); GUILayout.BeginHorizontal(); GUILayout.Space(40); GUILayout.Label("DOTween Utility Panel\nis disabled while in Play Mode", EditorGUIUtils.wrapCenterLabelStyle, GUILayout.ExpandWidth(true)); GUILayout.Space(40); GUILayout.EndHorizontal(); } else { Rect areaRect = new Rect(0, 0, _headerSize.x, 30); _selectedTab = GUI.Toolbar(areaRect, _selectedTab, _tabLabels); switch (_selectedTab) { case 1: DrawPreferencesGUI(); break; default: DrawSetupGUI(); break; } } }
public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(null); EditorGUIUtility.labelWidth = 80f; EditorGUIUtils.InspectorLogo(); VisualManagerPreset preset = this._src.preset; this._src.preset = (VisualManagerPreset)EditorGUILayout.EnumPopup("Preset", (Enum)(object)this._src.preset); if (preset != this._src.preset) { VisualManagerPreset preset2 = this._src.preset; if (preset2 == VisualManagerPreset.PoolingSystem) { this._src.onEnableBehaviour = OnEnableBehaviour.RestartFromSpawnPoint; this._src.onDisableBehaviour = OnDisableBehaviour.Rewind; } } GUILayout.Space(6f); bool flag = this._src.preset != VisualManagerPreset.Custom; OnEnableBehaviour onEnableBehaviour = this._src.onEnableBehaviour; OnDisableBehaviour onDisableBehaviour = this._src.onDisableBehaviour; this._src.onEnableBehaviour = (OnEnableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Enable", "Eventual actions to perform when this gameObject is activated"), (Enum)(object)this._src.onEnableBehaviour); this._src.onDisableBehaviour = (OnDisableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Disable", "Eventual actions to perform when this gameObject is deactivated"), (Enum)(object)this._src.onDisableBehaviour); if (flag && onEnableBehaviour != this._src.onEnableBehaviour) { goto IL_0156; } if (onDisableBehaviour != this._src.onDisableBehaviour) { goto IL_0156; } goto IL_0162; IL_0162: if (GUI.changed) { EditorUtility.SetDirty(this._src); } return; IL_0156: this._src.preset = VisualManagerPreset.Custom; goto IL_0162; }
public override void OnInspectorGUI() { targetUILayerElement = target as USpeedUILayerElement; EditorGUIUtils.SetGUIStyles(); if (targetUILayerElement != null) { targetUILayerElement.SetSortingOrder(); EditorGUILayout.Space(); targetUILayerElement.UILayerElementType = (USpeedUILayerElement.EUILayerElementType)EditorGUILayout.EnumPopup("类型:", targetUILayerElement.UILayerElementType); switch (targetUILayerElement.UILayerElementType) { case USpeedUILayerElement.EUILayerElementType.ELET_UI: OnInspectorGUI_UI(); break; case USpeedUILayerElement.EUILayerElementType.ELET_Effect: OnInspectorGUI_Effect(); break; default: break; } EditorGUILayout.Space(); DrawSortingLayer(); EditorGUILayout.Space(); if (GUILayout.Button("编辑模式下移动到其他Layer时点下我")) { targetUILayerElement.TransformParentChanged(); } EditorGUILayout.Space(); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUILayout.Space(3); EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label("对子类的 DoTweem 统一控制", EditorGUIUtils.sideLogoIconBoldLabelStyle); GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_src); } if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_src); } GUILayout.EndHorizontal(); _src.isAutoStart = EditorGUILayout.Toggle("是否一开始显示", _src.isAutoStart); GUILayout.Label("DOTweenAnimation:"); List <DOTweenAnimation> list = _src.l_DoTweens; List <DTExpansion_Fade> lFades = _src.l_Fades; for (int i = 0; i < list.Count; i++) { string tipStr = list[i].delay + " 延时," + list[i].duration + "运行 " + list[i].tipStr; DrawText(list[i].name, list[i].animationType.ToString(), tipStr, list[i].transform); } if (lFades.Count > 0) { GUILayout.Label("DTExpansion_Fade:"); for (int i = 0; i < lFades.Count; i++) { string tmpStr = ""; string tipStr = lFades[i].Delay + " 延时," + lFades[i].Duration + "运行 "; switch (lFades[i].ContrlFadeType) { case EFadeType.Zero2One: tmpStr = "0 -> 1"; break; case EFadeType.One2Zero: tmpStr = "1 -> 0"; break; } DrawText(lFades[i].name, tmpStr, tipStr, lFades[i].transform); } } GUILayout.Space(3); if (GUILayout.Button(" 刷新一下 ")) { _src.DoReset(); } }
public override void OnInspectorGUI() { //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0991: Unknown result type (might be due to invalid IL or missing references) //IL_0996: Unknown result type (might be due to invalid IL or missing references) //IL_09c5: Unknown result type (might be due to invalid IL or missing references) //IL_09ca: Unknown result type (might be due to invalid IL or missing references) base.OnInspectorGUI(); EditorGUIUtils.SetGUIStyles(null); GUILayout.Space(3f); EditorGUIUtils.InspectorLogo(); if (Application.isPlaying) { GUILayout.Space(8f); GUILayout.Label("Path Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10f); } else { if (this._refreshAfterEnable) { this._refreshAfterEnable = false; if (this._src.path == null) { this.ResetPath(RepaintMode.None); } else { this.RefreshPath(RepaintMode.Scene, true); } this._wpsList = new ReorderableList(this._src.wps, typeof(Vector3), true, true, true, true); this._wpsList.drawHeaderCallback = delegate(Rect rect) { EditorGUI.LabelField(rect, "Path Waypoints"); }; this._wpsList.onReorderCallback = delegate { this.RefreshPath(RepaintMode.Scene, true); }; this._wpsList.drawElementCallback = delegate(Rect rect, int index, bool isActive, bool isFocused) { Rect position = new Rect(rect.xMin, rect.yMin, 23f, rect.height); Rect position2 = new Rect(position.xMax, position.yMin, rect.width - 23f, position.height); GUI.Label(position, (index + 1).ToString()); this._src.wps[index] = EditorGUI.Vector3Field(position2, "", this._src.wps[index]); }; } bool flag = false; Undo.RecordObject(this._src, "DOTween Path"); if (!((UnityEngine.Object)((Component)this._src).GetComponent <DOTweenVisualManager>() != (UnityEngine.Object)null) && this._src.inspectorMode != DOTweenInspectorMode.InfoAndWaypointsOnly) { if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"))) { this._src.gameObject.AddComponent <DOTweenVisualManager>(); } GUILayout.Space(4f); } AnimationInspectorGUI.StickyTitle("Scene View Commands"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.Label("➲ SHIFT + " + (EditorUtils.isOSXEditor ? "CMD" : "CTRL") + ": add a waypoint\n➲ SHIFT + ALT: remove a waypoint"); DeGUILayout.EndVBox(); AnimationInspectorGUI.StickyTitle("Info"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.Label("Path Length: " + ((this._src.path == null) ? "-" : this._src.path.length.ToString())); DeGUILayout.EndVBox(); if (this._src.inspectorMode != DOTweenInspectorMode.InfoAndWaypointsOnly) { AnimationInspectorGUI.StickyTitle("Tween Options"); GUILayout.BeginHorizontal(); this._src.autoPlay = DeGUILayout.ToggleButton(this._src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically"), DeGUI.styles.button.tool, new GUILayoutOption[0]); this._src.autoKill = DeGUILayout.ToggleButton(this._src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable"), DeGUI.styles.button.tool, new GUILayoutOption[0]); GUILayout.EndHorizontal(); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.BeginHorizontal(); this._src.duration = EditorGUILayout.FloatField("Duration", this._src.duration); if (this._src.duration < 0f) { this._src.duration = 0f; } this._src.isSpeedBased = DeGUILayout.ToggleButton(this._src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, new GUILayoutOption[1] { GUILayout.Width(75f) }); GUILayout.EndHorizontal(); this._src.delay = EditorGUILayout.FloatField("Delay", this._src.delay); if (this._src.delay < 0f) { this._src.delay = 0f; } this._src.easeType = EditorGUIUtils.FilteredEasePopup(this._src.easeType); if (this._src.easeType == Ease.INTERNAL_Custom) { this._src.easeCurve = EditorGUILayout.CurveField(" Ease Curve", this._src.easeCurve); } this._src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), this._src.loops); if (this._src.loops < -1) { this._src.loops = -1; } if (this._src.loops > 1 || this._src.loops == -1) { this._src.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", (Enum)(object)this._src.loopType); } this._src.id = EditorGUILayout.TextField("ID", this._src.id); this._src.updateType = (UpdateType)EditorGUILayout.EnumPopup("Update Type", (Enum)(object)this._src.updateType); DeGUILayout.EndVBox(); AnimationInspectorGUI.StickyTitle("Path Tween Options"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); PathType pathType = this._src.pathType; this._src.pathType = (PathType)EditorGUILayout.EnumPopup("Path Type", (Enum)(object)this._src.pathType); if (pathType != this._src.pathType) { flag = true; } if (this._src.pathType != 0) { this._src.pathResolution = EditorGUILayout.IntSlider(" Path resolution", this._src.pathResolution, 2, 20); } bool isClosedPath = this._src.isClosedPath; this._src.isClosedPath = EditorGUILayout.Toggle("Close Path", this._src.isClosedPath); if (isClosedPath != this._src.isClosedPath) { flag = true; } this._src.isLocal = EditorGUILayout.Toggle(new GUIContent("Local Movement", "If checked, the path will tween the localPosition (instead than the position) of its target"), this._src.isLocal); this._src.pathMode = (PathMode)EditorGUILayout.EnumPopup("Path Mode", (Enum)(object)this._src.pathMode); this._src.lockRotation = (AxisConstraint)EditorGUILayout.EnumPopup("Lock Rotation", (Enum)(object)this._src.lockRotation); this._src.orientType = (OrientType)EditorGUILayout.EnumPopup("Orientation", (Enum)(object)this._src.orientType); if (this._src.orientType != 0) { switch (this._src.orientType) { case OrientType.LookAtTransform: this._src.lookAtTransform = (EditorGUILayout.ObjectField(" LookAt Target", this._src.lookAtTransform, typeof(Transform), true) as Transform); break; case OrientType.LookAtPosition: this._src.lookAtPosition = EditorGUILayout.Vector3Field(" LookAt Position", this._src.lookAtPosition); break; case OrientType.ToPath: this._src.lookAhead = EditorGUILayout.Slider(" LookAhead", this._src.lookAhead, 0f, 1f); break; } } DeGUILayout.EndVBox(); AnimationInspectorGUI.StickyTitle("Path Editor Options"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); this._src.relative = EditorGUILayout.Toggle(new GUIContent("Relative", "If toggled, the whole path moves with the target"), this._src.relative); this._src.pathColor = EditorGUILayout.ColorField("Color", this._src.pathColor); this._src.showIndexes = EditorGUILayout.Toggle("Show Indexes", this._src.showIndexes); this._src.showWpLength = EditorGUILayout.Toggle("Show WPs Lengths", this._src.showWpLength); this._src.livePreview = EditorGUILayout.Toggle("Live Preview", this._src.livePreview); this._src.handlesType = (HandlesType)EditorGUILayout.EnumPopup("Handles Type", (Enum)(object)this._src.handlesType); this._src.handlesDrawMode = (HandlesDrawMode)EditorGUILayout.EnumPopup("Handles Mode", (Enum)(object)this._src.handlesDrawMode); if (this._src.handlesDrawMode == HandlesDrawMode.Perspective) { this._src.perspectiveHandleSize = EditorGUILayout.FloatField(" Handle Size", this._src.perspectiveHandleSize); } DeGUILayout.EndVBox(); GUILayout.Space(6f); if (GUILayout.Button("Reset Path")) { this.ResetPath(RepaintMode.SceneAndInspector); } AnimationInspectorGUI.AnimationEvents(this, this._src); } else { GUILayout.Space(6f); if (GUILayout.Button("Reset Path")) { this.ResetPath(RepaintMode.SceneAndInspector); } } GUILayout.Space(10f); DeGUILayout.BeginToolbar(new GUILayoutOption[0]); this._src.wpsDropdown = DeGUILayout.ToolbarFoldoutButton(this._src.wpsDropdown, "Waypoints", false, false); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Copy to clipboard", "Copies the current waypoints to clipboard, as an array ready to be pasted in your code"), DeGUI.styles.button.tool)) { this.CopyWaypointsToClipboard(); } DeGUILayout.EndToolbar(); if (this._src.wpsDropdown) { DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); bool changed = GUI.changed; this._wpsList.DoLayoutList(); if (!changed && GUI.changed) { flag = true; } DeGUILayout.EndVBox(); } else { GUILayout.Space(5f); } if (flag) { this.RefreshPath(RepaintMode.Scene, false); } else if (GUI.changed) { EditorUtility.SetDirty(this._src); this.DORepaint(RepaintMode.Scene, false); } } }
override public void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); int totActiveTweens = TweenManager.totActiveTweens; int totPlayingTweens = TweenManager.TotalPlayingTweens(); int totPausedTweens = totActiveTweens - totPlayingTweens; int totActiveDefaultTweens = TweenManager.totActiveDefaultTweens; int totActiveLateTweens = TweenManager.totActiveLateTweens; GUILayout.Space(4); GUILayout.Label(_title, DOTween.isDebugBuild ? EditorGUIUtils.redLabelStyle : EditorGUIUtils.boldLabelStyle); GUILayout.Space(6); GUILayout.BeginHorizontal(); if (GUILayout.Button("Documentation")) { Application.OpenURL("http://dotween.demigiant.com/documentation.php"); } if (GUILayout.Button("Check Updates")) { Application.OpenURL("http://dotween.demigiant.com/download.php?v=" + DOTween.Version); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button(_showPlayingTweensData ? "Hide Playing Tweens" : "Show Playing Tweens")) { _showPlayingTweensData = !_showPlayingTweensData; } if (GUILayout.Button(_showPausedTweensData ? "Hide Paused Tweens" : "Show Paused Tweens")) { _showPausedTweensData = !_showPausedTweensData; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Play all")) { DOTween.PlayAll(); } if (GUILayout.Button("Pause all")) { DOTween.PauseAll(); } if (GUILayout.Button("Kill all")) { DOTween.KillAll(); } GUILayout.EndHorizontal(); GUILayout.Space(8); _strBuilder.Length = 0; _strBuilder.Append("Active tweens: ").Append(totActiveTweens) .Append(" (").Append(TweenManager.totActiveTweeners) .Append("/").Append(TweenManager.totActiveSequences).Append(")") .Append("\nDefault/Late tweens: ").Append(totActiveDefaultTweens) .Append("/").Append(totActiveLateTweens) .Append("\nPlaying tweens: ").Append(totPlayingTweens); if (_showPlayingTweensData) { foreach (Tween t in TweenManager._activeTweens) { if (t != null && t.isPlaying) { _strBuilder.Append("\n - [").Append(t.tweenType).Append("] ").Append(t.target); } } } _strBuilder.Append("\nPaused tweens: ").Append(totPausedTweens); if (_showPausedTweensData) { foreach (Tween t in TweenManager._activeTweens) { if (t != null && !t.isPlaying) { _strBuilder.Append("\n - [").Append(t.tweenType).Append("] ").Append(t.target); } } } _strBuilder.Append("\nPooled tweens: ").Append(TweenManager.TotalPooledTweens()) .Append(" (").Append(TweenManager.totPooledTweeners) .Append("/").Append(TweenManager.totPooledSequences).Append(")"); GUILayout.Label(_strBuilder.ToString()); GUILayout.Space(8); _strBuilder.Remove(0, _strBuilder.Length); _strBuilder.Append("Tweens Capacity: ").Append(TweenManager.maxTweeners).Append("/").Append(TweenManager.maxSequences) .Append("\nMax Simultaneous Active Tweens: ").Append(DOTween.maxActiveTweenersReached).Append("/").Append(DOTween.maxActiveSequencesReached); GUILayout.Label(_strBuilder.ToString()); GUILayout.Space(8); _strBuilder.Remove(0, _strBuilder.Length); _strBuilder.Append("SETTINGS ▼"); _strBuilder.Append("\nSafe Mode: ").Append(DOTween.useSafeMode ? "ON" : "OFF"); _strBuilder.Append("\nLog Behaviour: ").Append(DOTween.logBehaviour); _strBuilder.Append("\nShow Unity Editor Report: ").Append(DOTween.showUnityEditorReport); _strBuilder.Append("\nTimeScale (Unity/DOTween): ").Append(Time.timeScale).Append("/").Append(DOTween.timeScale); GUILayout.Label(_strBuilder.ToString()); GUILayout.Label("NOTE: DOTween's TimeScale is not the same as Unity's Time.timeScale: it is actually multiplied by it except for tweens that are set to update independently", EditorGUIUtils.wordWrapItalicLabelStyle); GUILayout.Space(8); _strBuilder.Remove(0, _strBuilder.Length); _strBuilder.Append("DEFAULTS ▼"); _strBuilder.Append("\ndefaultRecyclable: ").Append(DOTween.defaultRecyclable); _strBuilder.Append("\ndefaultUpdateType: ").Append(DOTween.defaultUpdateType); _strBuilder.Append("\ndefaultTSIndependent: ").Append(DOTween.defaultTimeScaleIndependent); _strBuilder.Append("\ndefaultAutoKill: ").Append(DOTween.defaultAutoKill); _strBuilder.Append("\ndefaultAutoPlay: ").Append(DOTween.defaultAutoPlay); _strBuilder.Append("\ndefaultEaseType: ").Append(DOTween.defaultEaseType); _strBuilder.Append("\ndefaultLoopType: ").Append(DOTween.defaultLoopType); GUILayout.Label(_strBuilder.ToString()); GUILayout.Space(10); }
override public void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label(_src.animationType.ToString().ToUpper() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle); // Up-down buttons GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_src); } if (GUILayout.Button("▼", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_src); } GUILayout.EndHorizontal(); if (Application.isPlaying) { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(4); GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); return; } Undo.RecordObject(_src, "DOTween Animation"); _src.isValid = Validate(); EditorGUIUtility.labelWidth = 120; bool hasManager = _src.GetComponent <DOTweenVisualManager>() != null; if (!hasManager) { if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"))) { _src.gameObject.AddComponent <DOTweenVisualManager>(); } } GUILayout.BeginHorizontal(); DOTweenAnimationType prevAnimType = _src.animationType; _src.animationType = (DOTweenAnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton); _src.autoPlay = EditorGUIUtils.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically")); _src.autoKill = EditorGUIUtils.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable")); GUILayout.EndHorizontal(); if (prevAnimType != _src.animationType) { // Set default optional values based on animation type switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: case DOTweenAnimationType.Scale: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = true; break; case DOTweenAnimationType.Color: case DOTweenAnimationType.Fade: _src.endValueFloat = 0; break; case DOTweenAnimationType.Text: _src.optionalBool0 = true; break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one; _src.optionalFloat0 = 1; _src.optionalInt0 = 10; _src.optionalBool0 = false; break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one; _src.optionalInt0 = 10; _src.optionalFloat0 = 90; _src.optionalBool0 = false; break; } } if (_src.animationType == DOTweenAnimationType.None) { return; } if (!_src.isValid) { GUI.color = Color.red; GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle); GUILayout.EndVertical(); GUI.color = Color.white; return; } _src.duration = EditorGUILayout.FloatField("Duration", _src.duration); if (_src.duration < 0) { _src.duration = 0; } _src.delay = EditorGUILayout.FloatField("Delay", _src.delay); if (_src.delay < 0) { _src.delay = 0; } _src.easeType = EditorGUIUtils.FilteredEasePopup(_src.easeType); if (_src.easeType == Ease.INTERNAL_Custom) { _src.easeCurve = EditorGUILayout.CurveField(" Ease Curve", _src.easeCurve); } _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops); if (_src.loops < -1) { _src.loops = -1; } if (_src.loops > 1 || _src.loops == -1) { _src.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _src.loopType); } _src.id = EditorGUILayout.TextField("ID", _src.id); bool canBeRelative = true; // End value and eventual specific options switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: GUIEndValueV3(); _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); break; case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: if (_src.GetComponent <Rigidbody2D>()) { GUIEndValueFloat(); } else { GUIEndValueV3(); _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup(" Rotation Mode", _src.optionalRotationMode); } break; case DOTweenAnimationType.Scale: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV3(); } _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0); break; case DOTweenAnimationType.Color: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimationType.Fade: GUIEndValueFloat(); if (_src.endValueFloat < 0) { _src.endValueFloat = 0; } if (_src.endValueFloat > 1) { _src.endValueFloat = 1; } canBeRelative = false; break; case DOTweenAnimationType.Text: GUIEndValueString(); _src.optionalBool0 = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0); _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode); _src.optionalString = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString); break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1); if (_src.animationType == DOTweenAnimationType.PunchPosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90); if (_src.animationType == DOTweenAnimationType.ShakePosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; } // Final settings if (canBeRelative) { _src.isRelative = EditorGUILayout.Toggle(" Relative", _src.isRelative); } // Events GUILayout.Space(4); GUILayout.Label("EVENTS", EditorGUIUtils.boldLabelStyle); GUILayout.BeginHorizontal(); _src.hasOnStart = EditorGUIUtils.ToggleButton(_src.hasOnStart, new GUIContent("OnStart", "Event called the first time the tween starts, after any eventual delay")); _src.hasOnStepComplete = EditorGUIUtils.ToggleButton(_src.hasOnStepComplete, new GUIContent("OnStepComplete", "Event called at the end of each loop")); _src.hasOnComplete = EditorGUIUtils.ToggleButton(_src.hasOnComplete, new GUIContent("OnComplete", "Event called at the end of the tween, all loops included")); GUILayout.EndHorizontal(); base.serializedObject.Update(); if (_src.hasOnStart) { EditorGUILayout.PropertyField(_onStartProperty, new GUILayoutOption[0]); } if (_src.hasOnStepComplete) { EditorGUILayout.PropertyField(_onStepCompleteProperty, new GUILayoutOption[0]); } if (_src.hasOnComplete) { EditorGUILayout.PropertyField(_onCompleteProperty, new GUILayoutOption[0]); } base.serializedObject.ApplyModifiedProperties(); }
private void OnSceneGUI() { if (Application.isPlaying) { return; } this.StoreSceneCamData(); if (!this._src.gameObject.activeInHierarchy || !this._sceneCamStored) { return; } if (this._wpsByDepth.Count != this._src.wps.Count) { this.FillWpIndexByDepth(); } EditorGUIUtils.SetGUIStyles(null); Event current = Event.current; Undo.RecordObject(this._src, "DOTween Path"); if (current.type == EventType.MouseDown) { if (current.shift) { if (EditorGUI.actionKey) { Vector3 vector = (this._lastCreatedWpIndex != -1) ? this._src.wps[this._lastCreatedWpIndex] : ((this._selectedWpIndex != -1) ? this._src.wps[this._selectedWpIndex] : ((this._lastSelectedWpIndex != -1) ? this._src.wps[this._lastSelectedWpIndex] : this._src.transform.position)); Matrix4x4 worldToCameraMatrix = this._sceneCam.worldToCameraMatrix; float z = -(worldToCameraMatrix.m20 * vector.x + worldToCameraMatrix.m21 * vector.y + worldToCameraMatrix.m22 * vector.z + worldToCameraMatrix.m23); Vector3 item = this._sceneCam.ViewportToWorldPoint(new Vector3(current.mousePosition.x / this._sceneCam.pixelRect.width, 1f - current.mousePosition.y / this._sceneCam.pixelRect.height, z)); if (this._selectedWpIndex != -1 && this._selectedWpIndex < this._src.wps.Count - 1) { this._src.wps.Insert(this._selectedWpIndex + 1, item); this._lastCreatedWpIndex = this._selectedWpIndex + 1; this._selectedWpIndex = this._lastCreatedWpIndex; } else { this._src.wps.Add(item); this._lastCreatedWpIndex = this._src.wps.Count - 1; this._selectedWpIndex = this._lastCreatedWpIndex; } this.RefreshPath(RepaintMode.Scene, true); return; } if (current.alt && this._src.wps.Count > 1) { this.FindSelectedWaypointIndex(); if (this._selectedWpIndex != -1) { this._src.wps.RemoveAt(this._selectedWpIndex); this.ResetIndexes(); this.RefreshPath(RepaintMode.Scene, true); return; } } } this.FindSelectedWaypointIndex(); } if (this._src.wps.Count < 1) { return; } if (current.type == EventType.MouseDrag) { this._isDragging = true; if (this._src.livePreview) { bool flag = this.CheckTargetMove(); if (this._selectedWpIndex != -1) { flag = true; } if (flag) { this.RefreshPath(RepaintMode.Scene, false); } } } else if (this._isDragging && current.rawType == EventType.MouseUp) { if (this._isDragging && this._selectedWpIndex != -1) { this._reselectAfterDrag = true; } this._isDragging = false; if (this._selectedWpIndex != -1 || this.CheckTargetMove()) { EditorUtility.SetDirty(this._src); this.RefreshPath(RepaintMode.Scene, true); } } else if (this.CheckTargetMove()) { this.RefreshPath(RepaintMode.Scene, false); } if (this._changed && !this._isDragging) { this.FillWpIndexByDepth(); this._changed = false; } int count = this._src.wps.Count; for (int i = 0; i < count; i++) { WpHandle wpHandle = this._wpsByDepth[i]; bool flag2 = wpHandle.wpIndex == this._selectedWpIndex; Vector3 vector2 = this._src.wps[wpHandle.wpIndex]; float num = (this._src.handlesDrawMode == HandlesDrawMode.Orthographic) ? (HandleUtility.GetHandleSize(vector2) * 0.2f) : this._src.perspectiveHandleSize; bool expr_40C = wpHandle.wpIndex >= 0 && wpHandle.wpIndex < (this._src.isClosedPath ? count : (count - 1)); Vector3 vector3 = expr_40C ? ((wpHandle.wpIndex >= count - 1) ? this._src.transform.position : this._src.wps[wpHandle.wpIndex + 1]) : Vector3.zero; bool flag3 = expr_40C && Vector3.Distance(this._sceneCamTrans.position, vector2) < Vector3.Distance(this._sceneCamTrans.position, vector2 + Vector3.ClampMagnitude(vector3 - vector2, num * 1.75f)); if (flag2) { Handles.color = Color.yellow; } else if (wpHandle.wpIndex == count - 1 && !this._src.isClosedPath) { Handles.color = this._wpColorEnd; } else { Handles.color = this._wpColor; } if (expr_40C & flag3) { this.DrawArrowFor(wpHandle.wpIndex, num, vector3); } int controlID = GUIUtility.GetControlID(FocusType.Passive); if (i == 0) { this._minHandleControlId = controlID; } if (this._src.handlesType == HandlesType.Free) { vector2 = Handles.FreeMoveHandle(vector2, Quaternion.identity, num, Vector3.one, new Handles.DrawCapFunction(Handles.SphereCap)); } else { vector2 = Handles.PositionHandle(vector2, Quaternion.identity); } this._src.wps[wpHandle.wpIndex] = vector2; int controlID2 = GUIUtility.GetControlID(FocusType.Passive); wpHandle.controlId = ((i == 0) ? (controlID2 - 1) : (controlID + 1)); this._maxHandleControlId = controlID2; if (expr_40C && !flag3) { this.DrawArrowFor(wpHandle.wpIndex, num, vector3); } Vector3 position = this._sceneCamTrans.InverseTransformPoint(vector2) + new Vector3(num * 0.75f, 0.1f, 0f); position = this._sceneCamTrans.TransformPoint(position); if (this._src.showIndexes || this._src.showWpLength) { string text = (this._src.showIndexes && this._src.showWpLength) ? string.Concat(new object[] { wpHandle.wpIndex + 1, "(", this._src.path.wpLengths[wpHandle.wpIndex + 1].ToString("N2"), ")" }) : (this._src.showIndexes ? (wpHandle.wpIndex + 1).ToString() : this._src.path.wpLengths[wpHandle.wpIndex + 1].ToString("N2")); Handles.Label(position, text, flag2 ? EditorGUIUtils.handleSelectedLabelStyle : EditorGUIUtils.handlelabelStyle); } } Handles.color = this._src.pathColor; if (this._src.pathType == PathType.Linear) { Handles.DrawPolyLine(this._src.path.wps); } else if (this._src.path.nonLinearDrawWps != null) { Handles.DrawPolyLine(this._src.path.nonLinearDrawWps); } if (this._reselectAfterDrag && current.type == EventType.Repaint) { this._reselectAfterDrag = false; } if (!this._changed) { this._changed = this.Changed(); } if (this._changed) { EditorUtility.SetDirty(this._src); } }
public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label("IMAGE ALPHA SCALE", EditorGUIUtils.sideLogoIconBoldLabelStyle); GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_alphascale); } if (GUILayout.Button("▼", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_alphascale); } GUILayout.EndHorizontal(); if (Application.isPlaying) { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(4); GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); return; } GUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _alphascale._Inside = EditorGUILayout.Slider("Start Inside", _alphascale._Inside, 1, 0); _alphascale._Alpha = EditorGUILayout.Slider("Start Alpha", _alphascale._Alpha, 0, 1); if (EditorGUI.EndChangeCheck()) { _alphascale.ChangeValue(); } GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); _alphascale.ASeaseType = EditorGUIUtils.FilteredEasePopup(_alphascale.ASeaseType); if (_alphascale.ASeaseType == Ease.INTERNAL_Custom) { _alphascale.AScurve = EditorGUILayout.CurveField(" AlphaScale Curve", _alphascale.AScurve); } _alphascale.AlphaEaseType = EditorGUIUtils.FilteredEasePopup(_alphascale.AlphaEaseType); if (_alphascale.AlphaEaseType == Ease.INTERNAL_Custom) { _alphascale.AlphaCurve = EditorGUILayout.CurveField(" Alpha Curve", _alphascale.AlphaCurve); } _alphascale.duration = EditorGUILayout.FloatField("Duration", _alphascale.duration); if (_alphascale.duration < 0) { _alphascale.duration = 0; } _alphascale.delay = EditorGUILayout.FloatField("Delay", _alphascale.delay); if (_alphascale.delay < 0) { _alphascale.delay = 0; } _alphascale.loops = EditorGUILayout.IntField(new GUIContent("Loop", "Set to -1 for infinite loops"), _alphascale.loops); if (_alphascale.loops < -1) { _alphascale.loops = -1; } if (_alphascale.loops > 1 || _alphascale.loops == -1) { _alphascale.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _alphascale.loopType); } GUIEndValue(); GUILayout.EndVertical(); }
public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label("IMAGE FLOW", EditorGUIUtils.sideLogoIconBoldLabelStyle); GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_flow); } if (GUILayout.Button("▼", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_flow); } GUILayout.EndHorizontal(); if (Application.isPlaying) { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(4); GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); return; } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); _flow._FlowTex = (Texture2D)EditorGUILayout.ObjectField(_flow._FlowTex, typeof(Texture2D), false, GUILayout.Width(180), GUILayout.Height(180)); if (EditorGUI.EndChangeCheck()) { _flow.ChangeTexture(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _flow._AddColorR = EditorGUILayout.FloatField("+ Color R", _flow._AddColorR); _flow._AddColorG = EditorGUILayout.FloatField("+ Color G", _flow._AddColorG); _flow._AddColorB = EditorGUILayout.FloatField("+ Color B", _flow._AddColorB); _flow._ScrollX = EditorGUILayout.FloatField(" Layer1 ", _flow._ScrollX); _flow._ScrollY = EditorGUILayout.FloatField(" Layer2 ", _flow._ScrollY); if (EditorGUI.EndChangeCheck()) { _flow.ChangeValue(); } GUILayout.EndVertical(); }
//Vector2 srcPos; public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(null); EditorGUIUtility.labelWidth = 80f; EditorGUIUtils.InspectorLogo(); GUILayout.Label("Custom Player", EditorGUIUtils.sideLogoIconBoldLabelStyle); //VisualManagerPreset preset = this._src.preset; //this._src.preset = (VisualManagerPreset)EditorGUILayout.EnumPopup("Preset", this._src.preset, new GUILayoutOption[0]); //if (preset != this._src.preset) //{ // VisualManagerPreset preset2 = this._src.preset; // if (preset2 == VisualManagerPreset.PoolingSystem) // { // this._src.onEnableBehaviour = OnEnableBehaviour.RestartFromSpawnPoint; // this._src.onDisableBehaviour = OnDisableBehaviour.Rewind; // } //} if (GUILayout.Button("Register")) { if (Application.isPlaying) { return; } RegisterAll(_src, false); } if (GUILayout.Button("Register Children")) { if (Application.isPlaying) { return; } RegisterAll(_src, true); } GUILayout.Space(6f); int to_delete = -1; if (_src.AllGroups != null && _src.AllGroups.Length > 0) { //srcPos = GUILayout.BeginScrollView(srcPos); GUILayout.BeginVertical(); for (int i = 0; i < _src.AllGroups.Length; i++) { //GUILayout.BeginArea DOTweenPlayer.DOTGroup dg_item = _src.AllGroups[i]; GUILayout.Space(6f); GUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Group ID : " + dg_item.ID); EditorGUILayout.LabelField("Count : " + dg_item.AllComps.Length); OnEnableBehaviour_My onEnableBehaviour = dg_item.onEnableBehaviour; OnDisableBehaviour_My onDisableBehaviour = dg_item.onDisableBehaviour; if (GUILayout.Button("X", GUILayout.Width(20))) { to_delete = i; } dg_item.onEnableBehaviour = (OnEnableBehaviour_My)EditorGUILayout.EnumPopup(new GUIContent("On Enable", "Eventual actions to perform when this gameObject is activated"), dg_item.onEnableBehaviour, new GUILayoutOption[0]); dg_item.onDisableBehaviour = (OnDisableBehaviour_My)EditorGUILayout.EnumPopup(new GUIContent("On Disable", "Eventual actions to perform when this gameObject is deactivated"), dg_item.onDisableBehaviour, new GUILayoutOption[0]); GUILayout.Space(6f); if (!Application.isPlaying) { GUILayout.BeginHorizontal(); //bool b_autoPlay = false; //bool b_autoKill = false; //for (int k = 0; k < dg_item.AllComps.Length; k++) //{ // if (dg_item.AllComps[k].autoPlay) // { // b_autoPlay = true; // break; // } //} //for (int k = 0; k < dg_item.AllComps.Length; k++) //{ // if (dg_item.AllComps[k].autoKill) // { // b_autoKill = true; // break; // } //} //EditorGUI.BeginChangeCheck(); //b_autoPlay = DeGUILayout.ToggleButton(b_autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically")); //if (EditorGUI.EndChangeCheck()) //{ // ToggleAutoPlay(_src, i, b_autoPlay); //} //EditorGUI.BeginChangeCheck(); //b_autoKill = DeGUILayout.ToggleButton(b_autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable")); //if (EditorGUI.EndChangeCheck()) //{ // ToggleAutoPlay(_src, i, b_autoPlay); //} if (GUILayout.Button("AutoPlay")) { ToggleAutoPlay(_src, i, true); } if (GUILayout.Button("X AutoPlay")) { ToggleAutoPlay(_src, i, false); } if (GUILayout.Button("AutoKill")) { ToggleAutoKill(_src, i, true); } if (GUILayout.Button("X AutoKill")) { ToggleAutoKill(_src, i, false); } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); if (GUILayout.Button("Play")) { _src.Play(dg_item.ID); } if (GUILayout.Button("Pause")) { _src.Pause(dg_item.ID); } if (GUILayout.Button("Rewind")) { _src.Rewind(dg_item.ID); } if (GUILayout.Button("Restart")) { _src.Restart(dg_item.ID); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (to_delete != -1) { DeleteGroup(this._src, to_delete); to_delete = -1; break; } } //GUILayout.EndScrollView(); GUILayout.EndVertical(); } if (GUI.changed) { EditorUtility.SetDirty(this._src); } }
public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); GUILayout.Label("IMAGE EDGE FADE", EditorGUIUtils.sideLogoIconBoldLabelStyle); GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_edgeFade); } if (GUILayout.Button("▼", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_edgeFade); } GUILayout.EndHorizontal(); GUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _edgeFade._Offset = EditorGUILayout.Slider("Offset", _edgeFade._Offset, 0f, 1f); _edgeFade._Alpha = EditorGUILayout.Slider("Alpha", _edgeFade._Alpha, 0f, 1f); _edgeFade._ClipLeft = EditorGUILayout.Slider("Clip Left", _edgeFade._ClipLeft, 0f, 1f); _edgeFade._ClipRight = EditorGUILayout.Slider("Clip Right", _edgeFade._ClipRight, 0f, 1f); _edgeFade._ClipUp = EditorGUILayout.Slider("Clip Up", _edgeFade._ClipUp, 0f, 1f); _edgeFade._ClipDown = EditorGUILayout.Slider("Clip Down", _edgeFade._ClipDown, 0f, 1f); if (EditorGUI.EndChangeCheck()) { _edgeFade.ChangeValue(); } GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); _edgeFade.cLeftEaseType = EditorGUIUtils.FilteredEasePopup(_edgeFade.cLeftEaseType); if (_edgeFade.cLeftEaseType == Ease.INTERNAL_Custom) { _edgeFade.cLeftCurve = EditorGUILayout.CurveField(" Clip Left Curve", _edgeFade.cLeftCurve); } _edgeFade.cLeftDuration = EditorGUILayout.FloatField("Clip Left Duration", _edgeFade.cLeftDuration); if (_edgeFade.cLeftDuration < 0) { _edgeFade.cLeftDuration = 0; } _edgeFade.cLeftDelay = EditorGUILayout.FloatField("Clip Left Delay", _edgeFade.cLeftDelay); if (_edgeFade.cLeftDelay < 0) { _edgeFade.cLeftDelay = 0; } _edgeFade.cLeftLoops = EditorGUILayout.IntField(new GUIContent("Loop", "Set to -1 for infinite loops"), _edgeFade.cLeftLoops); if (_edgeFade.cLeftLoops < -1) { _edgeFade.cLeftLoops = -1; } if (_edgeFade.cLeftLoops > 1 || _edgeFade.cLeftLoops == -1) { _edgeFade.cLeftLoopType = (LoopType)EditorGUILayout.EnumPopup(" Clip Loop Type", _edgeFade.cLeftLoopType); } _edgeFade.cLeftEndValue = EditorGUILayout.FloatField("Clip Left End Value", _edgeFade.cLeftEndValue); GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); _edgeFade.cRightEaseType = EditorGUIUtils.FilteredEasePopup(_edgeFade.cRightEaseType); if (_edgeFade.cRightEaseType == Ease.INTERNAL_Custom) { _edgeFade.cRightCurve = EditorGUILayout.CurveField(" Clip Right Curve", _edgeFade.cRightCurve); } _edgeFade.cRightDuration = EditorGUILayout.FloatField("Clip Right Duration", _edgeFade.cRightDuration); if (_edgeFade.cRightDuration < 0) { _edgeFade.cRightDuration = 0; } _edgeFade.cRightDelay = EditorGUILayout.FloatField("Clip Right Delay", _edgeFade.cRightDelay); if (_edgeFade.cRightDelay < 0) { _edgeFade.cRightDelay = 0; } _edgeFade.cRightLoops = EditorGUILayout.IntField(new GUIContent("Loop", "Set to -1 for infinite loops"), _edgeFade.cRightLoops); if (_edgeFade.cRightLoops < -1) { _edgeFade.cRightLoops = -1; } if (_edgeFade.cRightLoops > 1 || _edgeFade.cRightLoops == -1) { _edgeFade.cRightLoopType = (LoopType)EditorGUILayout.EnumPopup(" Clip Loop Type", _edgeFade.cRightLoopType); } _edgeFade.cRightEndValue = EditorGUILayout.FloatField("Clip Right End Value", _edgeFade.cRightEndValue); GUILayout.EndVertical(); }
override public void OnInspectorGUI() { base.OnInspectorGUI(); GUILayout.Space(3); EditorGUIUtils.SetGUIStyles(); bool playMode = Application.isPlaying; _runtimeEditMode = _runtimeEditMode && playMode; GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle); // Up-down buttons GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_src); } if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_src); } GUILayout.EndHorizontal(); if (playMode) { if (_runtimeEditMode) { } else { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); if (!_src.isActive) { GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle); GUI.enabled = false; } if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them"))) { _runtimeEditMode = true; } GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); if (!_runtimeEditMode) { return; } } } Undo.RecordObject(_src, "DOTween Animation"); Undo.RecordObject(_settings, "DOTween Animation"); // _src.isValid = Validate(); // Moved down EditorGUIUtility.labelWidth = 110; if (playMode) { GUILayout.Space(4); DeGUILayout.Toolbar("Edit Mode Commands"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.BeginHorizontal(); if (GUILayout.Button("TogglePause")) { _src.tween.TogglePause(); } if (GUILayout.Button("Rewind")) { _src.tween.Rewind(); } if (GUILayout.Button("Restart")) { _src.tween.Restart(); } GUILayout.EndHorizontal(); if (GUILayout.Button("Commit changes and restart")) { _src.tween.Rewind(); _src.tween.Kill(); if (_src.isValid) { _src.CreateTween(); _src.tween.Play(); } } GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap); DeGUILayout.EndVBox(); } else { GUILayout.BeginHorizontal(); bool hasManager = _src.GetComponent <DOTweenVisualManager>() != null; EditorGUI.BeginChangeCheck(); _settings.showPreviewPanel = hasManager ? DeGUILayout.ToggleButton(_settings.showPreviewPanel, "Preview Controls", styles.custom.inlineToggle) : DeGUILayout.ToggleButton(_settings.showPreviewPanel, "Preview Controls", styles.custom.inlineToggle, GUILayout.Width(120)); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(_settings); DOTweenPreviewManager.StopAllPreviews(); } if (!hasManager) { if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"))) { _src.gameObject.AddComponent <DOTweenVisualManager>(); } } GUILayout.EndHorizontal(); } // Preview in editor bool isPreviewing = _settings.showPreviewPanel ? DOTweenPreviewManager.PreviewGUI(_src) : false; EditorGUI.BeginDisabledGroup(isPreviewing); // Choose target GUILayout.BeginHorizontal(); _src.isActive = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(14)); EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck(); _src.targetIsSelf = DeGUILayout.ToggleButton( _src.targetIsSelf, _src.targetIsSelf ? _GuiC_selfTarget_true : _GuiC_selfTarget_false, new Color(1f, 0.78f, 0f), DeGUI.colors.bg.toggleOn, new Color(0.33f, 0.14f, 0.02f), DeGUI.colors.content.toggleOn, null, GUILayout.Width(47) ); bool innerChanged = EditorGUI.EndChangeCheck(); if (innerChanged) { _src.targetGO = null; GUI.changed = true; } if (_src.targetIsSelf) { GUILayout.Label(_GuiC_selfTarget_true.tooltip); } else { using (new DeGUI.ColorScope(null, null, _src.targetGO == null ? Color.red : Color.white)) { _src.targetGO = (GameObject)EditorGUILayout.ObjectField(_src.targetGO, typeof(GameObject), true); } _src.tweenTargetIsTargetGO = DeGUILayout.ToggleButton( _src.tweenTargetIsTargetGO, _src.tweenTargetIsTargetGO ? _GuiC_tweenTargetIsTargetGO_true : _GuiC_tweenTargetIsTargetGO_false, GUILayout.Width(131) ); } bool check = EditorGUI.EndChangeCheck(); if (check) { _refreshRequired = true; } GUILayout.EndHorizontal(); GameObject targetGO = _src.targetIsSelf ? _src.gameObject : _src.targetGO; if (targetGO == null) { // Uses external target gameObject but it's not set if (_src.targetGO != null || _src.target != null) { _src.targetGO = null; _src.target = null; GUI.changed = true; } } else { GUILayout.BeginHorizontal(); DOTweenAnimation.AnimationType prevAnimType = _src.animationType; // _src.animationType = (DOTweenAnimation.AnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton); GUI.enabled = GUI.enabled && _src.isActive; _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]); _src.autoGenerate = DeGUILayout.ToggleButton(_src.autoGenerate, new GUIContent("AutoGenerate", "If selected, the tween will be generated at startup (during Start for RectTransform position tween, Awake for all the others)")); if (_src.autoGenerate) { _src.autoPlay = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically")); } _src.autoKill = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable")); GUILayout.EndHorizontal(); if (prevAnimType != _src.animationType) { // Set default optional values based on animation type _src.endValueTransform = null; _src.useTargetAsV3 = false; switch (_src.animationType) { case DOTweenAnimation.AnimationType.Move: case DOTweenAnimation.AnimationType.LocalMove: case DOTweenAnimation.AnimationType.Rotate: case DOTweenAnimation.AnimationType.LocalRotate: case DOTweenAnimation.AnimationType.Scale: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = _src.animationType == DOTweenAnimation.AnimationType.Scale; break; case DOTweenAnimation.AnimationType.UIWidthHeight: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = _src.animationType == DOTweenAnimation.AnimationType.UIWidthHeight; break; case DOTweenAnimation.AnimationType.Color: case DOTweenAnimation.AnimationType.Fade: _isLightSrc = targetGO.GetComponent <Light>() != null; _src.endValueFloat = 0; break; case DOTweenAnimation.AnimationType.Text: _src.optionalBool0 = true; break; case DOTweenAnimation.AnimationType.PunchPosition: case DOTweenAnimation.AnimationType.PunchRotation: case DOTweenAnimation.AnimationType.PunchScale: _src.endValueV3 = _src.animationType == DOTweenAnimation.AnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one; _src.optionalFloat0 = 1; _src.optionalInt0 = 10; _src.optionalBool0 = false; break; case DOTweenAnimation.AnimationType.ShakePosition: case DOTweenAnimation.AnimationType.ShakeRotation: case DOTweenAnimation.AnimationType.ShakeScale: _src.endValueV3 = _src.animationType == DOTweenAnimation.AnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one; _src.optionalInt0 = 10; _src.optionalFloat0 = 90; _src.optionalBool0 = false; _src.optionalBool1 = true; break; case DOTweenAnimation.AnimationType.CameraAspect: case DOTweenAnimation.AnimationType.CameraFieldOfView: case DOTweenAnimation.AnimationType.CameraOrthoSize: _src.endValueFloat = 0; break; case DOTweenAnimation.AnimationType.CameraPixelRect: case DOTweenAnimation.AnimationType.CameraRect: _src.endValueRect = new Rect(0, 0, 0, 0); break; } } if (_src.animationType == DOTweenAnimation.AnimationType.None) { _src.isValid = false; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } if (_refreshRequired || prevAnimType != _src.animationType || ComponentsChanged()) { _refreshRequired = false; _src.isValid = Validate(targetGO); // See if we need to choose between multiple targets #if true // UI_MARKER if (_src.animationType == DOTweenAnimation.AnimationType.Fade && targetGO.GetComponent <CanvasGroup>() != null && targetGO.GetComponent <Image>() != null) { _chooseTargetMode = ChooseTargetMode.BetweenCanvasGroupAndImage; // Reassign target and forcedTargetType if lost if (_src.forcedTargetType == DOTweenAnimation.TargetType.Unset) { _src.forcedTargetType = _src.targetType; } switch (_src.forcedTargetType) { case DOTweenAnimation.TargetType.CanvasGroup: _src.target = targetGO.GetComponent <CanvasGroup>(); break; case DOTweenAnimation.TargetType.Image: _src.target = targetGO.GetComponent <Image>(); break; } } else { #endif _chooseTargetMode = ChooseTargetMode.None; _src.forcedTargetType = DOTweenAnimation.TargetType.Unset; #if true // UI_MARKER } #endif } if (!_src.isValid) { GUI.color = Color.red; GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle); GUILayout.EndVertical(); GUI.color = Color.white; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } #if true // UI_MARKER // Special cases in which multiple target types could be used (set after validation) if (_chooseTargetMode == ChooseTargetMode.BetweenCanvasGroupAndImage && _src.forcedTargetType != DOTweenAnimation.TargetType.Unset) { FadeTargetType fadeTargetType = (FadeTargetType)Enum.Parse(typeof(FadeTargetType), _src.forcedTargetType.ToString()); DOTweenAnimation.TargetType prevTargetType = _src.forcedTargetType; _src.forcedTargetType = (DOTweenAnimation.TargetType)Enum.Parse(typeof(DOTweenAnimation.TargetType), EditorGUILayout.EnumPopup(_src.animationType + " Target", fadeTargetType).ToString()); if (_src.forcedTargetType != prevTargetType) { // Target type change > assign correct target switch (_src.forcedTargetType) { case DOTweenAnimation.TargetType.CanvasGroup: _src.target = targetGO.GetComponent <CanvasGroup>(); break; case DOTweenAnimation.TargetType.Image: _src.target = targetGO.GetComponent <Image>(); break; } } } #endif GUILayout.BeginHorizontal(); _src.duration = EditorGUILayout.FloatField("Duration", _src.duration); if (_src.duration < 0) { _src.duration = 0; } _src.isSpeedBased = DeGUILayout.ToggleButton(_src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, GUILayout.Width(75)); GUILayout.EndHorizontal(); _src.delay = EditorGUILayout.FloatField("Delay", _src.delay); if (_src.delay < 0) { _src.delay = 0; } _src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate); _src.easeType = EditorGUIUtils.FilteredEasePopup("Ease", _src.easeType); if (_src.easeType == Ease.INTERNAL_Custom) { _src.easeCurve = EditorGUILayout.CurveField(" Ease Curve", _src.easeCurve); } _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops); if (_src.loops < -1) { _src.loops = -1; } if (_src.loops > 1 || _src.loops == -1) { _src.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _src.loopType); } _src.id = EditorGUILayout.TextField("ID", _src.id); bool canBeRelative = true; // End value and eventual specific options switch (_src.animationType) { case DOTweenAnimation.AnimationType.Move: case DOTweenAnimation.AnimationType.LocalMove: GUIEndValueV3(targetGO, _src.animationType == DOTweenAnimation.AnimationType.Move); _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); canBeRelative = !_src.useTargetAsV3; break; case DOTweenAnimation.AnimationType.Rotate: case DOTweenAnimation.AnimationType.LocalRotate: bool isRigidbody2D = DOTweenModuleUtils.Physics.HasRigidbody2D(_src); if (isRigidbody2D) { GUIEndValueFloat(); } else { GUIEndValueV3(targetGO); _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup(" Rotation Mode", _src.optionalRotationMode); } break; case DOTweenAnimation.AnimationType.Scale: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV3(targetGO); } _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0); break; case DOTweenAnimation.AnimationType.UIWidthHeight: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV2(); } _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0); break; case DOTweenAnimation.AnimationType.Color: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimation.AnimationType.Fade: GUIEndValueFloat(); if (_src.endValueFloat < 0) { _src.endValueFloat = 0; } if (!_isLightSrc && _src.endValueFloat > 1) { _src.endValueFloat = 1; } canBeRelative = false; break; case DOTweenAnimation.AnimationType.Text: GUIEndValueString(); _src.optionalBool0 = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0); _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode); _src.optionalString = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString); break; case DOTweenAnimation.AnimationType.PunchPosition: case DOTweenAnimation.AnimationType.PunchRotation: case DOTweenAnimation.AnimationType.PunchScale: GUIEndValueV3(targetGO); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1); if (_src.animationType == DOTweenAnimation.AnimationType.PunchPosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; case DOTweenAnimation.AnimationType.ShakePosition: case DOTweenAnimation.AnimationType.ShakeRotation: case DOTweenAnimation.AnimationType.ShakeScale: GUIEndValueV3(targetGO); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90); _src.optionalBool1 = EditorGUILayout.Toggle(new GUIContent(" FadeOut", "If selected the shake will fade out, otherwise it will constantly play with full force"), _src.optionalBool1); if (_src.animationType == DOTweenAnimation.AnimationType.ShakePosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; case DOTweenAnimation.AnimationType.CameraAspect: case DOTweenAnimation.AnimationType.CameraFieldOfView: case DOTweenAnimation.AnimationType.CameraOrthoSize: GUIEndValueFloat(); canBeRelative = false; break; case DOTweenAnimation.AnimationType.CameraBackgroundColor: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimation.AnimationType.CameraPixelRect: case DOTweenAnimation.AnimationType.CameraRect: GUIEndValueRect(); canBeRelative = false; break; } // Final settings if (canBeRelative) { _src.isRelative = EditorGUILayout.Toggle(" Relative", _src.isRelative); } // Events AnimationInspectorGUI.AnimationEvents(this, _src); } EditorGUI.EndDisabledGroup(); if (GUI.changed) { EditorUtility.SetDirty(_src); } }
public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label("IMAGE SMOKE", EditorGUIUtils.sideLogoIconBoldLabelStyle); GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_smoke); } if (GUILayout.Button("▼", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_smoke); } GUILayout.EndHorizontal(); if (Application.isPlaying) { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(4); GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); return; } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); _smoke.SmokeTex = (Texture2D)EditorGUILayout.ObjectField(_smoke.SmokeTex, typeof(Texture2D), false, GUILayout.Width(180), GUILayout.Height(180)); if (EditorGUI.EndChangeCheck()) { _smoke.ChangeTexture(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _smoke._Value2 = EditorGUILayout.Slider("Start Smoke Value", _smoke._Value2, 0, 1); _smoke._SmokeColor1 = EditorGUILayout.ColorField("Smoke Color", _smoke._SmokeColor1); _smoke._SmokeColor2 = EditorGUILayout.ColorField("Smoke Color2", _smoke._SmokeColor2); if (EditorGUI.EndChangeCheck()) { _smoke.ChangeScroll(); } GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); _smoke.SmokeEaseType = EditorGUIUtils.FilteredEasePopup(_smoke.SmokeEaseType); if (_smoke.SmokeEaseType == Ease.INTERNAL_Custom) { _smoke.SmokeSpdCurve = EditorGUILayout.CurveField(" Smoke Value Curve", _smoke.SmokeSpdCurve); } _smoke.duration = EditorGUILayout.FloatField("Duration", _smoke.duration); if (_smoke.duration < 0) { _smoke.duration = 0; } _smoke.delay = EditorGUILayout.FloatField("Delay", _smoke.delay); if (_smoke.delay < 0) { _smoke.delay = 0; } _smoke.loops = EditorGUILayout.IntField(new GUIContent("Loop", "Set to -1 for infinite loops"), _smoke.loops); if (_smoke.loops < -1) { _smoke.loops = -1; } if (_smoke.loops > 1 || _smoke.loops == -1) { _smoke.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _smoke.loopType); } GUIEndValue(); GUILayout.EndVertical(); }
private void OnSceneGUI() { if (!Application.isPlaying) { this.StoreSceneCamData(); if (this._src.gameObject.activeInHierarchy && this._sceneCamStored) { if (this._wpsByDepth.Count != this._src.wps.Count) { this.FillWpIndexByDepth(); } EditorGUIUtils.SetGUIStyles(null); Event current = Event.current; Undo.RecordObject(this._src, "DOTween Path"); if (current.type == EventType.MouseDown) { if (current.shift) { if (EditorGUI.actionKey) { Vector3 vector = (this._lastCreatedWpIndex != -1) ? this._src.wps[this._lastCreatedWpIndex] : ((this._selectedWpIndex != -1) ? this._src.wps[this._selectedWpIndex] : ((this._lastSelectedWpIndex != -1) ? this._src.wps[this._lastSelectedWpIndex] : this._src.transform.position)); Matrix4x4 worldToCameraMatrix = this._sceneCam.worldToCameraMatrix; float z = -((((worldToCameraMatrix.m20 * vector.x) + (worldToCameraMatrix.m21 * vector.y)) + (worldToCameraMatrix.m22 * vector.z)) + worldToCameraMatrix.m23); Vector3 item = this._sceneCam.ViewportToWorldPoint(new Vector3(current.mousePosition.x / this._sceneCam.pixelRect.width, 1f - (current.mousePosition.y / this._sceneCam.pixelRect.height), z)); if ((this._selectedWpIndex != -1) && (this._selectedWpIndex < (this._src.wps.Count - 1))) { this._src.wps.Insert(this._selectedWpIndex + 1, item); this._lastCreatedWpIndex = this._selectedWpIndex + 1; this._selectedWpIndex = this._lastCreatedWpIndex; } else { this._src.wps.Add(item); this._lastCreatedWpIndex = this._src.wps.Count - 1; this._selectedWpIndex = this._lastCreatedWpIndex; } this.RefreshPath(RepaintMode.Scene, true); return; } if (current.alt && (this._src.wps.Count > 1)) { this.FindSelectedWaypointIndex(); if (this._selectedWpIndex != -1) { this._src.wps.RemoveAt(this._selectedWpIndex); this.ResetIndexes(); this.RefreshPath(RepaintMode.Scene, true); return; } } } this.FindSelectedWaypointIndex(); } if (this._src.wps.Count >= 1) { if (current.type == EventType.MouseDrag) { this._isDragging = true; if (this._src.livePreview) { bool flag = this.CheckTargetMove(); if (this._selectedWpIndex != -1) { flag = true; } if (flag) { this.RefreshPath(RepaintMode.Scene, false); } } } else if (this._isDragging && (current.rawType == EventType.MouseUp)) { if (this._isDragging && (this._selectedWpIndex != -1)) { this._reselectAfterDrag = true; } this._isDragging = false; if ((this._selectedWpIndex != -1) || this.CheckTargetMove()) { EditorUtility.SetDirty(this._src); this.RefreshPath(RepaintMode.Scene, true); } } else if (this.CheckTargetMove()) { this.RefreshPath(RepaintMode.Scene, false); } if (this._changed && !this._isDragging) { this.FillWpIndexByDepth(); this._changed = false; } int count = this._src.wps.Count; for (int i = 0; i < count; i++) { WpHandle handle = this._wpsByDepth[i]; bool flag2 = handle.wpIndex == this._selectedWpIndex; Vector3 position = this._src.wps[handle.wpIndex]; float handleSize = (this._src.handlesDrawMode == HandlesDrawMode.Orthographic) ? (HandleUtility.GetHandleSize(position) * 0.2f) : this._src.perspectiveHandleSize; bool flag1 = (handle.wpIndex >= 0) && (handle.wpIndex < (this._src.isClosedPath ? count : (count - 1))); Vector3 arrowPointsAt = flag1 ? ((handle.wpIndex >= (count - 1)) ? this._src.transform.position : this._src.wps[handle.wpIndex + 1]) : Vector3.zero; bool flag3 = flag1 && (Vector3.Distance(this._sceneCamTrans.position, position) < Vector3.Distance(this._sceneCamTrans.position, position + Vector3.ClampMagnitude(arrowPointsAt - position, handleSize * 1.75f))); if (flag2) { Handles.color = Color.yellow; } else if ((handle.wpIndex == (count - 1)) && !this._src.isClosedPath) { Handles.color = this._wpColorEnd; } else { Handles.color = this._wpColor; } if (flag1 & flag3) { this.DrawArrowFor(handle.wpIndex, handleSize, arrowPointsAt); } int controlID = GUIUtility.GetControlID(FocusType.Passive); if (i == 0) { this._minHandleControlId = controlID; } if (this._src.handlesType == HandlesType.Free) { position = Handles.FreeMoveHandle(position, Quaternion.identity, handleSize, Vector3.one, new Handles.CapFunction(Handles.SphereHandleCap)); //position = Handles.FreeMoveHandle(position, Quaternion.identity, handleSize, Vector3.one, new Handles.DrawCapFunction(Handles.SphereCap)); } else { position = Handles.PositionHandle(position, Quaternion.identity); } this._src.wps[handle.wpIndex] = position; int num6 = GUIUtility.GetControlID(FocusType.Passive); handle.controlId = (i == 0) ? (num6 - 1) : (controlID + 1); this._maxHandleControlId = num6; if (flag1 && !flag3) { this.DrawArrowFor(handle.wpIndex, handleSize, arrowPointsAt); } Vector3 vector5 = this._sceneCamTrans.InverseTransformPoint(position) + new Vector3(handleSize * 0.75f, 0.1f, 0f); vector5 = this._sceneCamTrans.TransformPoint(vector5); if (this._src.showIndexes) { Handles.Label(vector5, (handle.wpIndex + 1).ToString(), flag2 ? EditorGUIUtils.handleSelectedLabelStyle : EditorGUIUtils.handlelabelStyle); } } Handles.color = this._src.pathColor; if (this._src.pathType == PathType.Linear) { Handles.DrawPolyLine(this._src.path.wps); } else if (this._src.path.nonLinearDrawWps != null) { Handles.DrawPolyLine(this._src.path.nonLinearDrawWps); } if (this._reselectAfterDrag && (current.type == EventType.Repaint)) { this._reselectAfterDrag = false; } if (!this._changed) { this._changed = this.Changed(); } if (this._changed) { EditorUtility.SetDirty(this._src); } } } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUIUtils.SetGUIStyles(null); GUILayout.Space(3f); EditorGUIUtils.InspectorLogo(); if (Application.isPlaying) { GUILayout.Space(8f); GUILayout.Label("Path Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle, new GUILayoutOption[0]); GUILayout.Space(10f); return; } if (this._refreshAfterEnable) { this._refreshAfterEnable = false; if (this._src.path == null) { this.ResetPath(RepaintMode.None); } else { this.RefreshPath(RepaintMode.Scene, true); } this._wpsList = new ReorderableList(this._src.wps, typeof(Vector3), true, true, true, true); ReorderableList arg_CD_0 = this._wpsList; ReorderableList.HeaderCallbackDelegate arg_CD_1; if ((arg_CD_1 = DOTweenPathInspector.HeaderItem.headerHander) == null) { HeaderItem.headerHander = new ReorderableList.HeaderCallbackDelegate(HeaderItem.item.OnInspectorGUI); arg_CD_1 = HeaderItem.headerHander; } arg_CD_0.drawHeaderCallback = arg_CD_1; this._wpsList.onReorderCallback = delegate(ReorderableList list) { this.RefreshPath(RepaintMode.Scene, true); }; this._wpsList.drawElementCallback = delegate(Rect rect, int index, bool isActive, bool isFocused) { Rect position = new Rect(rect.xMin, rect.yMin, 23f, rect.height); Rect position2 = new Rect(position.xMax, position.yMin, rect.width - 23f, position.height); GUI.Label(position, (index + 1).ToString()); this._src.wps[index] = EditorGUI.Vector3Field(position2, "", this._src.wps[index]); }; } bool flag = false; Undo.RecordObject(this._src, "DOTween Path"); if (this._src.inspectorMode != DOTweenInspectorMode.Default) { GUILayout.Label("Inspector Mode: <b>" + this._src.inspectorMode + "</b>", ABSAnimationInspector.styles.custom.warningLabel, new GUILayoutOption[0]); GUILayout.Space(2f); } if (!(this._src.GetComponent <DOTweenVisualManager>() != null) && this._showAddManager) { if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"), new GUILayoutOption[0])) { this._src.gameObject.AddComponent <DOTweenVisualManager>(); } GUILayout.Space(4f); } AnimationInspectorGUI.StickyTitle("Scene View Commands"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.Label("➲ SHIFT + " + (EditorUtils.isOSXEditor ? "CMD" : "CTRL") + ": add a waypoint\n➲ SHIFT + ALT: remove a waypoint", new GUILayoutOption[0]); DeGUILayout.EndVBox(); AnimationInspectorGUI.StickyTitle("Info"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.Label("Path Length: " + ((this._src.path == null) ? "-" : this._src.path.length.ToString()), new GUILayoutOption[0]); DeGUILayout.EndVBox(); if (this._showTweenSettings) { AnimationInspectorGUI.StickyTitle("Tween Options"); GUILayout.BeginHorizontal(new GUILayoutOption[0]); this._src.autoPlay = DeGUILayout.ToggleButton(this._src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically"), DeGUI.styles.button.tool, new GUILayoutOption[0]); this._src.autoKill = DeGUILayout.ToggleButton(this._src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable"), DeGUI.styles.button.tool, new GUILayoutOption[0]); GUILayout.EndHorizontal(); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.BeginHorizontal(new GUILayoutOption[0]); this._src.duration = EditorGUILayout.FloatField("Duration", this._src.duration, new GUILayoutOption[0]); if (this._src.duration < 0f) { this._src.duration = 0f; } this._src.isSpeedBased = DeGUILayout.ToggleButton(this._src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, new GUILayoutOption[] { GUILayout.Width(75f) }); GUILayout.EndHorizontal(); this._src.delay = EditorGUILayout.FloatField("Delay", this._src.delay, new GUILayoutOption[0]); if (this._src.delay < 0f) { this._src.delay = 0f; } this._src.easeType = EditorGUIUtils.FilteredEasePopup(this._src.easeType); if (this._src.easeType == Ease.INTERNAL_Custom) { this._src.easeCurve = EditorGUILayout.CurveField(" Ease Curve", this._src.easeCurve, new GUILayoutOption[0]); } this._src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), this._src.loops, new GUILayoutOption[0]); if (this._src.loops < -1) { this._src.loops = -1; } if (this._src.loops > 1 || this._src.loops == -1) { this._src.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", this._src.loopType, new GUILayoutOption[0]); } this._src.id = EditorGUILayout.TextField("ID", this._src.id, new GUILayoutOption[0]); this._src.updateType = (UpdateType)EditorGUILayout.EnumPopup("Update Type", this._src.updateType, new GUILayoutOption[0]); if (this._src.inspectorMode == DOTweenInspectorMode.Developer) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); Rigidbody component = this._src.GetComponent <Rigidbody>(); this._src.tweenRigidbody = EditorGUILayout.Toggle("Tween Rigidbody", component != null && this._src.tweenRigidbody, new GUILayoutOption[0]); if (component == null) { GUILayout.Label("No rigidbody found", ABSAnimationInspector.styles.custom.warningLabel, new GUILayoutOption[0]); } GUILayout.EndHorizontal(); if (this._src.tweenRigidbody) { EditorGUILayout.HelpBox("Tweening a rigidbody works correctly only when it's kinematic", MessageType.Warning); } } DeGUILayout.EndVBox(); AnimationInspectorGUI.StickyTitle("Path Tween Options"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); PathType pathType = this._src.pathType; this._src.pathType = (PathType)EditorGUILayout.EnumPopup("Path Type", this._src.pathType, new GUILayoutOption[0]); if (pathType != this._src.pathType) { flag = true; } if (this._src.pathType != PathType.Linear) { this._src.pathResolution = EditorGUILayout.IntSlider(" Path resolution", this._src.pathResolution, 2, 20, new GUILayoutOption[0]); } bool isClosedPath = this._src.isClosedPath; this._src.isClosedPath = EditorGUILayout.Toggle("Close Path", this._src.isClosedPath, new GUILayoutOption[0]); if (isClosedPath != this._src.isClosedPath) { flag = true; } this._src.isLocal = EditorGUILayout.Toggle(new GUIContent("Local Movement", "If checked, the path will tween the localPosition (instead than the position) of its target"), this._src.isLocal, new GUILayoutOption[0]); this._src.pathMode = (PathMode)EditorGUILayout.EnumPopup("Path Mode", this._src.pathMode, new GUILayoutOption[0]); this._src.lockRotation = (AxisConstraint)EditorGUILayout.EnumPopup("Lock Rotation", this._src.lockRotation, new GUILayoutOption[0]); this._src.orientType = (OrientType)EditorGUILayout.EnumPopup("Orientation", this._src.orientType, new GUILayoutOption[0]); if (this._src.orientType != OrientType.None) { switch (this._src.orientType) { case OrientType.ToPath: this._src.lookAhead = EditorGUILayout.Slider(" LookAhead", this._src.lookAhead, 0f, 1f, new GUILayoutOption[0]); break; case OrientType.LookAtTransform: this._src.lookAtTransform = (EditorGUILayout.ObjectField(" LookAt Target", this._src.lookAtTransform, typeof(Transform), true, new GUILayoutOption[0]) as Transform); break; case OrientType.LookAtPosition: this._src.lookAtPosition = EditorGUILayout.Vector3Field(" LookAt Position", this._src.lookAtPosition, new GUILayoutOption[0]); break; } } DeGUILayout.EndVBox(); } AnimationInspectorGUI.StickyTitle("Path Editor Options"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); this._src.relative = EditorGUILayout.Toggle(new GUIContent("Relative", "If toggled, the whole path moves with the target"), this._src.relative, new GUILayoutOption[0]); this._src.pathColor = EditorGUILayout.ColorField("Color", this._src.pathColor, new GUILayoutOption[0]); this._src.showIndexes = EditorGUILayout.Toggle("Show Indexes", this._src.showIndexes, new GUILayoutOption[0]); this._src.showWpLength = EditorGUILayout.Toggle("Show WPs Lengths", this._src.showWpLength, new GUILayoutOption[0]); this._src.livePreview = EditorGUILayout.Toggle("Live Preview", this._src.livePreview, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Handles Type/Mode", new GUILayoutOption[] { GUILayout.Width(EditorGUIUtility.labelWidth - 11f) }); this._src.handlesType = (HandlesType)EditorGUILayout.EnumPopup(this._src.handlesType, new GUILayoutOption[0]); this._src.handlesDrawMode = (HandlesDrawMode)EditorGUILayout.EnumPopup(this._src.handlesDrawMode, new GUILayoutOption[0]); GUILayout.EndHorizontal(); if (this._src.handlesDrawMode == HandlesDrawMode.Perspective) { this._src.perspectiveHandleSize = EditorGUILayout.FloatField(" Handle Size", this._src.perspectiveHandleSize, new GUILayoutOption[0]); } DeGUILayout.EndVBox(); if (this._showTweenSettings) { AnimationInspectorGUI.AnimationEvents(this, this._src); } this.DrawExtras(); GUILayout.Space(10f); DeGUILayout.BeginToolbar(new GUILayoutOption[0]); this._src.wpsDropdown = DeGUILayout.ToolbarFoldoutButton(this._src.wpsDropdown, "Waypoints", false, false); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Copy to clipboard", "Copies the current waypoints to clipboard, as an array ready to be pasted in your code"), DeGUI.styles.button.tool, new GUILayoutOption[0])) { this.CopyWaypointsToClipboard(); } DeGUILayout.EndToolbar(); if (this._src.wpsDropdown) { DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); bool arg_ABE_0 = GUI.changed; this._wpsList.DoLayoutList(); if (!arg_ABE_0 && GUI.changed) { flag = true; } DeGUILayout.EndVBox(); } else { GUILayout.Space(5f); } if (flag) { this.RefreshPath(RepaintMode.Scene, false); return; } if (GUI.changed) { EditorUtility.SetDirty(this._src); this.DORepaint(RepaintMode.Scene, false); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); #region 私有 GUILayout.Space(3); EditorGUIUtils.SetGUIStyles(); bool playMode = Application.isPlaying; _runtimeEditMode = _runtimeEditMode && playMode; GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); DrawLablelOnClick(); // Up-down buttons GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_src); } if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_src); } GUILayout.EndHorizontal(); if (playMode) { if (!_runtimeEditMode) { GUILayout.Space(8); Label("在播放模式下禁用动画编辑器", "Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); if (!_src.isActive) { Label("此动画已切换为非活动状态,不会生成", "This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle); GUI.enabled = false; } if (GUILayout.Button(NewGUIContent("激活编辑模式", "切换到运行时编辑模式,您可以在其中更改动画值并重新启动它们", "Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them"))) { _runtimeEditMode = true; } Label("注意:使用DOPlayNext时,序列由目标 GameObject 的 Inspector 中的 DOTweenAnimation Components 顺序决定", "NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); if (null != _src.btns && _src.btns.Length > 0) { GUILayout.Label("关闭的按钮:"); foreach (var btn in _src.btns) { GUILayout.Label(btn.name); } } GUILayout.Space(10); if (!_runtimeEditMode) { return; } } } Undo.RecordObject(_src, "DOTween Animation"); EditorGUIUtility.labelWidth = 120; if (playMode) { GUILayout.Space(4); DeGUILayout.Toolbar("Edit Mode Commands"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.BeginHorizontal(); if (GUILayout.Button("TogglePause")) { _src.tween.TogglePause(); } if (GUILayout.Button("Rewind")) { _src.tween.Rewind(); } if (GUILayout.Button("Restart")) { _src.tween.Restart(); } GUILayout.EndHorizontal(); if (GUILayout.Button("Commit changes and restart")) { _src.tween.Rewind(); _src.tween.Kill(); if (_src.isValid) { _src.CreateTween(); _src.tween.Play(); } } Label("要在退出播放模式时应用更改,请使用组件的右上方菜单并选择“复制组件”,然后在退出播放模式后选择“粘贴组件值”", "To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap); DeGUILayout.EndVBox(); } GUILayout.BeginHorizontal(); DOTweenAnimationType prevAnimType = _src.animationType; _src.isActive = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(16)); GUI.enabled = _src.isActive; _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]); _src.autoPlay = DeGUILayout.ToggleButton(_src.autoPlay, NewGUIContent("AutoPlay", "如果选中,则 tween 会自动播放", "AutoPlay", "If selected, the tween will play automatically")); _src.autoKill = DeGUILayout.ToggleButton(_src.autoKill, NewGUIContent("AutoKill", "如果选中,则 tween 将在完成时被终止,并且不可重用", "AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable")); GUILayout.EndHorizontal(); if (prevAnimType != _src.animationType) { // Set default optional values based on animation type switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: case DOTweenAnimationType.Scale: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = _src.animationType == DOTweenAnimationType.Scale; break; case DOTweenAnimationType.Color: case DOTweenAnimationType.Fade: _src.endValueFloat = 0; break; case DOTweenAnimationType.Text: _src.optionalBool0 = true; break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one; _src.optionalFloat0 = 1; _src.optionalInt0 = 10; _src.optionalBool0 = false; break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one; _src.optionalInt0 = 10; _src.optionalFloat0 = 90; _src.optionalBool0 = false; break; case DOTweenAnimationType.CameraAspect: case DOTweenAnimationType.CameraFieldOfView: case DOTweenAnimationType.CameraOrthoSize: _src.endValueFloat = 0; break; case DOTweenAnimationType.CameraPixelRect: case DOTweenAnimationType.CameraRect: _src.endValueRect = new Rect(0, 0, 0, 0); break; } } if (_src.animationType == DOTweenAnimationType.None) { _src.isValid = false; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } if (prevAnimType != _src.animationType || ComponentsChanged()) { _src.isValid = Validate(); } if (!_src.isValid) { GUI.color = Color.red; GUILayout.BeginVertical(GUI.skin.box); Label("找不到所选动画的有效组件", "No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle); GUILayout.EndVertical(); GUI.color = Color.white; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } #endregion _src.duration = FloatField("持续时间", "Duration", _src.duration); if (_src.duration < 0) { _src.duration = 0; } _src.delay = FloatField("延迟", "Delay", _src.delay); if (_src.delay < 0) { _src.delay = 0; } _src.isIndependentUpdate = Toggle("是否忽略 TimeScale", "Ignore TimeScale", _src.isIndependentUpdate); _src.easeType = EditorGUIUtils.FilteredEasePopup(_src.easeType); if (_src.easeType == Ease.INTERNAL_Custom) { _src.easeCurve = CurveField(" 缓和曲线", " Ease Curve", _src.easeCurve); } _src.loops = EditorGUILayout.IntField(NewGUIContent("循环", "无限循环设置为 -1", "Loops", "Set to -1 for infinite loops"), _src.loops); if (_src.loops < -1) { _src.loops = -1; } if (_src.loops > 1 || _src.loops == -1) { _src.loopType = (LoopType)EnumPopup(" 循环模式", " Loop Type", LoopTypeStrs, _src.loopType); } _src.id = EditorGUILayout.TextField("ID", _src.id); bool canBeRelative = true; // End value and eventual specific options switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: GUIEndValueV3(); DrawSnapping(); break; case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: if (_src.GetComponent <Rigidbody2D>()) { GUIEndValueFloat(); } else { GUIEndValueV3(); _src.optionalRotationMode = (RotateMode)EnumPopup(" 旋转模式", " Rotation Mode", RotationModeStrs, _src.optionalRotationMode); } break; case DOTweenAnimationType.Scale: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV3(); } _src.optionalBool0 = ToggleLeft(" ture:统一规模缩放,即只用 float 而非 Vector3", "Uniform Scale", _src.optionalBool0); break; case DOTweenAnimationType.Color: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimationType.Fade: GUIEndValueFloat(); if (_src.endValueFloat < 0) { _src.endValueFloat = 0; } if (_src.endValueFloat > 1) { _src.endValueFloat = 1; } canBeRelative = false; break; case DOTweenAnimationType.Text: GUIEndValueString(); _src.optionalBool0 = ToggleLeft(" 是否启用富文本", "Rich Text Enabled", _src.optionalBool0); _src.optionalScrambleMode = (ScrambleMode)EnumPopup("争夺模式", "Scramble Mode", ScrambleStrs, _src.optionalScrambleMode); _src.optionalString = EditorGUILayout.TextField(NewGUIContent("自定义争夺", "争夺模式中使用的自定义字符", "Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString); break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(NewGUIContent(" 振动", "冲头会振动多少", " Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(NewGUIContent(" 弹性", "当向后弹跳时,向量将超出起始位置", " Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1); if (_src.animationType == DOTweenAnimationType.PunchPosition) { DrawSnapping(); } break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(NewGUIContent(" 振动", "冲头会振动多少", " Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(NewGUIContent(" 随机性", "摇晃随机性", " Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90); if (_src.animationType == DOTweenAnimationType.ShakePosition) { DrawSnapping(); } break; case DOTweenAnimationType.CameraAspect: case DOTweenAnimationType.CameraFieldOfView: case DOTweenAnimationType.CameraOrthoSize: GUIEndValueFloat(); canBeRelative = false; break; case DOTweenAnimationType.CameraBackgroundColor: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimationType.CameraPixelRect: case DOTweenAnimationType.CameraRect: GUIEndValueRect(); canBeRelative = false; break; } // Final settings if (canBeRelative) { DrawRelative(); } _src.isUseDTContrl = ToggleLeft(" true:使用 DTExpansion_Contrl 统一控制", " isUseDTContrl", _src.isUseDTContrl); DrawToggleIsCloseBtn(); DrawTip(); DrawDesTip(); // Events AnimationInspectorGUI.AnimationEvents(this, _src); if (GUI.changed) { EditorUtility.SetDirty(_src); } }
public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label("IMAGE BLEND", EditorGUIUtils.sideLogoIconBoldLabelStyle); // Up-down buttons GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_blender); } if (GUILayout.Button("▼", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_blender); } GUILayout.EndHorizontal(); if (Application.isPlaying) { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(4); GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); return; } EditorGUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _blender.blendMode = (ImageBlend.BlendMode)EditorGUILayout.EnumPopup(" Blend Mode", _blender.blendMode); if (EditorGUI.EndChangeCheck()) { _blender.ChangeBlendMode(); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); _blender.Mask = (Texture2D)EditorGUILayout.ObjectField(_blender.Mask, typeof(Texture2D), false, GUILayout.Width(180), GUILayout.Height(180)); if (EditorGUI.EndChangeCheck()) { _blender.ChangeTexture(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _blender.ScrollX = EditorGUILayout.FloatField(" Start Scroll X", _blender.ScrollX); _blender.ScrollY = EditorGUILayout.FloatField(" Start Scroll Y", _blender.ScrollY); _blender.ScrollAlpha = EditorGUILayout.FloatField(" Start Scroll Alpha", _blender.ScrollAlpha); _blender._ScaleX = EditorGUILayout.FloatField(" Scale X", _blender._ScaleX); _blender._ScaleY = EditorGUILayout.FloatField(" Sclae Y", _blender._ScaleY); _blender._AddColorR = EditorGUILayout.FloatField(" +Color R", _blender._AddColorR); _blender._AddColorG = EditorGUILayout.FloatField(" +Color G", _blender._AddColorG); _blender._AddColorB = EditorGUILayout.FloatField(" +Color B", _blender._AddColorB); if (EditorGUI.EndChangeCheck()) { _blender.ChangeScroll(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); _blender.XeaseType = EditorGUIUtils.FilteredEasePopup(_blender.XeaseType); if (_blender.XeaseType == Ease.INTERNAL_Custom) { _blender.ScrollXCurve = EditorGUILayout.CurveField(" Scroll X Curve", _blender.ScrollXCurve); } _blender.YeaseType = EditorGUIUtils.FilteredEasePopup(_blender.YeaseType); if (_blender.YeaseType == Ease.INTERNAL_Custom) { _blender.ScrollYCurve = EditorGUILayout.CurveField(" Scroll Y Curve", _blender.ScrollYCurve); } _blender.duration = EditorGUILayout.FloatField("Duration", _blender.duration); if (_blender.duration < 0) { _blender.duration = 0; } _blender.delay = EditorGUILayout.FloatField("Delay", _blender.delay); if (_blender.delay < 0) { _blender.delay = 0; } _blender.loopsX = EditorGUILayout.IntField(new GUIContent("Loops X", "Set to -1 for infinite loops"), _blender.loopsX); if (_blender.loopsX < -1) { _blender.loopsX = -1; } if (_blender.loopsX > 1 || _blender.loopsX == -1) { _blender.loopTypeX = (LoopType)EditorGUILayout.EnumPopup(" Loop Type X", _blender.loopTypeX); } _blender.loopsY = EditorGUILayout.IntField(new GUIContent("Loops Y", "Set to -1 for infinite loops"), _blender.loopsY); if (_blender.loopsY < -1) { _blender.loopsY = -1; } if (_blender.loopsY > 1 || _blender.loopsY == -1) { _blender.loopTypeY = (LoopType)EditorGUILayout.EnumPopup(" Loop Type Y", _blender.loopTypeY); } GUIEndValue(); EditorGUILayout.EndVertical(); #region Mask Coclor Blend EditorGUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _blender.maskBlendMode = (ImageBlend.MaskBlendMode)EditorGUILayout.EnumPopup("Mask Blend Mode", _blender.maskBlendMode); if (EditorGUI.EndChangeCheck()) { _blender.ChangeBlendMode(); } if (_blender.maskBlendMode == ImageBlend.MaskBlendMode.Alpha) { _blender.AlphaEaseType = EditorGUIUtils.FilteredEasePopup(_blender.AlphaEaseType); if (_blender.AlphaEaseType == Ease.INTERNAL_Custom) { _blender.ScrollAlphaCurve = EditorGUILayout.CurveField(" Scroll Alpha Curve", _blender.ScrollAlphaCurve); } GUILayout.BeginHorizontal(); _blender.endAlphaValue = EditorGUILayout.FloatField(" End Scroll Alpha Value", _blender.endAlphaValue); GUILayout.EndHorizontal(); } _blender.loopsAlpha = EditorGUILayout.IntField(new GUIContent("Loops Alpha Type", "Set to -1 for infinite loops"), _blender.loopsAlpha); if (_blender.loopsAlpha < -1) { _blender.loopsAlpha = -1; } if (_blender.loopsAlpha > 1 || _blender.loopsAlpha == -1) { _blender.loopTypeAlpha = (LoopType)EditorGUILayout.EnumPopup(" Loop Type Alpha", _blender.loopTypeAlpha); } EditorGUILayout.EndVertical(); #endregion }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label("控制 CanvasGroup 的 Alpha"); GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(mFade); } if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(mFade); } GUILayout.EndHorizontal(); mFade.Duration = EditorGUILayout.FloatField("持续时间", mFade.Duration); if (mFade.Duration < 0) { mFade.Duration = 0.1f; } GUILayout.Space(5); // mFade.Dalay = EditorGUILayout.FloatField("延迟", mFade.Dalay); // if (mFade.Dalay < 0) // { // mFade.Dalay = 0; // } GUILayout.BeginHorizontal(); if (GUILayout.Button(mFade.IsFrom ? "FROM" : "TO", EditorGUIUtils.sideBtStyle, GUILayout.Width(100))) { mFade.IsFrom = !mFade.IsFrom; } GUILayout.Space(22); mFade.EndValue = EditorGUILayout.Slider(mFade.EndValue, 0, 1); GUILayout.EndHorizontal(); GUILayout.Space(5); string middleStr = mFade.IsFrom ? " From <- " : " TO -> "; string valueStr = mFade.GetCurrentAlpha + middleStr + mFade.EndValue; GUILayout.BeginHorizontal(); GUILayout.Label("Alpha", EditorGUIUtils.handlelabelStyle, GUILayout.Width(80)); GUILayout.Label(valueStr, EditorGUIUtils.handleSelectedLabelStyle); GUILayout.EndHorizontal(); if (GUI.changed) { EditorUtility.SetDirty(mFade); } }
override public void OnInspectorGUI() { base.OnInspectorGUI(); GUILayout.Space(3); EditorGUIUtils.SetGUIStyles(); bool playMode = Application.isPlaying; _runtimeEditMode = _runtimeEditMode && playMode; GUILayout.BeginHorizontal(); // EditorGUIUtils.InspectorLogo(); GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle); // Up-down buttons GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_src); } if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_src); } GUILayout.EndHorizontal(); if (playMode) { if (_runtimeEditMode) { } else { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); if (!_src.isActive) { GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle); GUI.enabled = false; } if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them"))) { _runtimeEditMode = true; } GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); if (!_runtimeEditMode) { return; } } } Undo.RecordObject(_src, "DOTween Animation"); // _src.isValid = Validate(); // Moved down EditorGUIUtility.labelWidth = 110; if (playMode) { GUILayout.Space(4); DeGUILayout.Toolbar("Edit Mode Commands"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.BeginHorizontal(); if (GUILayout.Button("TogglePause")) { _src.tween.TogglePause(); } if (GUILayout.Button("Rewind")) { _src.tween.Rewind(); } if (GUILayout.Button("Restart")) { _src.tween.Restart(); } GUILayout.EndHorizontal(); if (GUILayout.Button("Commit changes and restart")) { _src.tween.Rewind(); _src.tween.Kill(); if (_src.isValid) { _src.CreateTween(); _src.tween.Play(); } } GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap); DeGUILayout.EndVBox(); } else { /* * bool hasManager = _src.GetComponent<DOTweenVisualManager>() != null; * if (!hasManager) * { * if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"))) * { * _src.gameObject.AddComponent<DOTweenVisualManager>(); * } * } */ } //This is quite hacky. Every event is a DOTweenAnimation, but things like ActivationEvents simple don't show that. GUILayout.BeginHorizontal(); DOTweenAnimationType prevAnimType = _src.animationType; // _src.animationType = (DOTweenAnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton); _src.isActive = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(16)); GUI.enabled = _src.isActive; _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]); _src.autoPlay = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically")); _src.autoKill = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable")); GUILayout.EndHorizontal(); if (prevAnimType != _src.animationType) { // Set default optional values based on animation type _src.endValueTransform = null; _src.useTargetAsV3 = false; switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: case DOTweenAnimationType.Scale: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = _src.animationType == DOTweenAnimationType.Scale; break; case DOTweenAnimationType.UIWidthHeight: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = _src.animationType == DOTweenAnimationType.UIWidthHeight; break; case DOTweenAnimationType.Color: case DOTweenAnimationType.Fade: _isLightSrc = _src.GetComponent <Light>() != null; _src.endValueFloat = 0; break; case DOTweenAnimationType.Text: _src.optionalBool0 = true; break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one; _src.optionalFloat0 = 1; _src.optionalInt0 = 10; _src.optionalBool0 = false; break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one; _src.optionalInt0 = 10; _src.optionalFloat0 = 90; _src.optionalBool0 = false; break; case DOTweenAnimationType.CameraAspect: case DOTweenAnimationType.CameraFieldOfView: case DOTweenAnimationType.CameraOrthoSize: _src.endValueFloat = 0; break; case DOTweenAnimationType.CameraPixelRect: case DOTweenAnimationType.CameraRect: _src.endValueRect = new Rect(0, 0, 0, 0); break; } } if (_src.animationType == DOTweenAnimationType.None) { _src.isValid = false; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } if (prevAnimType != _src.animationType || ComponentsChanged()) { _src.isValid = Validate(); // See if we need to choose between multiple targets if (_src.animationType == DOTweenAnimationType.Fade && _src.GetComponent <CanvasGroup>() != null && _src.GetComponent <Image>() != null) { _chooseTargetMode = ChooseTargetMode.BetweenCanvasGroupAndImage; // Reassign target and forcedTargetType if lost if (_src.forcedTargetType == TargetType.Unset) { _src.forcedTargetType = _src.targetType; } switch (_src.forcedTargetType) { case TargetType.CanvasGroup: _src.target = _src.GetComponent <CanvasGroup>(); break; case TargetType.Image: _src.target = _src.GetComponent <Image>(); break; } } else { _chooseTargetMode = ChooseTargetMode.None; _src.forcedTargetType = TargetType.Unset; } } if (!_src.isValid) { GUI.color = Color.red; GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle); GUILayout.EndVertical(); GUI.color = Color.white; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } // Special cases in which multiple target types could be used (set after validation) if (_chooseTargetMode == ChooseTargetMode.BetweenCanvasGroupAndImage && _src.forcedTargetType != TargetType.Unset) { FadeTargetType fadeTargetType = (FadeTargetType)Enum.Parse(typeof(FadeTargetType), _src.forcedTargetType.ToString()); TargetType prevTargetType = _src.forcedTargetType; _src.forcedTargetType = (TargetType)Enum.Parse(typeof(TargetType), EditorGUILayout.EnumPopup(_src.animationType + " Target", fadeTargetType).ToString()); if (_src.forcedTargetType != prevTargetType) { // Target type change > assign correct target switch (_src.forcedTargetType) { case TargetType.CanvasGroup: _src.target = _src.GetComponent <CanvasGroup>(); break; case TargetType.Image: _src.target = _src.GetComponent <Image>(); break; } } } GUILayout.BeginHorizontal(); _src.duration = EditorGUILayout.FloatField("Duration", _src.duration); if (_src.duration < 0) { _src.duration = 0; } _src.isSpeedBased = DeGUILayout.ToggleButton(_src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, GUILayout.Width(75)); GUILayout.EndHorizontal(); _src.delay = EditorGUILayout.FloatField("Delay", _src.delay); if (_src.delay < 0) { _src.delay = 0; } _src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate); _src.easeType = EditorGUIUtils.FilteredEasePopup(_src.easeType); if (_src.easeType == Ease.INTERNAL_Custom) { _src.easeCurve = EditorGUILayout.CurveField(" Ease Curve", _src.easeCurve); } _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops); if (_src.loops < -1) { _src.loops = -1; } if (_src.loops > 1 || _src.loops == -1) { _src.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _src.loopType); } _src.id = EditorGUILayout.TextField("ID", _src.id); bool canBeRelative = true; // End value and eventual specific options switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: GUIEndValueV3(_src.animationType == DOTweenAnimationType.Move); _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); canBeRelative = !_src.useTargetAsV3; break; case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: if (_src.GetComponent <Rigidbody2D>()) { GUIEndValueFloat(); } else { GUIEndValueV3(); _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup(" Rotation Mode", _src.optionalRotationMode); } break; case DOTweenAnimationType.Scale: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV3(); } _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0); break; case DOTweenAnimationType.UIWidthHeight: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV2(); } _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0); break; case DOTweenAnimationType.Color: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimationType.Fade: GUIEndValueFloat(); if (_src.endValueFloat < 0) { _src.endValueFloat = 0; } if (!_isLightSrc && _src.endValueFloat > 1) { _src.endValueFloat = 1; } canBeRelative = false; break; case DOTweenAnimationType.Text: GUIEndValueString(); _src.optionalBool0 = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0); _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode); _src.optionalString = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString); break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1); if (_src.animationType == DOTweenAnimationType.PunchPosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90); if (_src.animationType == DOTweenAnimationType.ShakePosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; case DOTweenAnimationType.CameraAspect: case DOTweenAnimationType.CameraFieldOfView: case DOTweenAnimationType.CameraOrthoSize: GUIEndValueFloat(); canBeRelative = false; break; case DOTweenAnimationType.CameraBackgroundColor: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimationType.CameraPixelRect: case DOTweenAnimationType.CameraRect: GUIEndValueRect(); canBeRelative = false; break; } // Final settings if (canBeRelative) { _src.isRelative = EditorGUILayout.Toggle(" Relative", _src.isRelative); } // Events AnimationInspectorGUI.AnimationEvents(this, _src); if (GUI.changed) { EditorUtility.SetDirty(_src); } }
public override void OnInspectorGUI() { EditorGUIUtils.SetGUIStyles(); GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label("IMAGE CLIPPING", EditorGUIUtils.sideLogoIconBoldLabelStyle); GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_clipping); } if (GUILayout.Button("▼", EditorGUIUtils.btIconStyle)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_clipping); } GUILayout.EndHorizontal(); if (Application.isPlaying) { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(4); GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); return; } GUILayout.BeginVertical("Box"); EditorGUI.BeginChangeCheck(); _clipping._ClipLeft = EditorGUILayout.Slider("Start Clip Left", _clipping._ClipLeft, 0, 1); _clipping._ClipRight = EditorGUILayout.Slider("Start Clip Right", _clipping._ClipRight, 0, 1); _clipping._ClipUp = EditorGUILayout.Slider("Start Clip Up", _clipping._ClipUp, 0, 1); _clipping._ClipDown = EditorGUILayout.Slider("Start Clip Down", _clipping._ClipDown, 0, 1); if (EditorGUI.EndChangeCheck()) { _clipping.ChangeValue(); } GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); _clipping.ClipRightEaseType = EditorGUIUtils.FilteredEasePopup(_clipping.ClipRightEaseType); if (_clipping.ClipRightEaseType == Ease.INTERNAL_Custom) { _clipping.ClipRightCurve = EditorGUILayout.CurveField(" Right Clipping Curve", _clipping.ClipRightCurve); } _clipping.ClipRightDuration = EditorGUILayout.FloatField(" Right Clipping Duration", _clipping.ClipRightDuration); if (_clipping.ClipRightDuration < 0) { _clipping.ClipRightDuration = 0; } _clipping.ClipRightDelay = EditorGUILayout.FloatField(" Right Clipping Delay", _clipping.ClipRightDelay); if (_clipping.ClipRightDelay < 0) { _clipping.ClipRightDelay = 0; } _clipping.ClipRightLoop = EditorGUILayout.IntField(new GUIContent("Loop", "Set to -1 for infinite loops"), _clipping.ClipRightLoop); if (_clipping.ClipRightLoop < -1) { _clipping.ClipRightLoop = -1; } if (_clipping.ClipRightLoop > 1 || _clipping.ClipRightLoop == -1) { _clipping.ClipRightLoopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _clipping.ClipRightLoopType); } _clipping.ClipLeftEaseType = EditorGUIUtils.FilteredEasePopup(_clipping.ClipLeftEaseType); if (_clipping.ClipLeftEaseType == Ease.INTERNAL_Custom) { _clipping.ClipLeftCurve = EditorGUILayout.CurveField(" Left Clipping Curve", _clipping.ClipLeftCurve); } _clipping.ClipLeftDuration = EditorGUILayout.FloatField(" Left Clipping Duration", _clipping.ClipLeftDuration); if (_clipping.ClipLeftDuration < 0) { _clipping.ClipLeftDuration = 0; } _clipping.ClipLeftDelay = EditorGUILayout.FloatField(" Left Clipping Delay", _clipping.ClipLeftDelay); if (_clipping.ClipLeftDelay < 0) { _clipping.ClipLeftDelay = 0; } _clipping.ClipLeftLoop = EditorGUILayout.IntField(new GUIContent("Loop", "Set to -1 for infinite loops"), _clipping.ClipLeftLoop); if (_clipping.ClipLeftLoop < -1) { _clipping.ClipLeftLoop = -1; } if (_clipping.ClipLeftLoop > 1 || _clipping.ClipLeftLoop == -1) { _clipping.ClipLeftLoopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _clipping.ClipLeftLoopType); } EditorGUILayout.BeginVertical("Box"); GUIEndValue(); EditorGUILayout.EndVertical(); GUILayout.EndVertical(); }