public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { progressBarAttribute = (attribute as ProgressBarAttribute); switch (property.propertyType) { case SerializedPropertyType.Integer: property.intValue = (int)EditorGUIExtension.ProgressBar(position, property.intValue, progressBarAttribute.min, progressBarAttribute.max, string.Concat(property.intValue.ToString(), "(", property.displayName, ")") , true, progressBarAttribute.drawMinMaxValue); break; case SerializedPropertyType.Float: property.floatValue = EditorGUIExtension.ProgressBar(position, property.floatValue, progressBarAttribute.min, progressBarAttribute.max, string.Concat(property.floatValue.ToString("0.00"), "(", "property.displayName", ")"), true, progressBarAttribute.drawMinMaxValue); break; default: break; } }
protected override void onGUI() { PortalExecution myTarget = (PortalExecution)target; EditorGUIExtension.SimpleBox("", 5, "", delegate() { // IS INPUT if (_outputPortals.Count > 0) { myTarget.IsInput = InputToggle(myTarget.IsInput); } else { EditorGUILayout.Toggle("Is Input", myTarget.IsInput); EditorGUILayout.HelpBox("You can't set this node to Input," + "You need at least one output execution portal in the graph", MessageType.Info); } // PORTAL NAME if (myTarget.IsInput) { if (_portalNames.Draw("Portal Name")) { // Set the connected portal. myTarget.OutputPortal = _outputPortals[_portalNames.Index]; } } else { myTarget.PortalName = PortalNameField(myTarget.PortalName); } }); }
//Draw a preview Gizmo, if showPreview is enabled //For int and float, a disc for the min and max values is drawn //For vector3, a box for each min and max value is drawn #if UNITY_EDITOR public override void DrawEditorGizmos() { if (component != null && showPreview) { if (IsSelectedOfType(typeof(int))) { EditorGUIExtension.RadiusDisc(transform.position, minIntVal, Color.red); EditorGUIExtension.RadiusDisc(transform.position, maxIntVal, Color.green); } else if (IsSelectedOfType(typeof(Single))) { EditorGUIExtension.RadiusDisc(transform.position, minFloatVal, Color.red); EditorGUIExtension.RadiusDisc(transform.position, maxFloatVal, Color.green); } else if (IsSelectedOfType(typeof(Vector3))) { EditorGUIExtension.DrawPreviewCube(transform.position, minVec3Val, Color.red); EditorGUIExtension.DrawPreviewCube(transform.position, maxVec3Val, Color.green); } else if (IsSelectedOfType(typeof(Vector2))) { EditorGUIExtension.AreaRect(minVec2Val, transform.position, Color.red); EditorGUIExtension.AreaRect(maxVec2Val, transform.position, Color.green); } } }
private static void Show(DetailNode obj, Action beforeProperties = null) { //General NodeEditorGUILayout.PortField(obj.GetInputPort("Constraint")); NodeEditorGUILayout.PortField(obj.GetInputPort("Modifier")); obj.DistributionType = (DetailNode.Distribution)EditorGUILayout.EnumPopup("Distribution", obj.DistributionType); if (obj.DistributionType == DetailNode.Distribution.PoissonDisc) { obj.Spread = EditorGUIExtension.MinMaxFloatField("Spread", obj.Spread, 1f, 50f); } else { obj.UniformResolution = EditorGUIExtension.MinMaxIntField("Resolution", obj.UniformResolution, 2, 1024); } obj.MaxObjects = EditorGUILayout.IntField("Max Objects", obj.MaxObjects); if (beforeProperties != null) { beforeProperties(); } EditorGUIExtension.DrawMinMax("Width Scale", ref obj.WidthScale.x, ref obj.WidthScale.y); EditorGUIExtension.DrawMinMax("Height Scale", ref obj.HeightScale.x, ref obj.HeightScale.y); if (obj.MaxObjects < 1) { obj.MaxObjects = 1; } }
void AnswerSettings() { if (myTarget.UIType == DialogueUIType.AmbientDialogue) { return; } EditorGUIExtension.SimpleBox("Answers", 5, "", delegate() { DrawPropertyField("DynamicAnswerNumber", "Dynamicaly Expand"); EditorGUILayout.HelpBox("If Dynamicaly Expand is turned on, " + "in runtime the system will generate additional answer buttons" + "if there is more answer in the text node than button in the ui skin.", MessageType.Info); DrawPropertyField("answerKeyBinding", "Bind Key to Answer"); switch (myTarget.answerKeyBinding) { case DialogueSystemUISkin.AnswerKeyBinding.Alphanumeric1To9: EditorGUILayout.HelpBox("In runtime the system will bind alphanumeric keys to the answers based on their order. Only handles up 9 answers.", MessageType.Info); break; case DialogueSystemUISkin.AnswerKeyBinding.FirstOnly: EditorGUILayout.HelpBox("In runtime the system will bind the below key to the first answer. Great for next or skip type of answers.", MessageType.Info); DrawPropertyField("FirstOnlyKey", "Key"); break; } }); }
public static Vector3 DirectionHandleVec(Vector3 position, float sizeFactor, Vector3 initialDir, Vector3 axis) { if (axis.x == 1f && EditorGUIExtension.DirectionHandle(position, Vector3.right, sizeFactor, Color.red)) { return(Vector3.right); } else if (axis.y == 1f && EditorGUIExtension.DirectionHandle(position, Vector3.up, sizeFactor, Color.green)) { return(Vector3.up); } else if (axis.z == 1f && EditorGUIExtension.DirectionHandle(position, Vector3.forward, sizeFactor, Color.blue)) { return(Vector3.forward); } else if (axis.x == 1f && EditorGUIExtension.DirectionHandle(position, Vector3.left, sizeFactor, Color.red)) { return(Vector3.left); } else if (axis.y == 1f && EditorGUIExtension.DirectionHandle(position, Vector3.down, sizeFactor, Color.green)) { return(Vector3.down); } else if (axis.z == 1f && EditorGUIExtension.DirectionHandle(position, Vector3.back, sizeFactor, Color.blue)) { return(Vector3.back); } return(initialDir); }
public static void OnInspectorGUI(Rect rect, Variable variable) { EditorGUIExtension.SimpleBox(rect, "", 5, "", delegate(Rect dRect) { if (variable != null) { Rect r = dRect; r.x += 5; r.width -= 10; r.height = 20; variable.Name = EditorGUI.TextField(r, "Name", variable.Name); r.y += 30; variable.Group = EditorGUI.TextField(r, "Group", variable.Group); r.y += 30; r.y += 5; variable.DefaultValue.Value = EditorGUIExtension.SmartField(r, "Default Value", variable.type, variable.DefaultValue.Value); r.y += 30; variable.Save = EditorGUI.Toggle(r, "Save", variable.Save); } }); }
public void OnSceneGUI() { if (SceneUpdater.IsActive) { float sizeFactor = HandleUtility.GetHandleSize(stickTo.transform.position) * .7f; stickTo.stickDirection = EditorGUIExtension.DirectionHandleVec(stickTo.transform.position, sizeFactor, stickTo.stickDirection, Vector3.one); } }
private void OnGUI() { EditorGUILayout.PropertyField(serializedObject.FindProperty("objects")); UnityObject obj = EditorGUILayoutExtension.DragDropAreaSingle(GUILayout.Height(50)); GUI.Box(GUILayoutUtility.GetLastRect(), "使用GUILayout方式绘制接收单个资源区域,无需指定Rect", "GroupBox"); if (obj != null) { objects.Add(obj); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } Rect r = GUILayoutUtility.GetRect(50, 50); GUI.Box(r, "使用GUI方式绘制接收单个资源区域,需指定Rect", "GroupBox"); obj = EditorGUIExtension.DragDropAreaSingle(r); if (obj != null) { objects.Add(obj); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } r = GUILayoutUtility.GetRect(50, 50); GUI.Box(r, "使用GUI方式绘制接收单个资源区域,需指定Rect,自定义高亮色", "GroupBox"); obj = EditorGUIExtension.DragDropAreaSingle(r, Color.black); if (obj != null) { objects.Add(obj); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } r = GUILayoutUtility.GetRect(50, 50); GUI.Box(r, "使用GUI方式绘制接收单个资源区域,需指定Rect,自定义鼠标指针", "GroupBox"); obj = EditorGUIExtension.DragDropAreaSingle(r, DragAndDropVisualMode.Link); if (obj != null) { objects.Add(obj); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } r = GUILayoutUtility.GetRect(50, 50); GUI.Box(r, "使用GUI方式绘制接收多个个资源区域,需指定Rect,自定义高亮色和鼠标指针", "GroupBox"); UnityObject[] objs = EditorGUIExtension.DragDropAreaMulti(r, DragAndDropVisualMode.Link, new Color(0.3f, 0.58f, 0.7f, 0.3f)); if (objs != null) { foreach (var item in objs) { objects.Add(item); } serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } }
protected override void onGUI() { Operator myTarget = (Operator)target; EditorGUIExtension.SimpleBox("", 5, "", delegate() { myTarget.OperatorMode = (Operator.Mode)EditorGUILayout.EnumPopup("Operator", myTarget.OperatorMode); }); }
protected override void onGUI() { Logical myTarget = (Logical)target; EditorGUIExtension.SimpleBox("", 5, "", delegate() { myTarget.LogicalMode = (Logical.Mode)EditorGUILayout.EnumPopup("Logical", myTarget.LogicalMode); }); }
public void GetRects(Rect rect, float splitterWidth, float leftMinWidth, float rightMinWidth, out Rect left, out Rect right) { EditorGUIExtension.DrawSplitter(new Rect(rect.x + m_LeftWidth, rect.y, SplitterLineWidth, rect.height)); Rect dragRect = new Rect(rect.x + m_LeftWidth, rect.y, splitterWidth, rect.height); Rect newRect = EditorGUIExtension.HandleHorizontalSplitter(dragRect, rect.width, leftMinWidth, rightMinWidth); m_LeftWidth = newRect.x; left = new Rect(rect.x, rect.y, m_LeftWidth, rect.height); right = new Rect(left.xMax, rect.y, rect.width - left.width, rect.height); }
protected override void onGUI() { UIElementTimer myTarget = (UIElementTimer)target; EditorGUIExtension.SimpleBox("UI Elements", 5, "", delegate() { DrawPropertyField("Slider"); DrawPropertyField("Label", "Text"); }); }
private void DrawSerialziedVaraibles(SerializedProperty property) { EditorGUIExtension.SetFoldoutBool(property.displayName, EditorGUILayout.BeginFoldoutHeaderGroup(EditorGUIExtension.GetFoldoutBool(property.displayName, false), property.displayName)); if (EditorGUIExtension.GetFoldoutBool(property.displayName)) { GUILayout.TextArea(property.stringValue, EditorStyles.wordWrappedLabel); } EditorGUILayout.EndFoldoutHeaderGroup(); }
public override void OnInspectorGUI() { GUILayout.Label(_logo); VisualEditorBehaviour myTarget = (VisualEditorBehaviour)target; myTarget.Graph = (FunctionGraph)EditorGUILayout.ObjectField(new GUIContent(graphLabel), myTarget.Graph, typeof(FunctionGraph), false); myTarget.isDisabled = EditorGUILayout.Toggle("Is Disabled", myTarget.isDisabled); EditorGUIExtension.HorizontalLine(EditorGUIUtility.currentViewWidth); }
protected override void onGUI() { EditorGUIExtension.SimpleBox("UI Elements", 5, "", delegate() { DrawGUI(); }); EditorGUIExtension.SimpleBox("Key Binding", 5, "", delegate() { DrawPropertyField("Key"); }); }
void AmbientDetails() { // BARKING EditorGUIExtension.FoldoutBox("Ambient Dialogue (Barking)", ref myTarget.BarkFoldout, (myTarget.AmbientDialogue.Enabled) ? 1 : 0, delegate() { EditorGUI.indentLevel--; DrawPropertyField("AmbientDialogue.Enabled", "Enable"); var prop = GetProperty("AmbientDialogue.Enabled"); if (prop.boolValue) { EditorGUILayout.Space(); DrawPropertyField("AmbientDialogue.Once", new GUIContent("Once", "If this option is turned on, the ambient dialogue only appears once when it's triggered")); if (!myTarget.AmbientDialogue.Once) { DrawPropertyField("AmbientDialogue.Time", new GUIContent("Time", "The ambient dialogue will activate after this amount of seconds (if not active currently)")); } EditorGUILayout.Space(); DrawPropertyField("AmbientDialogue.Trigger.Mode", "Trigger"); EditorGUI.indentLevel++; // Player Tag if (myTarget.AmbientDialogue.Trigger.Mode == Trigger.Modes.TriggerEnter || myTarget.AmbientDialogue.Trigger.Mode == Trigger.Modes.Use) { DrawPropertyField("AmbientDialogue.Trigger.PlayerTag", "Player Tag"); } // Distance if (myTarget.AmbientDialogue.Trigger.Mode == Trigger.Modes.Use) { DrawPropertyField("AmbientDialogue.Trigger.Distance", "Distance"); } if (myTarget.AmbientDialogue.Trigger.Mode == Trigger.Modes.Custom) { EditorGUILayout.HelpBox("You can call the StartBark() method from script directly.", MessageType.Info); } EditorGUI.indentLevel--; // OFFSET EditorGUILayout.Space(); DrawPropertyField("AmbientDialogue.Offset", new GUIContent("Offset", "The offset position for the ambient dialogue ui.")); EditorGUILayout.Space(); // +Culling } EditorGUI.indentLevel++; }); EditorGUILayout.Space(); }
void OnPathSettingView() { GUILayout.Space(10f); //场景打包路径 if (needPackageScene) { var scenePath = EditorGUIExtension.FolderSelector("Scene Directory :", rawScenePath); if (string.IsNullOrEmpty(scenePath)) { rawScenePath = ""; } else { var index = scenePath.IndexOf("Assets"); var length = scenePath.Length; rawScenePath = scenePath.Substring(index, length - index); } } GUILayout.Space(10f); //代码打包路径 var codePath = EditorGUIExtension.FolderSelector("Code Directory :", rawCodePath); if (string.IsNullOrEmpty(codePath)) { rawCodePath = ""; } else { var index = codePath.IndexOf("Assets"); var length = codePath.Length; rawCodePath = codePath.Substring(index, length - index); } GUILayout.Space(10f); //DataTable打包路径 var tablePath = EditorGUIExtension.FolderSelector("DataTable Directory :", rawDataTablePath); if (string.IsNullOrEmpty(codePath)) { rawDataTablePath = ""; } else { var index = tablePath.IndexOf("Assets"); var length = tablePath.Length; rawDataTablePath = tablePath.Substring(index, length - index); } GUILayout.Space(10f); }
public override void OnInspectorGUI() { EditorGUIExtension.DrawScriptBox(this); serializedObject.Update(); EditorGUILayout.PropertyField(name); EditorGUILayout.PropertyField(xP); EditorGUILayout.PropertyField(zP); EditorGUILayout.PropertyField(xS); EditorGUILayout.PropertyField(zS); EditorGUILayout.PropertyField(navigable); exceptionsList.Draw(); connectionsLight.Draw(); serializedObject.ApplyModifiedProperties(); }
protected override void onGUI() { Relation myTarget = (Relation)target; EditorGUIExtension.SimpleBox("", 5, "", delegate() { var rm = myTarget.RelationMode; myTarget.RelationMode = (Relation.Mode)EditorGUILayout.EnumPopup("Relation", myTarget.RelationMode); if (rm != myTarget.RelationMode) { ResetTypePopup(); } }); }
void ExternalEvents() { EditorGUIExtension.FoldoutBox("External Events " + ((myTarget.ExternalEventEnable) ? "[" + myTarget.Events.Count + "]" : ""), ref myTarget.ExternalEventFoldout, (myTarget.ExternalEventEnable) ? 1 : 0, delegate() { EditorGUI.indentLevel--; DrawPropertyField("ExternalEventEnable", "Enable"); var prop = GetProperty("ExternalEventEnable"); if (prop.boolValue) { EditorGUILayout.Space(); for (int cnt = 0; cnt < myTarget.Events.Count; cnt++) { var element = serializedObject.FindProperty("Events").GetArrayElementAtIndex(cnt); EditorGUIExtension.SimpleBox("", 5, "ShurikenModuleBG", delegate() { EditorGUILayout.BeginHorizontal(); var eventNameProp = element.FindPropertyRelative("EventName"); DrawPropertyField(eventNameProp, new GUIContent("Event Name", "This is the name you want to call from the graph")); //myTarget.Events[cnt].EventName = EditorGUILayout.TextField(new GUIContent("Event Name", "This is the name you want to call from the graph"), myTarget.Events[cnt].EventName); if (GUILayout.Button("X", GUILayout.Width(20))) { Undo.RecordObject(myTarget, "Removed External Event"); myTarget.Events.RemoveAt(cnt); PrefabUtility.RecordPrefabInstancePropertyModifications(myTarget); return; } EditorGUILayout.EndHorizontal(); var eventProperty = element.FindPropertyRelative("uEvent"); DrawPropertyField(eventProperty, new GUIContent("Event: " + myTarget.Events[cnt].EventName)); }); GUILayout.Space(10); } if (GUILayout.Button("Add Event")) { Undo.RecordObject(myTarget, "Added External Event"); myTarget.Events.Add(new DialogueBehaviour.ExternalEvent()); PrefabUtility.RecordPrefabInstancePropertyModifications(myTarget); Repaint(); } } }); EditorGUILayout.Space(); }
public override void OnInspectorGUI() { Node myTarget = (Node)target; EditorGUI.BeginChangeCheck(); if (myTarget is INodeCollection || NameEditable) { EditorGUIExtension.SimpleBox("", 5, "", delegate() { myTarget.Name = EditorGUILayout.TextField("Name", myTarget.Name); }); } else if (myTarget is ITypedNode) { ITypedNode t = (ITypedNode)myTarget; EditorGUIExtension.SimpleBox("", 5, "", delegate() { if (_typePopup == null) { int index = 0; List <string> names = new List <string>(); for (int cnt = 0; cnt < t.AllowedTypes.Count; cnt++) { if (t.Type == t.AllowedTypes[cnt]) { index = cnt; } names.Add(TypeUtils.GetPrettyName(t.AllowedTypes[cnt])); } _typePopup = new SmartPopup(names, index); } if (_typePopup.Draw("Value Type")) { t.Type = t.AllowedTypes[_typePopup.Index]; } }); } EditorGUILayout.Space(); onGUI(); if (EditorGUI.EndChangeCheck()) { myTarget.HasChanges = true; } }
public override void OnBodyGUI() { NodeEditorGUILayout.PortField(_scatter.GetOutputPort("Output")); NodeEditorGUILayout.PortField(_scatter.GetInputPort("DetailNode")); //Object count min max EditorGUI.BeginChangeCheck(); EditorGUIExtension.DrawMinMax("Distance", ref _scatter.DistanceMin, ref _scatter.DistanceMax); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } }
protected override void onGUI() { RandomNode myTarget = (RandomNode)target; EditorGUIExtension.SimpleBox("", 5, "", delegate() { var min = myTarget.Variables.GetByName("Min"); var max = myTarget.Variables.GetByName("Max"); VariableEditor.VariableField(min, null, true); VariableEditor.VariableField(max, null, true); }); EditorGUILayout.Space(); }
void ActorDetails() { EditorGUIExtension.SimpleBox("UI Elements", 5, "", delegate() { DrawPropertyField("ActorText", "Text"); GUILayout.Space(10); DrawPropertyFieldWithToggle("ActorName", "UseActorName"); DrawPropertyFieldWithToggle("ActorPortrait", "UseActorPortrait"); if (myTarget.UIType != DialogueUIType.AmbientDialogue) { DrawPropertyFieldWithToggle("Timer", "UseTimer"); } }); }
/// <summary> /// Displays a toggleable toolbar with icons from /// the file system /// </summary> public void Toolbar() { EditorGUILayout.Space(); //Set toolbar images if (_toolbarImages == null) { _toolbarImages = new Texture[] { (Texture)Resources.Load("terra_gui_wrench"), (Texture)Resources.Load("terra_gui_map"), (Texture)Resources.Load("terra_gui_biome"), (Texture)Resources.Load("terra_gui_detail") }; } _config.EditorState.ToolbarSelection = (ToolbarOptions)EditorGUIExtension.EnumToolbar(_config.EditorState.ToolbarSelection, _toolbarImages); }
/// <summary> /// Displays a toggleable toolbar with icons from /// the file system /// </summary> public void Toolbar() { EditorGUILayout.Space(); //Set toolbar images if (ToolbarImages == null) { ToolbarImages = new Texture[] { (Texture)Resources.Load("terra_gui_general"), (Texture)Resources.Load("terra_gui_noise"), (Texture)Resources.Load("terra_gui_material"), (Texture)Resources.Load("terra_gui_object") }; } Settings.ToolbarSelection = (TerraSettings.ToolbarOptions)EditorGUIExtension.EnumToolbar(Settings.ToolbarSelection, ToolbarImages); }
public void OnSceneGUI() { Vector3 pos = aPosition.transform.position; float sizeFactor = HandleUtility.GetHandleSize(pos) * 0.7f; if (EditorGUIExtension.DirectionHandle(pos, Vector3.right, sizeFactor, Color.red)) { aPosition.direction = Vector3.right; } else if (EditorGUIExtension.DirectionHandle(pos, Vector3.up, sizeFactor, Color.green)) { aPosition.direction = Vector3.up; } else if (EditorGUIExtension.DirectionHandle(pos, Vector3.forward, sizeFactor, Color.blue)) { aPosition.direction = Vector3.forward; } }
void ActorDetails() { EditorGUIExtension.FoldoutBox("Actor", ref myTarget.ActorFoldout, (myTarget.ActorEnabled) ? 1 : 0, delegate() { EditorGUI.indentLevel--; DrawPropertyField("ActorEnabled", "Enable"); var prop = GetProperty("ActorEnabled"); if (prop.boolValue) { GUIContent label = new GUIContent("Actor Name", "The dialogue system will use this name as Actor name. If it's not set, the name will be the name of the GameObject."); DrawPropertyField("ActorName", label); DrawPropertyField("ActorPortrait", "Portrait"); } EditorGUI.indentLevel++; }); EditorGUILayout.Space(); }
void OnGUI() { GUILayout.Space(10f); PackagePlatform.platformCurrent = (PackagePlatform.PlatformType)EditorGUIExtension.EnumToolbar(PackagePlatform.platformCurrent); OnOptionsView(); OnPathSettingView(); GUILayout.Space(20f); if (GUILayout.Button("Package", GUILayout.Width(370))) { EditorApplication.delayCall += Package; Close(); } GUILayout.Space(10f); }