Skip to content

Commit 2c590c5

Browse files
committed
Organize code formatting and naming
1 parent 43c464a commit 2c590c5

12 files changed

+70
-58
lines changed

Editor/Scripts/Node/AnimationClipPlayableNode.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using GBG.PlayableGraphMonitor.Editor.GraphView;
22
using GBG.PlayableGraphMonitor.Editor.Utility;
3-
using System.Text;
43
using UnityEditor;
54
using UnityEditor.UIElements;
65
using UnityEngine;
@@ -58,7 +57,9 @@ protected override void OnUpdate(PlayableGraphViewUpdateContext updateContext, b
5857
{
5958
_progressBar.style.display = DisplayStyle.Flex;
6059

61-
var rawProgress01 = 0.0;
60+
// ReSharper disable once TooWideLocalVariableScope
61+
// ReSharper disable once RedundantAssignment
62+
var rawProgress01 = 0.0; // used in UNITY_2021_1_OR_NEWER
6263
double progress01;
6364
if (clip)
6465
{
@@ -110,13 +111,13 @@ protected override void OnUpdate(PlayableGraphViewUpdateContext updateContext, b
110111
// public override void Release()
111112
// {
112113
// base.Release();
113-
// // Change the value of the ObjectField is expensive, so we dont clear referenced clip asset to save performance
114+
// // Change the value of the ObjectField is expensive, so we don't clear referenced clip asset to save performance
114115
// // _clipField.SetValueWithoutNotify(null);
115116
// }
116117

117-
protected override void AppendNodeDescription()
118+
protected override void DrawNodeDescriptionInternal()
118119
{
119-
base.AppendNodeDescription();
120+
base.DrawNodeDescriptionInternal();
120121

121122
if (!Playable.IsValid())
122123
{
@@ -172,7 +173,7 @@ protected override void AppendNodeDescription()
172173
{
173174
var evt = events[i];
174175
var evtPosition = evt.time / clip.length * 100;
175-
GUILayout.Label($" #{(i + 1)} {evtPosition.ToString("F2")}% {evt.functionName}");
176+
GUILayout.Label($" #{(i + 1)} {evtPosition:F2}% {evt.functionName}");
176177
}
177178
}
178179
}

Editor/Scripts/Node/AnimationLayerMixerPlayableNode.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Text;
2-
using UnityEditor;
1+
using UnityEditor;
32
using UnityEngine.Animations;
43
using UnityEngine.Playables;
54

@@ -15,10 +14,12 @@ protected override void AppendInputPortDescription()
1514
{
1615
EditorGUI.BeginChangeCheck();
1716
var weight = EditorGUILayout.Slider($" #{i} Weight:", Playable.GetInputWeight(i), 0, 1);
18-
if (EditorGUI.EndChangeCheck()) Playable.SetInputWeight(i, weight);
17+
if (EditorGUI.EndChangeCheck())
18+
Playable.SetInputWeight(i, weight);
1919
EditorGUI.BeginChangeCheck();
2020
var isLayerAdditive = EditorGUILayout.Toggle($" #{i} Additive:", layerMixer.IsLayerAdditive((uint)i));
21-
if (EditorGUI.EndChangeCheck()) layerMixer.SetLayerAdditive((uint) i, isLayerAdditive);
21+
if (EditorGUI.EndChangeCheck())
22+
layerMixer.SetLayerAdditive((uint)i, isLayerAdditive);
2223
}
2324
}
2425
}

Editor/Scripts/Node/AnimationPlayableOutputNode.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Text;
2-
using UnityEditor;
1+
using UnityEditor;
32
using UnityEditor.UIElements;
43
using UnityEngine;
54
using UnityEngine.Animations;
@@ -45,9 +44,9 @@ protected override void OnUpdate(bool playableOutputChanged)
4544
_targetField.SetValueWithoutNotify(target);
4645
}
4746

48-
protected override void AppendNodeDescription()
47+
protected override void DrawNodeDescriptionInternal()
4948
{
50-
base.AppendNodeDescription();
49+
base.DrawNodeDescriptionInternal();
5150

5251
if (!PlayableOutput.IsOutputValid())
5352
{
@@ -59,11 +58,13 @@ protected override void AppendNodeDescription()
5958
GUILayout.Label(LINE);
6059
EditorGUILayout.ObjectField("Target:", target, typeof(Animator), true);
6160
EditorGUI.BeginChangeCheck();
62-
var animationStreamSource = (AnimationStreamSource) EditorGUILayout.EnumPopup("AnimationStreamSource:", animationPlayableOutput.GetAnimationStreamSource());
63-
if (EditorGUI.EndChangeCheck()) animationPlayableOutput.SetAnimationStreamSource(animationStreamSource);
61+
var animationStreamSource = (AnimationStreamSource)EditorGUILayout.EnumPopup("AnimationStreamSource:", animationPlayableOutput.GetAnimationStreamSource());
62+
if (EditorGUI.EndChangeCheck())
63+
animationPlayableOutput.SetAnimationStreamSource(animationStreamSource);
6464
EditorGUI.BeginChangeCheck();
65-
var sortingOrder = (ushort) EditorGUILayout.IntField("SortingOrder:", animationPlayableOutput.GetSortingOrder());
66-
if (EditorGUI.EndChangeCheck()) animationPlayableOutput.SetSortingOrder(sortingOrder);
65+
var sortingOrder = (ushort)EditorGUILayout.IntField("SortingOrder:", animationPlayableOutput.GetSortingOrder());
66+
if (EditorGUI.EndChangeCheck())
67+
animationPlayableOutput.SetSortingOrder(sortingOrder);
6768
}
6869
}
6970
}

