// FLOAT EDITOR public static void drawFloatEditor(Rect container, DialogueEditorVariablesContainer variables) { bool isPro = EditorGUIUtility.isProSkin; Rect nameTextFieldRect = new Rect(container.x + 5 + 2, container.y + container.height - 22 - 5 - 2, container.width - 4 - 10, 22); if (isPro) { DialogueEditorGUI.drawHighlightRect(nameTextFieldRect, 1, 1); } else { GUI.Box(DialogueEditorGUI.getOutlineRect(nameTextFieldRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset")); } /* * if(Event.current.character == '.'){ * if(Regex.Matches(variables.variables[variables.selection].variable, ".").Count > 1){ * Event.current.character = '\0'; * } * } * variables.variables[variables.selection].variable = GUI.TextField(nameTextFieldRect, variables.variables[variables.selection].variable, largeTextFieldStyle()); * variables.variables[variables.selection].variable = Regex.Replace(variables.variables[variables.selection].variable, @"[^0-9.-]", ""); * for(int i=1; i<variables.variables[variables.selection].variable.Length; i+=1){ * if(variables.variables[variables.selection].variable[i] == '-'){ * variables.variables[variables.selection].variable = variables.variables[variables.selection].variable.Remove(i, 1); * } * } */ float floatVar; float.TryParse(variables.variables[variables.selection].variable, out floatVar); variables.variables[variables.selection].variable = EditorGUI.FloatField(nameTextFieldRect, floatVar, largeTextFieldStyle()).ToString(); }
public DialogueEditorDialogueObject(){ name = string.Empty; phases = new List<DialogueEditorPhaseObject>(); floats = new DialogueEditorVariablesContainer(); strings = new DialogueEditorVariablesContainer(); booleans = new DialogueEditorVariablesContainer(); }
public DialogueEditorDialogueObject() { name = string.Empty; phases = new List <DialogueEditorPhaseObject>(); floats = new DialogueEditorVariablesContainer(); strings = new DialogueEditorVariablesContainer(); booleans = new DialogueEditorVariablesContainer(); }
// STRING EDITOR public static void drawStringEditor(Rect container, DialogueEditorVariablesContainer variables) { bool isPro = EditorGUIUtility.isProSkin; Rect nameTextFieldRect = new Rect(container.x + 5 + 2, container.y + container.height - 22 - 5 - 2, container.width - 4 - 10, 22); if (isPro) { DialogueEditorGUI.drawHighlightRect(nameTextFieldRect, 1, 1); } else { GUI.Box(DialogueEditorGUI.getOutlineRect(nameTextFieldRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset")); } variables.variables[variables.selection].variable = GUI.TextField(nameTextFieldRect, variables.variables[variables.selection].variable, largeTextFieldStyle()); }
// BOOLEAN EDITOR public static void drawBooleanEditor(Rect container, DialogueEditorVariablesContainer variables) { Rect buttonRect = new Rect(container.x + 5, container.y + container.height - 22 - 5 - 3, container.width - 10, 22); Rect buttonLeftRect = new Rect(buttonRect.x, buttonRect.y, buttonRect.width * 0.5f, buttonRect.height); Rect buttonRightRect = new Rect(buttonRect.x + (buttonRect.width * 0.5f), buttonRect.y, buttonRect.width * 0.5f, buttonRect.height); if (GUI.Toggle(buttonLeftRect, (variables.variables[variables.selection].variable == "true"), "True", DialogueEditorGUI.gui.GetStyle("toolbar_left"))) { variables.variables[variables.selection].variable = "true"; } if (GUI.Toggle(buttonRightRect, (variables.variables[variables.selection].variable != "true"), "False", DialogueEditorGUI.gui.GetStyle("toolbar_right"))) { variables.variables[variables.selection].variable = "false"; } }
// VARIABLE EDITOR RE-USABLE GUI public static void drawEditorBase(Rect container, DialogueEditorVariablesContainer variables, VariableEditorScopes scope, VariableEditorTypes type) { bool isPro = EditorGUIUtility.isProSkin; int boxHeight = 63; string targetName = scope.ToString() + " " + type.ToString(); Rect topRect = new Rect(container.x, container.y, container.width, boxHeight); Rect bottomRect = new Rect(container.x, container.y + container.height - boxHeight, container.width, boxHeight); if (isPro) { DialogueEditorGUI.drawShadowedRect(topRect, 2); DialogueEditorGUI.drawShadowedRect(bottomRect, 2); } else { GUI.Box(topRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(bottomRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(topRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(bottomRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); } GUIStyle titleStyle = new GUIStyle("label"); titleStyle.fontStyle = FontStyle.Bold; titleStyle.padding = new RectOffset(5, titleStyle.padding.right, titleStyle.padding.top - 2, titleStyle.padding.bottom); titleStyle.alignment = TextAnchor.MiddleLeft; Rect topTitleRect = new Rect(topRect.x + 5, topRect.y + 5, topRect.width - 10, 22); if (isPro) { DialogueEditorGUI.drawShadowedRect(topTitleRect, 2); } else { GUI.Box(topTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(topTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); } GUI.Label(topTitleRect, targetName + " Name", titleStyle); Rect bottomTitleRect = new Rect(bottomRect.x + 5, bottomRect.y + 5, bottomRect.width - 10, 22); if (isPro) { DialogueEditorGUI.drawShadowedRect(bottomTitleRect, 2); } else { GUI.Box(bottomTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(bottomTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); } GUI.Label(bottomTitleRect, targetName + " Value", titleStyle); Rect nameTextFieldRect = new Rect(topTitleRect.x + 2, topTitleRect.y + topTitleRect.height + 5 + 1, topTitleRect.width - 4, 22); if (isPro) { DialogueEditorGUI.drawHighlightRect(nameTextFieldRect, 1, 1); } else { GUI.Box(DialogueEditorGUI.getOutlineRect(nameTextFieldRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset")); } variables.variables[variables.selection].name = GUI.TextField(nameTextFieldRect, variables.variables[variables.selection].name, largeTextFieldStyle()); }
// STRING EDITOR public static void drawStringEditor(Rect container, DialogueEditorVariablesContainer variables){ bool isPro = EditorGUIUtility.isProSkin; Rect nameTextFieldRect = new Rect(container.x + 5 + 2,container.y + container.height - 22 - 5 - 2 ,container.width - 4 - 10,22); if(isPro){ DialogueEditorGUI.drawHighlightRect(nameTextFieldRect, 1, 1); }else{ GUI.Box(DialogueEditorGUI.getOutlineRect(nameTextFieldRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset")); } variables.variables[variables.selection].variable = GUI.TextField(nameTextFieldRect, variables.variables[variables.selection].variable, largeTextFieldStyle()); }
// FLOAT EDITOR public static void drawFloatEditor(Rect container, DialogueEditorVariablesContainer variables){ bool isPro = EditorGUIUtility.isProSkin; Rect nameTextFieldRect = new Rect(container.x + 5 + 2,container.y + container.height - 22 - 5 - 2 ,container.width - 4 - 10,22); if(isPro){ DialogueEditorGUI.drawHighlightRect(nameTextFieldRect, 1, 1); }else{ GUI.Box(DialogueEditorGUI.getOutlineRect(nameTextFieldRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset")); } /* if(Event.current.character == '.'){ if(Regex.Matches(variables.variables[variables.selection].variable, ".").Count > 1){ Event.current.character = '\0'; } } variables.variables[variables.selection].variable = GUI.TextField(nameTextFieldRect, variables.variables[variables.selection].variable, largeTextFieldStyle()); variables.variables[variables.selection].variable = Regex.Replace(variables.variables[variables.selection].variable, @"[^0-9.-]", ""); for(int i=1; i<variables.variables[variables.selection].variable.Length; i+=1){ if(variables.variables[variables.selection].variable[i] == '-'){ variables.variables[variables.selection].variable = variables.variables[variables.selection].variable.Remove(i, 1); } } */ float floatVar; float.TryParse(variables.variables[variables.selection].variable, out floatVar); variables.variables[variables.selection].variable = EditorGUI.FloatField(nameTextFieldRect, floatVar, largeTextFieldStyle()).ToString(); }
// BOOLEAN EDITOR public static void drawBooleanEditor(Rect container, DialogueEditorVariablesContainer variables){ Rect buttonRect = new Rect(container.x + 5, container.y + container.height - 22 - 5 - 3, container.width - 10, 22); Rect buttonLeftRect = new Rect(buttonRect.x, buttonRect.y,buttonRect.width * 0.5f,buttonRect.height); Rect buttonRightRect = new Rect(buttonRect.x + (buttonRect.width * 0.5f), buttonRect.y,buttonRect.width * 0.5f,buttonRect.height); if(GUI.Toggle(buttonLeftRect, (variables.variables[variables.selection].variable == "true"), "True", DialogueEditorGUI.gui.GetStyle("toolbar_left"))) variables.variables[variables.selection].variable = "true"; if(GUI.Toggle(buttonRightRect, (variables.variables[variables.selection].variable != "true"), "False", DialogueEditorGUI.gui.GetStyle("toolbar_right"))) variables.variables[variables.selection].variable = "false"; }
// VARIABLE EDITOR RE-USABLE GUI public static void drawEditorBase(Rect container, DialogueEditorVariablesContainer variables, VariableEditorScopes scope, VariableEditorTypes type){ bool isPro = EditorGUIUtility.isProSkin; int boxHeight = 63; string targetName = scope.ToString() + " " + type.ToString(); Rect topRect = new Rect(container.x, container.y, container.width, boxHeight); Rect bottomRect = new Rect(container.x, container.y + container.height - boxHeight, container.width, boxHeight); if(isPro){ DialogueEditorGUI.drawShadowedRect(topRect, 2); DialogueEditorGUI.drawShadowedRect(bottomRect, 2); }else{ GUI.Box(topRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(bottomRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(topRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(bottomRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); } GUIStyle titleStyle = new GUIStyle("label"); titleStyle.fontStyle = FontStyle.Bold; titleStyle.padding = new RectOffset(5, titleStyle.padding.right, titleStyle.padding.top - 2, titleStyle.padding.bottom); titleStyle.alignment = TextAnchor.MiddleLeft; Rect topTitleRect = new Rect(topRect.x + 5, topRect.y + 5, topRect.width - 10, 22); if(isPro){ DialogueEditorGUI.drawShadowedRect(topTitleRect, 2); }else{ GUI.Box(topTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(topTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); } GUI.Label(topTitleRect, targetName + " Name", titleStyle); Rect bottomTitleRect = new Rect(bottomRect.x + 5, bottomRect.y + 5, bottomRect.width - 10, 22); if(isPro){ DialogueEditorGUI.drawShadowedRect(bottomTitleRect, 2); }else{ GUI.Box(bottomTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); GUI.Box(bottomTitleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset")); } GUI.Label(bottomTitleRect, targetName + " Value", titleStyle); Rect nameTextFieldRect = new Rect(topTitleRect.x + 2,topTitleRect.y + topTitleRect.height + 5 + 1,topTitleRect.width - 4,22); if(isPro){ DialogueEditorGUI.drawHighlightRect(nameTextFieldRect, 1, 1); }else{ GUI.Box(DialogueEditorGUI.getOutlineRect(nameTextFieldRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset")); } variables.variables[variables.selection].name = GUI.TextField(nameTextFieldRect, variables.variables[variables.selection].name, largeTextFieldStyle()); }
public DialogueEditorGlobalVariablesContainer() { booleans = new DialogueEditorVariablesContainer(); floats = new DialogueEditorVariablesContainer(); strings = new DialogueEditorVariablesContainer(); }
public DialogueEditorGlobalVariablesContainer(){ booleans = new DialogueEditorVariablesContainer(); floats = new DialogueEditorVariablesContainer(); strings = new DialogueEditorVariablesContainer(); }