void ValidatePivot(Transform fg, string name, UISlider.Direction dir) { if (fg != null) { UISprite sprite = fg.GetComponent <UISprite>(); if (sprite != null && sprite.type != UISprite.Type.Filled) { if (dir == UISlider.Direction.Horizontal) { if (sprite.pivot != UIWidget.Pivot.Left && sprite.pivot != UIWidget.Pivot.TopLeft && sprite.pivot != UIWidget.Pivot.BottomLeft) { GUI.color = new Color(1f, 0.7f, 0f); GUILayout.Label(name + " should use a Left pivot"); GUI.color = Color.white; } } else if (sprite.pivot != UIWidget.Pivot.BottomLeft && sprite.pivot != UIWidget.Pivot.Bottom && sprite.pivot != UIWidget.Pivot.BottomRight) { GUI.color = new Color(1f, 0.7f, 0f); GUILayout.Label(name + " should use a Bottom pivot"); GUI.color = Color.white; } } } }
public unsafe override void LoadFromBuffer(FakeStruct fake, Initializer initializer) { SliderInfo *si = (SliderInfo *)fake.ip; StartOffset = si->StartOffset; EndOffset = si->EndOffset; MinScale = si->MinScale; MaxScale = si->MaxScale; direction = si->direction; }
public unsafe override void Unity_NamedDeserialize(int depth) { byte[] var_0_cp_0; int var_0_cp_1; if (depth <= 7) { ISerializedNamedStateReader arg_1E_0 = SerializedNamedStateReader.Instance; var_0_cp_0 = $FieldNamesStorage.$RuntimeNames; var_0_cp_1 = 0; this.thumb = (arg_1E_0.ReadUnityEngineObject(&var_0_cp_0[var_0_cp_1] + 1570) as Transform); } if (depth <= 7) { this.mBG = (SerializedNamedStateReader.Instance.ReadUnityEngineObject(&var_0_cp_0[var_0_cp_1] + 1576) as UIWidget); } if (depth <= 7) { this.mFG = (SerializedNamedStateReader.Instance.ReadUnityEngineObject(&var_0_cp_0[var_0_cp_1] + 1580) as UIWidget); } this.mValue = SerializedNamedStateReader.Instance.ReadSingle(&var_0_cp_0[var_0_cp_1] + 1584); this.mFill = (UIProgressBar.FillDirection)SerializedNamedStateReader.Instance.ReadInt32(&var_0_cp_0[var_0_cp_1] + 1591); this.numberOfSteps = SerializedNamedStateReader.Instance.ReadInt32(&var_0_cp_0[var_0_cp_1] + 1597); if (depth <= 7) { int num = SerializedNamedStateReader.Instance.BeginSequenceGroup(&var_0_cp_0[var_0_cp_1] + 1446); this.onChange = new List <EventDelegate>(num); for (int i = 0; i < num; i++) { EventDelegate eventDelegate = new EventDelegate(); EventDelegate arg_F8_0 = eventDelegate; SerializedNamedStateReader.Instance.BeginMetaGroup((IntPtr)0); arg_F8_0.Unity_NamedDeserialize(depth + 1); SerializedNamedStateReader.Instance.EndMetaGroup(); this.onChange.Add(eventDelegate); } SerializedNamedStateReader.Instance.EndMetaGroup(); } if (depth <= 7) { this.foreground = (SerializedNamedStateReader.Instance.ReadUnityEngineObject(&var_0_cp_0[var_0_cp_1] + 1619) as Transform); } this.rawValue = SerializedNamedStateReader.Instance.ReadSingle(&var_0_cp_0[var_0_cp_1] + 1630); this.direction = (UISlider.Direction)SerializedNamedStateReader.Instance.ReadInt32(&var_0_cp_0[var_0_cp_1] + 1639); this.mInverted = SerializedNamedStateReader.Instance.ReadBoolean(&var_0_cp_0[var_0_cp_1] + 1649); SerializedNamedStateReader.Instance.Align(); }
protected override void Upgrade() { if (this.direction != UISlider.Direction.Upgraded) { this.mValue = this.rawValue; if (this.foreground != null) { this.mFG = this.foreground.GetComponent <UIWidget>(); } if (this.direction == UISlider.Direction.Horizontal) { this.mFill = (this.mInverted ? UIProgressBar.FillDirection.RightToLeft : UIProgressBar.FillDirection.LeftToRight); } else { this.mFill = (this.mInverted ? UIProgressBar.FillDirection.TopToBottom : UIProgressBar.FillDirection.BottomToTop); } this.direction = UISlider.Direction.Upgraded; } }
public override void Unity_Deserialize(int depth) { if (depth <= 7) { this.thumb = (SerializedStateReader.Instance.ReadUnityEngineObject() as Transform); } if (depth <= 7) { this.mBG = (SerializedStateReader.Instance.ReadUnityEngineObject() as UIWidget); } if (depth <= 7) { this.mFG = (SerializedStateReader.Instance.ReadUnityEngineObject() as UIWidget); } this.mValue = SerializedStateReader.Instance.ReadSingle(); this.mFill = (UIProgressBar.FillDirection)SerializedStateReader.Instance.ReadInt32(); this.numberOfSteps = SerializedStateReader.Instance.ReadInt32(); if (depth <= 7) { int num = SerializedStateReader.Instance.ReadInt32(); this.onChange = new List <EventDelegate>(num); for (int i = 0; i < num; i++) { EventDelegate eventDelegate = new EventDelegate(); eventDelegate.Unity_Deserialize(depth + 1); this.onChange.Add(eventDelegate); } } if (depth <= 7) { this.foreground = (SerializedStateReader.Instance.ReadUnityEngineObject() as Transform); } this.rawValue = SerializedStateReader.Instance.ReadSingle(); this.direction = (UISlider.Direction)SerializedStateReader.Instance.ReadInt32(); this.mInverted = SerializedStateReader.Instance.ReadBoolean(); SerializedStateReader.Instance.Align(); }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(80f); UISlider slider = target as UISlider; NGUIEditorTools.DrawSeparator(); float sliderValue = EditorGUILayout.Slider("Value", slider.sliderValue, 0f, 1f); if (slider.sliderValue != sliderValue) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.sliderValue = sliderValue; UnityEditor.EditorUtility.SetDirty(slider); } int steps = EditorGUILayout.IntSlider("Steps", slider.numberOfSteps, 0, 11); if (slider.numberOfSteps != steps) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.numberOfSteps = steps; slider.ForceUpdate(); UnityEditor.EditorUtility.SetDirty(slider); } NGUIEditorTools.DrawSeparator(); Transform fg = EditorGUILayout.ObjectField("Foreground", slider.foreground, typeof(Transform), true) as Transform; Transform tb = EditorGUILayout.ObjectField("Thumb", slider.thumb, typeof(Transform), true) as Transform; UISlider.Direction dir = (UISlider.Direction)EditorGUILayout.EnumPopup("Direction", slider.direction); // If we're using a sprite for the foreground, ensure it's using a proper pivot. ValidatePivot(fg, "Foreground sprite", dir); NGUIEditorTools.DrawSeparator(); GameObject er = EditorGUILayout.ObjectField("Event Recv.", slider.eventReceiver, typeof(GameObject), true) as GameObject; GUILayout.BeginHorizontal(); string fn = EditorGUILayout.TextField("Function", slider.functionName); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (slider.foreground != fg || slider.thumb != tb || slider.direction != dir || slider.eventReceiver != er || slider.functionName != fn) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.foreground = fg; slider.thumb = tb; slider.direction = dir; slider.eventReceiver = er; slider.functionName = fn; if (slider.thumb != null) { slider.thumb.localPosition = Vector3.zero; slider.sliderValue = -1f; slider.sliderValue = sliderValue; } else { slider.ForceUpdate(); } UnityEditor.EditorUtility.SetDirty(slider); } }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(80f); UISlider slider = target as UISlider; NGUIEditorTools.DrawSeparator(); float sliderValue = EditorGUILayout.Slider("Value", slider.sliderValue, 0f, 1f); if (slider.sliderValue != sliderValue) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.sliderValue = sliderValue; UnityEditor.EditorUtility.SetDirty(slider); } int steps = EditorGUILayout.IntSlider("Steps", slider.numberOfSteps, 0, 11); if (slider.numberOfSteps != steps) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.numberOfSteps = steps; slider.ForceUpdate(); UnityEditor.EditorUtility.SetDirty(slider); } NGUIEditorTools.DrawSeparator(); Vector2 size = slider.fullSize; GUILayout.Label(" Size"); GUILayout.Space(-36f); GUILayout.BeginHorizontal(); GUILayout.Space(66f); size = EditorGUILayout.Vector2Field("", size); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (mShowWarning && slider.foreground != null) { UIWidget widget = slider.foreground.GetComponent <UIWidget>(); if (widget != null && !(widget is UIFilledSprite)) { GUI.color = new Color(1f, 0.7f, 0f); GUILayout.Label("Don't forget to adjust the background as well"); GUILayout.Label("(the slider doesn't know what it is)"); GUI.color = Color.white; } } Transform fg = EditorGUILayout.ObjectField("Foreground", slider.foreground, typeof(Transform), true) as Transform; Transform tb = EditorGUILayout.ObjectField("Thumb", slider.thumb, typeof(Transform), true) as Transform; UISlider.Direction dir = (UISlider.Direction)EditorGUILayout.EnumPopup("Direction", slider.direction); // If we're using a sprite for the foreground, ensure it's using a proper pivot. ValidatePivot(fg, "Foreground sprite", dir); NGUIEditorTools.DrawSeparator(); GameObject er = EditorGUILayout.ObjectField("Event Recv.", slider.eventReceiver, typeof(GameObject), true) as GameObject; GUILayout.BeginHorizontal(); string fn = EditorGUILayout.TextField("Function", slider.functionName); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (slider.foreground != fg || slider.thumb != tb || slider.direction != dir || slider.fullSize != size || slider.eventReceiver != er || slider.functionName != fn) { if (slider.fullSize != size) { mShowWarning = true; } NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.foreground = fg; slider.thumb = tb; slider.direction = dir; slider.fullSize = size; slider.eventReceiver = er; slider.functionName = fn; if (slider.thumb != null) { slider.thumb.localPosition = Vector3.zero; slider.sliderValue = -1f; slider.sliderValue = sliderValue; } else { slider.ForceUpdate(); } UnityEditor.EditorUtility.SetDirty(slider); } }
public override void OnInspectorGUI() { NGUIEditorTools.SetLabelWidth(80f); UISlider slider = target as UISlider; GUILayout.Space(3f); float sliderValue = EditorGUILayout.Slider("Value", slider.value, 0f, 1f); if (slider.value != sliderValue) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.value = sliderValue; UnityEditor.EditorUtility.SetDirty(slider); } int steps = EditorGUILayout.IntSlider("Steps", slider.numberOfSteps, 0, 11); if (slider.numberOfSteps != steps) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.numberOfSteps = steps; slider.ForceUpdate(); UnityEditor.EditorUtility.SetDirty(slider); } //GUILayout.Space(6f); Transform fg = slider.foreground; Transform tb = slider.thumb; UISlider.Direction dir = slider.direction; if (NGUIEditorTools.DrawHeader("Appearance")) { NGUIEditorTools.BeginContents(); GUILayout.BeginHorizontal(); dir = (UISlider.Direction)EditorGUILayout.EnumPopup("Direction", slider.direction); GUILayout.Space(18f); GUILayout.EndHorizontal(); fg = EditorGUILayout.ObjectField("Foreground", slider.foreground, typeof(Transform), true) as Transform; tb = EditorGUILayout.ObjectField("Thumb", slider.thumb, typeof(Transform), true) as Transform; // If we're using a sprite for the foreground, ensure it's using a proper pivot. ValidatePivot(fg, "Foreground sprite", dir); NGUIEditorTools.EndContents(); } //GUILayout.Space(3f); if (slider.foreground != fg || slider.thumb != tb || slider.direction != dir) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.foreground = fg; slider.thumb = tb; slider.direction = dir; if (slider.thumb != null) { slider.thumb.localPosition = Vector3.zero; slider.value = -1f; slider.value = sliderValue; } else { slider.ForceUpdate(); } UnityEditor.EditorUtility.SetDirty(slider); } NGUIEditorTools.DrawEvents("On Value Change", slider, slider.onChange); }
public UISlider() { this.rawValue = 1f; this.direction = UISlider.Direction.Upgraded; base..ctor(); }
protected override void Upgrade() { if (this.direction != UISlider.Direction.Upgraded) { this.mValue = this.rawValue; if (this.foreground != null) { this.mFG = this.foreground.GetComponent<UIWidget>(); } if (this.direction == UISlider.Direction.Horizontal) { this.mFill = ((!this.mInverted) ? UIProgressBar.FillDirection.LeftToRight : UIProgressBar.FillDirection.RightToLeft); } else { this.mFill = ((!this.mInverted) ? UIProgressBar.FillDirection.BottomToTop : UIProgressBar.FillDirection.TopToBottom); } this.direction = UISlider.Direction.Upgraded; } }