Editor/Scripts/Node/AnimationScriptPlayableNode.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using GBG.PlayableGraphMonitor.Editor.GraphView;
22
using System;
33
using System.Reflection;
4-
using System.Text;
54
using UnityEngine;
65
using UnityEngine.Animations;
76
using UnityEngine.Playables;
@@ -59,9 +58,9 @@ protected override void AppendPlayableTypeDescription()
5958
GUILayout.Label($"Job: {jobType?.Name ?? "?"}");
6059
}
6160

62-
protected override void AppendNodeDescription()
61+
protected override void DrawNodeDescriptionInternal()
6362
{
64-
base.AppendNodeDescription();
63+
base.DrawNodeDescriptionInternal();
6564

6665
if (!Playable.IsValid())
6766
{

Editor/Scripts/Node/AudioClipPlayableNode.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using GBG.PlayableGraphMonitor.Editor.GraphView;
22
using GBG.PlayableGraphMonitor.Editor.Utility;
3-
using System.Text;
43
using UnityEditor;
54
using UnityEditor.UIElements;
65
using UnityEngine;
@@ -57,7 +56,9 @@ protected override void OnUpdate(PlayableGraphViewUpdateContext updateContext, b
5756
{
5857
_progressBar.style.display = DisplayStyle.Flex;
5958

60-
var rawProgress01 = 0.0;
59+
// ReSharper disable once TooWideLocalVariableScope
60+
// ReSharper disable once RedundantAssignment
61+
var rawProgress01 = 0.0; // used in UNITY_2021_1_OR_NEWER
6162
double progress01;
6263
if (clip)
6364
{
@@ -109,14 +110,14 @@ protected override void OnUpdate(PlayableGraphViewUpdateContext updateContext, b
109110
// public override void Release()
110111
// {
111112
// base.Release();
112-
// // Change the value of the ObjectField is expensive, so we dont clear referenced clip asset to save performance
113+
// // Change the value of the ObjectField is expensive, so we don't clear referenced clip asset to save performance
113114
// // _clipField.SetValueWithoutNotify(null);
114115
// }
115116

116117

117-
protected override void AppendNodeDescription()
118+
protected override void DrawNodeDescriptionInternal()
118119
{
119-
base.AppendNodeDescription();
120+
base.DrawNodeDescriptionInternal();
120121

121122
if (!Playable.IsValid())
122123
{
@@ -133,7 +134,7 @@ protected override void AppendNodeDescription()
133134
}
134135

135136
EditorGUILayout.ObjectField("Clip:", clip, typeof(AudioClip), true);
136-
GUILayout.Label($"Length: {clip.length.ToString("F3")}(s)");
137+
GUILayout.Label($"Length: {clip.length:F3}(s)");
137138
EditorGUILayout.Toggle("Looped:", clipPlayable.GetLooped());
138139
GUILayout.Label($"Channels: {clip.channels}");
139140
GUILayout.Label($"Ambisonic: {clip.ambisonic}");
@@ -142,7 +143,7 @@ protected override void AppendNodeDescription()
142143
GUILayout.Label($"LoadState: {clip.loadState}");
143144
GUILayout.Label($"LoadType: {clip.loadType}");
144145
GUILayout.Label($"LoadInBackground: {clip.loadInBackground}");
145-
GUILayout.Label($"PreloadAudioData: {clip.preloadAudioData}");;
146+
GUILayout.Label($"PreloadAudioData: {clip.preloadAudioData}");
146147
}
147148
}
148149
}

Editor/Scripts/Node/AudioPlayableOutputNode.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Text;
2-
using UnityEditor;
1+
using UnityEditor;
32
using UnityEditor.UIElements;
43
using UnityEngine;
54
using UnityEngine.Audio;
@@ -44,9 +43,9 @@ protected override void OnUpdate(bool playableOutputChanged)
4443
_targetField.SetValueWithoutNotify(target);
4544
}
4645

47-
protected override void AppendNodeDescription()
46+
protected override void DrawNodeDescriptionInternal()
4847
{
49-
base.AppendNodeDescription();
48+
base.DrawNodeDescriptionInternal();
5049

5150
if (!PlayableOutput.IsOutputValid())
5251
{

Editor/Scripts/Node/GraphViewNode.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
5050
protected const string LINE = "----------";
5151

5252

53-
public void GetNodeDescription()
53+
public void DrawNodeDescription()
5454
{
5555
var prevSize = EditorGUIUtility.labelWidth;
5656
EditorGUIUtility.labelWidth = 120;
57-
AppendNodeDescription();
57+
DrawNodeDescriptionInternal();
5858
EditorGUIUtility.labelWidth = prevSize;
5959
}
6060

6161

62-
protected abstract void AppendNodeDescription();
62+
protected abstract void DrawNodeDescriptionInternal();
6363

6464
#endregion
6565

Editor/Scripts/Node/PlayableNode.cs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using GBG.PlayableGraphMonitor.Editor.Utility;
33
using System;
44
using System.Collections.Generic;
5-
using System.Text;
65
using UnityEditor;
76
using UnityEditor.Experimental.GraphView;
87
using UnityEngine;
@@ -131,7 +130,7 @@ public string GetExtraNodeLabel(IReadOnlyDictionary<PlayableHandle, string> node
131130
}
132131

133132

134-
protected override void AppendNodeDescription()
133+
protected override void DrawNodeDescriptionInternal()
135134
{
136135
if (!Playable.IsValid())
137136
{
@@ -155,29 +154,40 @@ protected override void AppendNodeDescription()
155154
GUILayout.Label($"IsNull: {Playable.IsNull()}");
156155
EditorGUI.BeginChangeCheck();
157156
var done = EditorGUILayout.Toggle("IsDone:", Playable.IsDone());
158-
if (EditorGUI.EndChangeCheck()) Playable.SetDone(done);
157+
if (EditorGUI.EndChangeCheck())
158+
Playable.SetDone(done);
159159
EditorGUI.BeginChangeCheck();
160-
var playState = (PlayState) EditorGUILayout.EnumPopup("PlayState:", Playable.GetPlayState());
161-
if (EditorGUI.EndChangeCheck()) if (playState == PlayState.Playing) Playable.Play(); else if (playState == PlayState.Paused) Playable.Pause(); else /*Do nothing*/;
160+
var playState = (PlayState)EditorGUILayout.EnumPopup("PlayState:", Playable.GetPlayState());
161+
if (EditorGUI.EndChangeCheck())
162+
if (playState == PlayState.Playing)
163+
Playable.Play();
164+
else if (playState == PlayState.Paused)
165+
Playable.Pause();
162166
EditorGUI.BeginChangeCheck();
163167
var speed = EditorGUILayout.DoubleField("Speed:", Playable.GetSpeed());
164-
if (EditorGUI.EndChangeCheck()) Playable.SetSpeed(speed);
168+
if (EditorGUI.EndChangeCheck())
169+
Playable.SetSpeed(speed);
165170
EditorGUI.BeginChangeCheck();
166171
var duration = EditorGUILayout.DoubleField("Duration (s):", Playable.GetDuration());
167-
if (EditorGUI.EndChangeCheck()) Playable.SetDuration(duration);
172+
if (EditorGUI.EndChangeCheck())
173+
Playable.SetDuration(duration);
168174
GUILayout.Label($"PreviousTime: {Playable.GetPreviousTime().ToString("F3")}(s)");
169175
EditorGUI.BeginChangeCheck();
170176
var time = EditorGUILayout.DoubleField("Time (s):", Playable.GetTime());
171-
if (EditorGUI.EndChangeCheck()) Playable.SetTime(time);
177+
if (EditorGUI.EndChangeCheck())
178+
Playable.SetTime(time);
172179
EditorGUI.BeginChangeCheck();
173180
var leadTime = EditorGUILayout.FloatField("LeadTime (s):", Playable.GetLeadTime());
174-
if (EditorGUI.EndChangeCheck()) Playable.SetLeadTime(leadTime);
181+
if (EditorGUI.EndChangeCheck())
182+
Playable.SetLeadTime(leadTime);
175183
EditorGUI.BeginChangeCheck();
176184
var propagateSetTime = EditorGUILayout.Toggle($"PropagateSetTime:", Playable.GetPropagateSetTime());
177-
if (EditorGUI.EndChangeCheck()) Playable.SetPropagateSetTime(propagateSetTime);
185+
if (EditorGUI.EndChangeCheck())
186+
Playable.SetPropagateSetTime(propagateSetTime);
178187
EditorGUI.BeginChangeCheck();
179-
var traversalMode = (PlayableTraversalMode) EditorGUILayout.EnumPopup("TraversalMode:", Playable.GetTraversalMode());
180-
if (EditorGUI.EndChangeCheck()) Playable.SetTraversalMode(traversalMode);
188+
var traversalMode = (PlayableTraversalMode)EditorGUILayout.EnumPopup("TraversalMode:", Playable.GetTraversalMode());
189+
if (EditorGUI.EndChangeCheck())
190+
Playable.SetTraversalMode(traversalMode);
181191

182192
// Inputs
183193
GUILayout.Label(LINE);
@@ -212,7 +222,8 @@ protected virtual void AppendInputPortDescription()
212222
{
213223
EditorGUI.BeginChangeCheck();
214224
var weight = EditorGUILayout.Slider($" #{i} Weight: {Playable.GetInputWeight(i).ToString("F3")}", Playable.GetInputWeight(i), 0, 1);
215-
if (EditorGUI.EndChangeCheck()) Playable.SetInputWeight(i, weight);
225+
if (EditorGUI.EndChangeCheck())
226+
Playable.SetInputWeight(i, weight);
216227
}
217228
}
218229

Editor/Scripts/Node/PlayableOutputNode.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Text;
2-
using GBG.PlayableGraphMonitor.Editor.Utility;
1+
using GBG.PlayableGraphMonitor.Editor.Utility;
32
using UnityEditor;
43
using UnityEditor.Experimental.GraphView;
54
using UnityEditor.Playables;
@@ -97,7 +96,7 @@ public override string ToString()
9796
return GetType().Name;
9897
}
9998

100-
protected override void AppendNodeDescription()
99+
protected override void DrawNodeDescriptionInternal()
101100
{
102101
if (!PlayableOutput.IsOutputValid())
103102
{
@@ -120,7 +119,8 @@ protected override void AppendNodeDescription()
120119
GUILayout.Label($" SourceOutputPort: {PlayableOutput.GetSourceOutputPort()}");
121120
EditorGUI.BeginChangeCheck();
122121
var weight = EditorGUILayout.Slider(" Weight:", PlayableOutput.GetWeight(), 0, 1);
123-
if (EditorGUI.EndChangeCheck()) PlayableOutput.SetWeight(weight);
122+
if (EditorGUI.EndChangeCheck())
123+
PlayableOutput.SetWeight(weight);
124124
}
125125

126126
#endregion

Editor/Scripts/Node/TexturePlayableOutputNode.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Text;
2-
using UnityEditor;
1+
using UnityEditor;
32
using UnityEditor.UIElements;
43
using UnityEngine;
54
using UnityEngine.Experimental.Playables;
@@ -44,9 +43,9 @@ protected override void OnUpdate(bool playableOutputChanged)
4443
_targetField.SetValueWithoutNotify(target);
4544
}
4645

47-
protected override void AppendNodeDescription()
46+
protected override void DrawNodeDescriptionInternal()
4847
{
49-
base.AppendNodeDescription();
48+
base.DrawNodeDescriptionInternal();
5049

5150
if (!PlayableOutput.IsOutputValid())
5251
{

0 commit comments

Comments
 (0)