Skip to content

Commit 6520488

Browse files
committed
Merge branch 'feature' into release
2 parents bfd43ce + 84518e7 commit 6520488

File tree

124 files changed

+5806
-8798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+5806
-8798
lines changed

Editor.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/RateManagerInspector.cs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#if !UNITY_2019_3_OR_NEWER
2+
using UnityEditor;
3+
4+
namespace UniRate.Editor {
5+
6+
[CustomEditor(typeof(RateManager))]
7+
public class RateManagerInspector : UnityEditor.Editor {
8+
9+
public override void OnInspectorGUI() {
10+
this.serializedObject.Update();
11+
this.DrawDefaultInspector();
12+
EditorGUILayout.HelpBox("render interval is only supported on Unity 2019.3 or newer", MessageType.Warning);
13+
}
14+
}
15+
}
16+
#endif

Examples/PWRExample_DelayEventVoid.cs.meta Editor/RateManagerInspector.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
4+
namespace UniRate.Editor {
5+
6+
[CustomEditor(typeof(RateRequestComponent), true)]
7+
[CanEditMultipleObjects]
8+
public class RateRequestComponentInspector : UnityEditor.Editor {
9+
10+
#region <<---------- Properties and Fields ---------->>
11+
12+
private SerializedProperty _propUpdateRatePresetOption;
13+
private SerializedProperty _propUpdateRateCustomValue;
14+
15+
private SerializedProperty _propFixedUpdateRatePresetOption;
16+
private SerializedProperty _propFixedUpdateRateCustomValue;
17+
18+
private SerializedProperty _propRenderIntervalPresetOption;
19+
private SerializedProperty _propRenderIntervalCustomValue;
20+
21+
private SerializedProperty _propDelaySecondsToStopRequests;
22+
23+
private readonly string[] _displayUpdateRate = new [] {
24+
$"{RateRequestComponent.PresetOptions.Ultra.ToString()} ({RatePreset.Ultra.UpdateRate.ToString()})",
25+
$"{RateRequestComponent.PresetOptions.VeryHigh.ToString()} ({RatePreset.VeryHigh.UpdateRate.ToString()})",
26+
$"{RateRequestComponent.PresetOptions.High.ToString()} ({RatePreset.High.UpdateRate.ToString()})",
27+
$"{RateRequestComponent.PresetOptions.Medium.ToString()} ({RatePreset.Medium.UpdateRate.ToString()})",
28+
$"{RateRequestComponent.PresetOptions.Low.ToString()} ({RatePreset.Low.UpdateRate.ToString()})",
29+
$"{RateRequestComponent.PresetOptions.VeryLow.ToString()} ({RatePreset.VeryLow.UpdateRate.ToString()})",
30+
RateRequestComponent.PresetOptions.Custom.ToString(),
31+
};
32+
33+
private readonly string[] _displayFixedUpdateRate = new [] {
34+
$"{RateRequestComponent.PresetOptions.Ultra.ToString()} ({RatePreset.Ultra.FixedUpdateRate.ToString()})",
35+
$"{RateRequestComponent.PresetOptions.VeryHigh.ToString()} ({RatePreset.VeryHigh.FixedUpdateRate.ToString()})",
36+
$"{RateRequestComponent.PresetOptions.High.ToString()} ({RatePreset.High.FixedUpdateRate.ToString()})",
37+
$"{RateRequestComponent.PresetOptions.Medium.ToString()} ({RatePreset.Medium.FixedUpdateRate.ToString()})",
38+
$"{RateRequestComponent.PresetOptions.Low.ToString()} ({RatePreset.Low.FixedUpdateRate.ToString()})",
39+
$"{RateRequestComponent.PresetOptions.VeryLow.ToString()} ({RatePreset.VeryLow.FixedUpdateRate.ToString()})",
40+
RateRequestComponent.PresetOptions.Custom.ToString(),
41+
};
42+
43+
private readonly string[] _displayRenderInterval = new [] {
44+
$"{RateRequestComponent.PresetOptions.Ultra.ToString()} ({RatePreset.Ultra.RenderInterval.ToString()})",
45+
$"{RateRequestComponent.PresetOptions.VeryHigh.ToString()} ({RatePreset.VeryHigh.RenderInterval.ToString()})",
46+
$"{RateRequestComponent.PresetOptions.High.ToString()} ({RatePreset.High.RenderInterval.ToString()})",
47+
$"{RateRequestComponent.PresetOptions.Medium.ToString()} ({RatePreset.Medium.RenderInterval.ToString()})",
48+
$"{RateRequestComponent.PresetOptions.Low.ToString()} ({RatePreset.Low.RenderInterval.ToString()})",
49+
$"{RateRequestComponent.PresetOptions.VeryLow.ToString()} ({RatePreset.VeryLow.RenderInterval.ToString()})",
50+
RateRequestComponent.PresetOptions.Custom.ToString(),
51+
};
52+
53+
private const string STR_SPACE = " ";
54+
55+
#endregion <<---------- Properties and Fields ---------->>
56+
57+
58+
59+
60+
#region <<---------- Editor ---------->>
61+
62+
private void OnEnable() {
63+
this._propUpdateRatePresetOption = this.serializedObject.FindProperty("_updateRatePresetOption");
64+
this._propUpdateRateCustomValue = this.serializedObject.FindProperty("_updateRateCustomValue");
65+
66+
this._propFixedUpdateRatePresetOption = this.serializedObject.FindProperty("_fixedUpdateRatePresetOption");
67+
this._propFixedUpdateRateCustomValue = this.serializedObject.FindProperty("_fixedUpdateRateCustomValue");
68+
69+
this._propRenderIntervalPresetOption = this.serializedObject.FindProperty("_renderIntervalPresetOption");
70+
this._propRenderIntervalCustomValue = this.serializedObject.FindProperty("_renderIntervalCustomValue");
71+
72+
this._propDelaySecondsToStopRequests = this.serializedObject.FindProperty("_delaySecondsToStopRequests");
73+
}
74+
75+
public override void OnInspectorGUI() {
76+
this.serializedObject.Update();
77+
this.DrawDefaultInspector();
78+
79+
EditorGUI.BeginChangeCheck();
80+
EditorGUILayout.PropertyField(this._propDelaySecondsToStopRequests, new GUIContent("Delay Seconds to Stop Requests"));
81+
if (EditorGUI.EndChangeCheck()) {
82+
this.serializedObject.ApplyModifiedProperties();
83+
}
84+
EditorGUILayout.Space();
85+
86+
bool isCustom;
87+
88+
EditorGUI.BeginChangeCheck();
89+
isCustom = this.DrawPresetOptionAndReturnIfCustom("Render Interval", this._displayRenderInterval, this._propRenderIntervalPresetOption);
90+
if (EditorGUI.EndChangeCheck()) {
91+
this.serializedObject.ApplyModifiedProperties();
92+
}
93+
if (isCustom) {
94+
EditorGUI.BeginChangeCheck();
95+
this._propRenderIntervalCustomValue.intValue = EditorGUILayout.IntField(STR_SPACE, this._propRenderIntervalCustomValue.intValue);
96+
if (EditorGUI.EndChangeCheck()) {
97+
this.serializedObject.ApplyModifiedProperties();
98+
}
99+
}
100+
101+
EditorGUI.BeginChangeCheck();
102+
isCustom = this.DrawPresetOptionAndReturnIfCustom("Update Rate", this._displayUpdateRate, this._propUpdateRatePresetOption);
103+
if (EditorGUI.EndChangeCheck()) {
104+
this.serializedObject.ApplyModifiedProperties();
105+
}
106+
if (isCustom) {
107+
EditorGUI.BeginChangeCheck();
108+
this._propUpdateRateCustomValue.intValue = EditorGUILayout.IntField(STR_SPACE, this._propUpdateRateCustomValue.intValue);
109+
if (EditorGUI.EndChangeCheck()) {
110+
this.serializedObject.ApplyModifiedProperties();
111+
}
112+
}
113+
114+
EditorGUI.BeginChangeCheck();
115+
isCustom = this.DrawPresetOptionAndReturnIfCustom("Fixed Update Rate", this._displayFixedUpdateRate, this._propFixedUpdateRatePresetOption);
116+
if (EditorGUI.EndChangeCheck()) {
117+
this.serializedObject.ApplyModifiedProperties();
118+
}
119+
if (isCustom) {
120+
EditorGUI.BeginChangeCheck();
121+
this._propFixedUpdateRateCustomValue.intValue = EditorGUILayout.IntField(STR_SPACE, this._propFixedUpdateRateCustomValue.intValue);
122+
if (EditorGUI.EndChangeCheck()) {
123+
this.serializedObject.ApplyModifiedProperties();
124+
}
125+
}
126+
127+
#if !UNITY_2019_3_OR_NEWER
128+
EditorGUILayout.Space();
129+
EditorGUILayout.HelpBox("render interval is only supported on Unity 2019.3 or newer", MessageType.Warning);
130+
#endif
131+
}
132+
133+
#endregion <<---------- Editor ---------->>
134+
135+
136+
137+
138+
#region <<---------- General ---------->>
139+
140+
private bool DrawPresetOptionAndReturnIfCustom(string label, string[] display, SerializedProperty property) {
141+
int enumIndex = (property.hasMultipleDifferentValues ? -1 : property.enumValueIndex);
142+
enumIndex = EditorGUILayout.Popup(label, enumIndex, display);
143+
var enumValue = (RateRequestComponent.PresetOptions)enumIndex;
144+
if (enumIndex != -1) {
145+
property.enumValueIndex = enumIndex;
146+
}
147+
return (enumValue == RateRequestComponent.PresetOptions.Custom);
148+
}
149+
150+
#endregion <<---------- General ---------->>
151+
}
152+
}

Examples/PWRExample_NumberToText.cs.meta Editor/RateRequestComponentInspector.cs.meta

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/UniRate.Editor.asmdef

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "UniRate.Editor",
3+
"references": [
4+
"UniRate"
5+
],
6+
"optionalUnityReferences": [],
7+
"includePlatforms": [
8+
"Editor"
9+
],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": false,
13+
"precompiledReferences": [],
14+
"autoReferenced": true,
15+
"defineConstraints": []
16+
}

Editor/UniRate.Editor.asmdef.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)