public override void OnInspectorGUI() { if (isCreatingClass) { CreatingClass(); return; } UIView view = (UIView)target; EditorGUILayout.HelpBox("UIView is the controller for the view. To add custom logic to the view use Create subclass option", MessageType.Info, true); EditorGUILayout.LabelField("Tools"); Rect basicRect = EditorGUILayout.BeginVertical(); EditorGUI.DrawRect(basicRect, ToolkitColor.shade); EditorGUILayout.Space(); EditorGUILayout.LabelField("Basic"); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add segue")) { GameObject segueGO = new GameObject("segue"); segueGO.transform.SetParent(view.transform); segueGO.transform.localPosition = Vector3.zero; UISegue segue = segueGO.AddComponent <UISegue>(); Selection.activeGameObject = segue.gameObject; } if (GUILayout.Button("Show Preview")) { SetPreviewVisibility(true); } if (GUILayout.Button("Hide Preview")) { SetPreviewVisibility(false); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); //only show create subclass button if we are showing baseclass if (!this.ContainsComponentWithName(view.name)) { Rect advancedRect = EditorGUILayout.BeginVertical(); EditorGUI.DrawRect(advancedRect, ToolkitColor.shade); EditorGUILayout.Space(); EditorGUILayout.LabelField("Advanced"); if (GUILayout.Button("Create subclass")) { Utilities.CreateViewClass(view.name); isCreatingClass = true; } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } base.DrawDefaultInspector(); }
public override void OnInspectorGUI() { UISegue segue = (UISegue)target; serializedObject.Update(); EditorGUILayout.HelpBox("UISegue performing transition between UIViews", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); //source view Rect cellRect = EditorGUILayout.BeginVertical(GUILayout.MaxWidth(150)); EditorGUI.DrawRect(cellRect, ToolkitColor.shade); EditorGUILayout.Space(); EditorGUILayout.LabelField("Source view (locked)", GUILayout.Width(120)); EditorGUILayout.ObjectField(segue.sourceView, typeof(UIView), true, GUILayout.Width(150)); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); //arrow //load arrow texture if (arrowTexture == null) { string guid = AssetDatabase.FindAssets("UIToolkitIconSegueArrow")[0]; string path = AssetDatabase.GUIDToAssetPath(guid); arrowTexture = (Texture2D)AssetDatabase.LoadMainAssetAtPath(path); } //draw arrow GUILayout.FlexibleSpace(); GUILayout.Box(arrowTexture, GUIStyle.none); GUILayout.FlexibleSpace(); //targetView Rect targetCellRect = EditorGUILayout.BeginVertical(GUILayout.MaxWidth(150)); EditorGUI.DrawRect(targetCellRect, ToolkitColor.shade); EditorGUILayout.Space(); EditorGUILayout.LabelField("Target view", GUILayout.Width(120)); segue.targetView = EditorGUILayout.ObjectField(segue.targetView, typeof(UIView), true) as UIView; //rename segue automatically when assigning target view if (segue.targetView != null) { if (segue.name != "segueTo" + segue.targetView.name) { segue.name = "segueTo" + segue.targetView.name; } } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(serializedObject.FindProperty("transitionType"), new GUIContent("Transition type"), false); segue.animatedTransition = EditorGUILayout.ToggleLeft("Animated transition", segue.animatedTransition); if (segue.animatedTransition) { EditorGUILayout.PropertyField(serializedObject.FindProperty("animatedTransitionType"), new GUIContent("Animation type"), false); } serializedObject.ApplyModifiedProperties(); }