public override void OnInspectorGUI() { EditorGUIUtility.LookLikeInspector(); base.OnInspectorGUI(); tk2dUIScrollableArea scrollableArea = (tk2dUIScrollableArea)target; scrollableArea.BackgroundLayoutItem = EditorGUILayout.ObjectField("Background LayoutItem", scrollableArea.BackgroundLayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; scrollableArea.ContentLayoutContainer = EditorGUILayout.ObjectField("Content LayoutContainer", scrollableArea.ContentLayoutContainer, typeof(tk2dUILayoutContainer), true) as tk2dUILayoutContainer; GUILayout.Label("Tools", EditorStyles.boldLabel); if (GUILayout.Button("Calculate content length")) { Undo.RegisterUndo(scrollableArea, "Content length changed"); Bounds b = tk2dUIItemBoundsHelper.GetRendererBoundsInChildren( scrollableArea.contentContainer.transform, scrollableArea.contentContainer.transform ); b.Encapsulate(Vector3.zero); float contentSize = (scrollableArea.scrollAxes == tk2dUIScrollableArea.Axes.XAxis) ? b.size.x : b.size.y; scrollableArea.ContentLength = contentSize * 1.02f; // 5% more EditorUtility.SetDirty(scrollableArea); } tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); scrollableArea.SendMessageTarget = methodBindingUtil.BeginMessageGUI(scrollableArea.SendMessageTarget); methodBindingUtil.MethodBinding( "On Scroll", typeof(tk2dUIScrollableArea), scrollableArea.SendMessageTarget, ref scrollableArea.SendMessageOnScrollMethodName ); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { EditorUtility.SetDirty(scrollableArea); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); base.OnInspectorGUI(); tk2dUITextInput textInput = (tk2dUITextInput)target; textInput.LayoutItem = EditorGUILayout.ObjectField("LayoutItem", textInput.LayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); textInput.SendMessageTarget = methodBindingUtil.BeginMessageGUI(textInput.SendMessageTarget); methodBindingUtil.MethodBinding("On Text Change", typeof(tk2dUITextInput), textInput.SendMessageTarget, ref textInput.SendMessageOnTextChangeMethodName); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { tk2dUtil.SetDirty(textInput); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); base.OnInspectorGUI(); tk2dUIDropDownMenu dropdownMenu = (tk2dUIDropDownMenu)target; dropdownMenu.MenuLayoutItem = EditorGUILayout.ObjectField("Menu LayoutItem", dropdownMenu.MenuLayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; dropdownMenu.TemplateLayoutItem = EditorGUILayout.ObjectField("Template LayoutItem", dropdownMenu.TemplateLayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; if (dropdownMenu.MenuLayoutItem == null) { dropdownMenu.height = EditorGUILayout.FloatField("Height", dropdownMenu.height, GUILayout.ExpandWidth(false)); } tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); dropdownMenu.SendMessageTarget = methodBindingUtil.BeginMessageGUI(dropdownMenu.SendMessageTarget); methodBindingUtil.MethodBinding("On Selected Item Change", typeof(tk2dUIDropDownMenu), dropdownMenu.SendMessageTarget, ref dropdownMenu.SendMessageOnSelectedItemChangeMethodName); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { tk2dUtil.SetDirty(target); } }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeInspector(); base.OnInspectorGUI(); tk2dUIScrollableArea scrollableArea = (tk2dUIScrollableArea)target; scrollableArea.BackgroundLayoutItem = EditorGUILayout.ObjectField("Background LayoutItem", scrollableArea.BackgroundLayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; scrollableArea.ContentLayoutContainer = EditorGUILayout.ObjectField("Content LayoutContainer", scrollableArea.ContentLayoutContainer, typeof(tk2dUILayoutContainer), true) as tk2dUILayoutContainer; GUILayout.Label("Tools", EditorStyles.boldLabel); if (GUILayout.Button("Calculate content length")) { Undo.RegisterUndo(scrollableArea, "Content length changed"); Bounds b = tk2dUIItemBoundsHelper.GetRendererBoundsInChildren(scrollableArea.contentContainer.transform, scrollableArea.contentContainer.transform); b.Encapsulate(Vector3.zero); float contentSize = (scrollableArea.scrollAxes == tk2dUIScrollableArea.Axes.XAxis) ? b.size.x : b.size.y; scrollableArea.ContentLength = contentSize * 1.02f; // 5% more EditorUtility.SetDirty(scrollableArea); } tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); scrollableArea.SendMessageTarget = methodBindingUtil.BeginMessageGUI(scrollableArea.SendMessageTarget); methodBindingUtil.MethodBinding("On Scroll", typeof(tk2dUIScrollableArea), scrollableArea.SendMessageTarget, ref scrollableArea.SendMessageOnScrollMethodName); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { EditorUtility.SetDirty(scrollableArea); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); base.OnInspectorGUI(); tk2dUIScrollbar scrollbar = (tk2dUIScrollbar)target; scrollbar.BarLayoutItem = EditorGUILayout.ObjectField("Bar LayoutItem", scrollbar.BarLayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; scrollbar.SendMessageTarget = methodBindingUtil.BeginMessageGUI(scrollbar.SendMessageTarget); methodBindingUtil.MethodBinding("On Scroll", typeof(tk2dUIScrollbar), scrollbar.SendMessageTarget, ref scrollbar.SendMessageOnScrollMethodName); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { tk2dUtil.SetDirty(scrollbar); } }
public override void OnInspectorGUI() { serializedObject.Update(); bool changeOccurred = false; tk2dGuiUtility.LookLikeControls(180); tk2dUIItem btn = (tk2dUIItem)target; bool newIsChildOfAnotherMenuBtn = EditorGUILayout.Toggle("Child of Another UIItem?", btn.InternalGetIsChildOfAnotherUIItem()); if (newIsChildOfAnotherMenuBtn != btn.InternalGetIsChildOfAnotherUIItem()) { changeOccurred = true; btn.InternalSetIsChildOfAnotherUIItem(newIsChildOfAnotherMenuBtn); } btn.registerPressFromChildren = EditorGUILayout.Toggle("Register Events From Children", btn.registerPressFromChildren); btn.isHoverEnabled = EditorGUILayout.Toggle("Is Hover Events Enabled?", btn.isHoverEnabled); btn.sendMessageTarget = methodBindingUtil.BeginMessageGUI(btn.sendMessageTarget); methodBindingUtil.MethodBinding("On Down", typeof(tk2dUIItem), btn.sendMessageTarget, ref btn.SendMessageOnDownMethodName); methodBindingUtil.MethodBinding("On Up", typeof(tk2dUIItem), btn.sendMessageTarget, ref btn.SendMessageOnUpMethodName); methodBindingUtil.MethodBinding("On Click", typeof(tk2dUIItem), btn.sendMessageTarget, ref btn.SendMessageOnClickMethodName); methodBindingUtil.MethodBinding("On Release", typeof(tk2dUIItem), btn.sendMessageTarget, ref btn.SendMessageOnReleaseMethodName); methodBindingUtil.EndMessageGUI(); #if UNITY_5 if (btn.GetComponent <Collider>() != null) { #else if (btn.collider != null) { #endif GUILayout.Label("Collider", EditorStyles.boldLabel); EditorGUI.indentLevel++; GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Automatic Fit"); if (GUILayout.Button("Fit", GUILayout.MaxWidth(100))) { tk2dUIItemBoundsHelper.FixColliderBounds(btn); } GUILayout.EndHorizontal(); ArrayProperty("Extra Bounds", extraBoundsProp); ArrayProperty("Ignore Bounds", ignoreBoundsProp); EditorGUI.indentLevel--; } serializedObject.ApplyModifiedProperties(); if (GUI.changed || changeOccurred) { EditorUtility.SetDirty(btn); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); base.OnInspectorGUI(); tk2dUITextInput textInput = (tk2dUITextInput)target; textInput.LayoutItem = EditorGUILayout.ObjectField("LayoutItem", textInput.LayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); textInput.SendMessageTarget = methodBindingUtil.BeginMessageGUI(textInput.SendMessageTarget); methodBindingUtil.MethodBinding( "On Text Change", typeof(tk2dUITextInput), textInput.SendMessageTarget, ref textInput.SendMessageOnTextChangeMethodName ); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { EditorUtility.SetDirty(textInput); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); tk2dUIToggleButtonGroup toggleBtnGroup = (tk2dUIToggleButtonGroup)target; serializedObj.Update(); ListIterator("toggleBtns", ref listVisibility); serializedObj.ApplyModifiedProperties(); toggleBtnGroup.SelectedIndex = EditorGUILayout.IntField("Selected Index", toggleBtnGroup.SelectedIndex); tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); toggleBtnGroup.sendMessageTarget = methodBindingUtil.BeginMessageGUI(toggleBtnGroup.sendMessageTarget); methodBindingUtil.MethodBinding( "On Change", typeof(tk2dUIToggleButtonGroup), toggleBtnGroup.sendMessageTarget, ref toggleBtnGroup.SendMessageOnChangeMethodName ); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { tk2dUtil.SetDirty(toggleBtnGroup); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); base.OnInspectorGUI(); tk2dUIDropDownMenu dropdownMenu = (tk2dUIDropDownMenu)target; dropdownMenu.MenuLayoutItem = EditorGUILayout.ObjectField("Menu LayoutItem", dropdownMenu.MenuLayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; dropdownMenu.TemplateLayoutItem = EditorGUILayout.ObjectField("Template LayoutItem", dropdownMenu.TemplateLayoutItem, typeof(tk2dUILayout), true) as tk2dUILayout; if (dropdownMenu.MenuLayoutItem == null) dropdownMenu.height = EditorGUILayout.FloatField("Height", dropdownMenu.height, GUILayout.ExpandWidth(false)); tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); dropdownMenu.SendMessageTarget = methodBindingUtil.BeginMessageGUI(dropdownMenu.SendMessageTarget); methodBindingUtil.MethodBinding( "On Selected Item Change", typeof(tk2dUIDropDownMenu), dropdownMenu.SendMessageTarget, ref dropdownMenu.SendMessageOnSelectedItemChangeMethodName ); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { tk2dUtil.SetDirty(target); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); tk2dUIToggleButtonGroup toggleBtnGroup = (tk2dUIToggleButtonGroup)target; serializedObj.Update(); ListIterator("toggleBtns", ref listVisibility); serializedObj.ApplyModifiedProperties(); toggleBtnGroup.SelectedIndex = EditorGUILayout.IntField("Selected Index", toggleBtnGroup.SelectedIndex); tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); toggleBtnGroup.sendMessageTarget = methodBindingUtil.BeginMessageGUI(toggleBtnGroup.sendMessageTarget); methodBindingUtil.MethodBinding("On Change", typeof(tk2dUIToggleButtonGroup), toggleBtnGroup.sendMessageTarget, ref toggleBtnGroup.SendMessageOnChangeMethodName); methodBindingUtil.EndMessageGUI(); if (GUI.changed) { tk2dUtil.SetDirty(toggleBtnGroup); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); bool markAsDirty = false; tk2dUIProgressBar progressBar = (tk2dUIProgressBar)target; if (progressBar.clippedSpriteBar != null) //can only be one { progressBar.scalableBar = null; progressBar.slicedSpriteBar = null; } if (progressBar.slicedSpriteBar != null) { progressBar.clippedSpriteBar = null; progressBar.scalableBar = null; } tk2dClippedSprite tempClippedSpriteBar = tk2dUICustomEditorGUILayout.SceneObjectField("Clipped Sprite Bar", progressBar.clippedSpriteBar, target); if (tempClippedSpriteBar != progressBar.clippedSpriteBar) { markAsDirty = true; progressBar.clippedSpriteBar = tempClippedSpriteBar; progressBar.scalableBar = null; //can only be one progressBar.slicedSpriteBar = null; } tk2dSlicedSprite tempSlicedSpriteBar = tk2dUICustomEditorGUILayout.SceneObjectField("Sliced Sprite Bar", progressBar.slicedSpriteBar, target); if (tempSlicedSpriteBar != progressBar.slicedSpriteBar) { markAsDirty = true; progressBar.slicedSpriteBar = tempSlicedSpriteBar; progressBar.scalableBar = null; //can only be one progressBar.clippedSpriteBar = null; } Transform tempScalableBar = tk2dUICustomEditorGUILayout.SceneObjectField("Scalable Bar", progressBar.scalableBar, target); if (tempScalableBar != progressBar.scalableBar) { markAsDirty = true; progressBar.scalableBar = tempScalableBar; progressBar.clippedSpriteBar = null; //can only be one progressBar.slicedSpriteBar = null; } float tempPercent = EditorGUILayout.FloatField("Value", progressBar.Value); if (tempPercent != progressBar.Value) { markAsDirty = true; progressBar.Value = tempPercent; } tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); progressBar.sendMessageTarget = methodBindingUtil.BeginMessageGUI(progressBar.sendMessageTarget); methodBindingUtil.MethodBinding("On Progress Complete", typeof(tk2dUIProgressBar), progressBar.sendMessageTarget, ref progressBar.SendMessageOnProgressCompleteMethodName); methodBindingUtil.EndMessageGUI(); if (markAsDirty || GUI.changed) { tk2dUtil.SetDirty(progressBar); } }
public override void OnInspectorGUI() { tk2dGuiUtility.LookLikeInspector(); bool markAsDirty = false; tk2dUIProgressBar progressBar = (tk2dUIProgressBar)target; if (progressBar.clippedSpriteBar != null) //can only be one { progressBar.scalableBar = null; progressBar.slicedSpriteBar = null; } if (progressBar.slicedSpriteBar != null) { progressBar.clippedSpriteBar = null; progressBar.scalableBar = null; } tk2dClippedSprite tempClippedSpriteBar = tk2dUICustomEditorGUILayout.SceneObjectField("Clipped Sprite Bar", progressBar.clippedSpriteBar, target); if (tempClippedSpriteBar != progressBar.clippedSpriteBar) { markAsDirty = true; progressBar.clippedSpriteBar = tempClippedSpriteBar; progressBar.scalableBar = null; //can only be one progressBar.slicedSpriteBar = null; } tk2dSlicedSprite tempSlicedSpriteBar = tk2dUICustomEditorGUILayout.SceneObjectField("Sliced Sprite Bar", progressBar.slicedSpriteBar, target); if (tempSlicedSpriteBar != progressBar.slicedSpriteBar) { markAsDirty = true; progressBar.slicedSpriteBar = tempSlicedSpriteBar; progressBar.scalableBar = null; //can only be one progressBar.clippedSpriteBar = null; } Transform tempScalableBar = tk2dUICustomEditorGUILayout.SceneObjectField("Scalable Bar", progressBar.scalableBar,target); if (tempScalableBar != progressBar.scalableBar) { markAsDirty = true; progressBar.scalableBar = tempScalableBar; progressBar.clippedSpriteBar = null; //can only be one progressBar.slicedSpriteBar = null; } float tempPercent = EditorGUILayout.FloatField("Value", progressBar.Value); if (tempPercent != progressBar.Value) { markAsDirty = true; progressBar.Value = tempPercent; } tk2dUIMethodBindingHelper methodBindingUtil = new tk2dUIMethodBindingHelper(); progressBar.sendMessageTarget = methodBindingUtil.BeginMessageGUI(progressBar.sendMessageTarget); methodBindingUtil.MethodBinding( "On Progress Complete", typeof(tk2dUIProgressBar), progressBar.sendMessageTarget, ref progressBar.SendMessageOnProgressCompleteMethodName ); methodBindingUtil.EndMessageGUI(); if (markAsDirty || GUI.changed) { tk2dUtil.SetDirty(progressBar); } }