Get a named GUIStyle.
public void drawShelfGroup(Event e, float yCoord, int shelfGroupIndex, Rect viewRect, NodeGraph currentNodeGraph, GUISkin viewSkin) { if (isExpanded) { groupRect = new Rect(5f, yCoord, viewRect.width - 10f, getHeight()); GUI.Box(groupRect, groupName, viewSkin.GetStyle(("shelf_group_bg"))); int hiddenNodes = 0; for (int i = 0; i < shelfNodes.Count; i++) { if (!shelfNodes[i].isHidden) { shelfNodes[i].shelfNodeRect = new Rect(10f, yCoord + 40f + (50f * (i - hiddenNodes)), viewRect.width - 20f, 40f); shelfNodes[i].drawNodeShelfGroupNode(e, yCoord, viewSkin); } else { hiddenNodes++; } } } else { groupRect = new Rect(5f, yCoord, viewRect.width - 10f, 40f); GUI.Box(groupRect, groupName, viewSkin.GetStyle(("shelf_group_bg"))); } ProcessEvent(e, currentNodeGraph); }
public void DrawDragButton(Event e, Rect nodeRect, GUISkin guiSkin) { leftButtonRect = new Rect(nodeRect.x, nodeRect.y + nodeRect.height, 30f, 30f); middleButtonRect = new Rect(nodeRect.x + nodeRect.width * 0.5f - 15f, nodeRect.y + nodeRect.height, 30f, 30f); rightButtonRect = new Rect(nodeRect.x + nodeRect.width - 30f, nodeRect.y + nodeRect.height, 30f, 30f); GUI.Box(leftButtonRect, "", guiSkin.GetStyle("node_default")); GUI.Box(rightButtonRect, "", guiSkin.GetStyle("node_default")); GUI.Box(middleButtonRect, "", guiSkin.GetStyle("node_default")); }
void OnGUI() { UnityEngine.GUI.skin = guiskin; if (startTime <= 5) { guiskin.GetStyle("Timer").normal.textColor = warningColorTime; } else { guiskin.GetStyle("Timer").normal.textColor = defaultColorTime; } UnityEngine.GUI.Label(timerRect, currentTime, guiskin.GetStyle("Timer")); UnityEngine.GUI.Label(new Rect(45, 100, 200, 200), tokenCount.ToString() + " / " + totalTokensCount.ToString()); UnityEngine.GUI.Label(new Rect(20, 10, Screen.width, Screen.height), "Current Score: " + PlayerPrefs.GetInt("Score") + " " + "HighScore: " + PlayerPrefs.GetInt("HighScore") + " " + "Deaths: " + PlayerPrefs.GetInt("Deaths") + " " + "Current Level: " + CurrLevell); }
void InitFromRemoteData() { if (!RemoteData.DataValid) { // Подождать загрузки данных RemoteData.AllComplete += InitFromRemoteData; return; } //Иначе данные уже загрузить, можно отписаться и проинициализароваться RemoteData.AllComplete -= InitFromRemoteData; // Инициализация объектов данными из удаленного источника и отписка: _skin = RemoteData.RequiredAssets["MenuSkin"].obj as GUISkin; _welcomLabel = _skin.GetStyle("Header"); }
static public int GetStyle(IntPtr l) { try { UnityEngine.GUISkin self = (UnityEngine.GUISkin)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GetStyle(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public override void UpdateNodeGUI(Event e, Rect viewRect, Rect workViewRect, GUISkin guiSkin) { base.UpdateNodeGUI(e, viewRect, workViewRect, guiSkin); stringToEdit = GUI.TextField(new Rect(nodeRect.x + nodeRect.width * 0.5f + 8f, nodeRect.y + nodeRect.height * 0.5f - 10f, nodeRect.width * 0.4f, 20f), nodeValue.ToString(), 25); try { nodeValue = float.Parse(stringToEdit); // TODO handle Exception from Bad Input }catch(FormatException ex){ } if (GUI.Button(new Rect(nodeRect.x + nodeRect.width - 10f, nodeRect.y + nodeRect.height * 0.5f - 10f, 20f, 20f), "", guiSkin.GetStyle("node_output"))) { if (parentGraph != null) { parentGraph.wantsConnection = true; parentGraph.connectionNode = this; } } }
public PauseScreen( GUISkin Skin, SpriteRenderer BackgroundRenderer, PauseMenu PauseMenu) : base(Skin, BackgroundRenderer, PauseMenu) { activeButton = MenuButton.Resume; unselectedButtonMap = new Dictionary<MenuButton, Texture2D>(); selectedButtonMap = new Dictionary<MenuButton, Texture2D>(); styleMap = new Dictionary<MenuButton, GUIStyle> (); rectMap = new Dictionary<MenuButton, Rect> (); unselectedButtonMap.Add( MenuButton.Resume , Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseResumeUnselected" ) ); unselectedButtonMap.Add( MenuButton.Restart , Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseRestartUnselected" ) ); unselectedButtonMap.Add( MenuButton.Instructions , Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseinstructionsUnselected" ) ); unselectedButtonMap.Add( MenuButton.QuitToMainMenu, Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseQuitUnselected" ) ); selectedButtonMap.Add( MenuButton.Resume , Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseResumeSelected" ) ); selectedButtonMap.Add( MenuButton.Restart , Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseRestartSelected" ) ); selectedButtonMap.Add( MenuButton.Instructions , Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseinstructionsSelected" ) ); selectedButtonMap.Add( MenuButton.QuitToMainMenu, Resources.Load<Texture2D>( "Sprites/GUI/PauseScreen/pauseQuitSelected" ) ); styleMap.Add( MenuButton.Resume , Skin.GetStyle("Pause-Resume" ) ); styleMap.Add( MenuButton.Restart , Skin.GetStyle("Pause-Restart" ) ); styleMap.Add( MenuButton.Instructions , Skin.GetStyle("Pause-Instructions") ); styleMap.Add( MenuButton.QuitToMainMenu, Skin.GetStyle("Pause-QuitToMenu" ) ); rectMap.Add( MenuButton.Resume , new Rect( 303, 207, 250, 75 ) ); rectMap.Add( MenuButton.Restart , new Rect( 303, 300, 250, 75 ) ); rectMap.Add( MenuButton.Instructions , new Rect( 275, 400, 325, 75 ) ); rectMap.Add( MenuButton.QuitToMainMenu, new Rect( 240, 500, 400, 75 ) ); Background = Resources.Load<Sprite>( "Sprites/GUI/Menu/mainMenu-home" ); styleMap[ activeButton ].normal.background = selectedButtonMap[ activeButton ]; }
//Draws the Inputhandles of the Node (Leftside Red Handles) public void drawInputHandles(GUISkin guiSkin) { if (multiInput) { //Multi Input Box if (GUI.Button(new Rect(nodeRect.x - 24f, nodeRect.y + ((nodeRect.height + 25f) * 0.5f) - 25f, 24f, 50f), "", guiSkin.GetStyle("node_multiInput"))) { if (parentGraph != null) { if (parentGraph.wantsConnection) { if (parentGraph.connectionOutputList != null) { for (int i = 0; i < parentGraph.connectionOutputList.Count; i++) { bool needsExpanding = true; for (int k = 0; k < nodeInputs.Count; k++) { if (parentGraph.connectionOutputList[i].outputNode == this) { Debug.Log("Connection impossible"); return; } if (nodeInputs[k].inputNode == null && nodeInputs[k].isOccupied == false) { nodeInputs[k].inputNode = parentGraph.connectionOutputList[i].outputNode; nodeInputs[k].isOccupied = nodeInputs[k].inputNode != null; //experimental nodeInputs[k].outputPos = parentGraph.connectionOutputList[i].position; nodeInputs[k].inputNode.nodeOutputs[nodeInputs[k].outputPos].connectedToNode = this; parentGraph.connectionOutputList[i].connectedToNode = this; //experimental Debug.Log("Connected at: " + k); needsExpanding = false; break; } else { needsExpanding = true; } } if (numberOfInputs < nodeInputsMax && needsExpanding) { int t = nodeInputs.Count; numberOfInputs = t + 1; nodeInputs.Add(new NodeInput()); nodeInputs[t].inputNode = parentGraph.connectionOutputList[i].outputNode; nodeInputs[t].isOccupied = nodeInputs[t].inputNode != null; nodeInputs[t].outputPos = parentGraph.connectionOutputList[i].position; nodeInputs[t].inputNode.nodeOutputs[nodeInputs[t].outputPos].connectedToNode = this; parentGraph.connectionOutputList[i].connectedToNode = this; Debug.Log("Increased Input and Connected"); } } parentGraph.wantsConnection = false; parentGraph.connectionNode = null; parentGraph.connectionOutputList = null; } else { for (int k = 0; k < nodeInputs.Count; k++) { if (parentGraph.connectionOutput.outputNode == this) { Debug.Log("Connection impossible"); return; } if (nodeInputs[k].inputNode == null && nodeInputs[k].isOccupied == false) { nodeInputs[k].inputNode = parentGraph.connectionOutput.outputNode; nodeInputs[k].isOccupied = nodeInputs[k].inputNode != null; nodeInputs[k].outputPos = parentGraph.connectionOutput.position; nodeInputs[k].inputNode.nodeOutputs[nodeInputs[k].outputPos].connectedToNode = this; parentGraph.connectionOutput.connectedToNode = this; parentGraph.wantsConnection = false; parentGraph.connectionNode = null; Debug.Log("Connected at: " + k); return; } } if (numberOfInputs < nodeInputsMax) { int i = nodeInputs.Count; numberOfInputs = i + 1; nodeInputs.Add(new NodeInput()); nodeInputs[i].inputNode = parentGraph.connectionNode; nodeInputs[i].isOccupied = nodeInputs[i].inputNode != null; nodeInputs[i].outputPos = parentGraph.connectionOutput.position; nodeInputs[i].inputNode.nodeOutputs[nodeInputs[i].outputPos].connectedToNode = this; parentGraph.connectionOutput.connectedToNode = this; Debug.Log("Increased Input and Connected"); } parentGraph.wantsConnection = false; parentGraph.connectionNode = null; } } else // remove all Inputs { Debug.Log("Removing MultiInput"); foreach (NodeInput input in nodeInputs) { input.getConnectedOutput().connectedToNode = null; input.outputPos = -1; input.inputNode = null; input.isOccupied = false; } nodeInputs = new List<NodeInput>(); } } } GUI.Label(new Rect(nodeRect.x - 20f, nodeRect.y + ((nodeRect.height + 25f) * 0.5f) - 10f, nodeRect.width * 0.2f - 10f, 20f), nodeInputs.Count + "", guiSkin.GetStyle("std_whiteText")); } else { //Single Input Circles(red) for (int i = 0; i < nodeInputs.Count; i++) { nodeInputs[i].rect.x = nodeRect.x - 10f; nodeInputs[i].rect.y = nodeRect.y + (nodeRect.height * (1f / (nodeInputs.Count + 1))) * (i + 1) - 10f; nodeInputs[i].position = i; if (GUI.Button(nodeInputs[i].rect, "", guiSkin.GetStyle("node_input"))) { if (parentGraph != null) { if (parentGraph.wantsConnection) { if (parentGraph.connectionOutputList != null) { if (parentGraph.connectionOutputList[0].outputNode == this) { return; } if(this.nodeType == NodeType.Graph) { NodeBase tmp = this.nodeGraph.getFirstAnimatedNode(); if (tmp != null) { if (tmp.nodeInputs != null) { tmp.nodeInputs[0].inputNode = parentGraph.connectionOutputList[0].outputNode; tmp.nodeInputs[0].isOccupied = nodeInputs[0].inputNode != null; tmp.nodeInputs[0].outputPos = parentGraph.connectionOutputList[0].position; nodeInputs[i].inputNode = parentGraph.connectionOutputList[0].outputNode; nodeInputs[i].isOccupied = nodeInputs[i].inputNode != null; nodeInputs[i].outputPos = parentGraph.connectionOutputList[0].position; tmp.nodeInputs[0].inputNode.nodeOutputs[nodeInputs[0].outputPos].connectedToNode = tmp; parentGraph.connectionOutputList[0].connectedToNode = tmp; parentGraph.wantsConnection = false; parentGraph.connectionNode = null; parentGraph.connectionOutputList = null; Debug.Log("Autoconnect to inside Node " + tmp.nodeName); } } } else { nodeInputs[i].inputNode = parentGraph.connectionOutputList[0].outputNode; nodeInputs[i].isOccupied = nodeInputs[i].inputNode != null; nodeInputs[i].outputPos = parentGraph.connectionOutputList[0].position; nodeInputs[i].inputNode.nodeOutputs[nodeInputs[i].outputPos].connectedToNode = this; parentGraph.connectionOutputList[0].connectedToNode = this; parentGraph.wantsConnection = false; parentGraph.connectionNode = null; parentGraph.connectionOutputList = null; } Debug.Log("Connected from multiInput"); } else { if (parentGraph.connectionOutput.outputNode == this) { return; } if (this.nodeType == NodeType.Graph) { NodeBase tmp = this.nodeGraph.getFirstAnimatedNode(); if (tmp != null) { if (tmp.nodeInputs != null) { tmp.nodeInputs[0].inputNode = parentGraph.connectionOutput.outputNode; tmp.nodeInputs[0].isOccupied = tmp.nodeInputs[0].inputNode != null; tmp.nodeInputs[0].outputPos = parentGraph.connectionOutput.position; nodeInputs[i].inputNode = parentGraph.connectionOutput.outputNode; nodeInputs[i].isOccupied = nodeInputs[i].inputNode != null; nodeInputs[i].outputPos = parentGraph.connectionOutput.position; tmp.nodeInputs[0].inputNode.nodeOutputs[tmp.nodeInputs[0].outputPos].connectedToNode = tmp; parentGraph.connectionOutput.connectedToNode = tmp; parentGraph.wantsConnection = false; parentGraph.connectionNode = null; Debug.Log("Autoconnect to inside Node " + tmp.nodeName); } } } else { nodeInputs[i].inputNode = parentGraph.connectionOutput.outputNode; nodeInputs[i].isOccupied = nodeInputs[i].inputNode != null; nodeInputs[i].outputPos = parentGraph.connectionOutput.position; nodeInputs[i].inputNode.nodeOutputs[nodeInputs[i].outputPos].connectedToNode = this; parentGraph.connectionOutput.connectedToNode = this; parentGraph.wantsConnection = false; parentGraph.connectionNode = null; Debug.Log("Connected"); } } } else { if (this.nodeType == NodeType.Graph) { if (nodeGraph != null) { NodeBase tmp = this.nodeGraph.getFirstAnimatedNode(); if (tmp != null) { if (tmp.nodeInputs != null) { tmp.nodeInputs[0].getConnectedOutput().connectedToNode = null; tmp.nodeInputs[0].outputPos = -1; tmp.nodeInputs[0].inputNode = null; tmp.nodeInputs[0].isOccupied = false; } } } } Debug.Log("Removing Connection #" + i); nodeInputs[i].getConnectedOutput().connectedToNode = null; nodeInputs[i].outputPos = -1; nodeInputs[i].inputNode = null; nodeInputs[i].isOccupied = false; } } } } } }
public InstructionScreen(GUISkin Skin, SpriteRenderer BackgroundRenderer, PauseMenu PauseMenu) : base(Skin, BackgroundRenderer, PauseMenu) { Background = Resources.Load<Sprite>( "Sprites/GUI/Menu/Instructions_page" ); backStyle = Skin.GetStyle( "Pause-InsBack" ); backRect = new Rect( 656, 562, 150, 44 ); }
private void DrawDefaultProperties(GUISkin guiSkin) { if (parameters != null) { foreach (var key in parameters.Keys) { if (parameters[key].getParameterType() == typeof(float)) { parameters[key].floatParam = EditorGUILayout.FloatField(key, parameters[key].floatParam, guiSkin.GetStyle("property_view")); } else if (parameters[key].getParameterType() == typeof(bool)) { parameters[key].boolParam = EditorGUILayout.Toggle(key, parameters[key].boolParam); } else Debug.LogWarning("parameter type not supported: " + parameters[key].GetType()); } } }
private void DrawFloatNodeProperties(GUISkin guiSkin) { if(parameters != null) { parameters["value"].floatParam = EditorGUILayout.FloatField("Float value", parameters["value"].floatParam, guiSkin.GetStyle("property_view")); } }
//Draws Outputhandles of the Node (Rightside Green Handles) public void drawOutputHandles(GUISkin guiSkin) { if (multiOutput) { if (GUI.Button(new Rect(nodeRect.x + nodeRect.width, nodeRect.y + ((nodeRect.height + 25f) * 0.5f) - 25f, 24f, 50f), "", guiSkin.GetStyle("node_multiOutput"))) { if (parentGraph != null) { parentGraph.wantsConnection = true; parentGraph.connectionOutputList = new List<NodeOutput>(); foreach(NodeOutput n in nodeOutputs) { parentGraph.connectionOutputList.Add(n); } } } GUI.Label(new Rect(nodeRect.x + nodeRect.width , nodeRect.y + ((nodeRect.height + 25f) * 0.5f) - 10f, nodeRect.width * 0.2f - 10f, 20f), nodeOutputs.Count + "", guiSkin.GetStyle("std_whiteText")); } else { //Single Output Circles (green) for (int i = 0; i < nodeOutputs.Count; i++) { nodeOutputs[i].rect.x = nodeRect.x + nodeRect.width - 10f; nodeOutputs[i].rect.y = nodeRect.y + (nodeRect.height * (1f / (nodeOutputs.Count + 1))) * (i + 1) - 10f; nodeOutputs[i].position = i; if (GUI.Button(nodeOutputs[i].rect, "", guiSkin.GetStyle("node_output"))) { if (parentGraph != null) { if (nodeOutputs[i].connectedToNode == null) { if(nodeType == NodeType.Graph) { if (nodeOutputs[i].outputNode != null) { parentGraph.wantsConnection = true; parentGraph.connectionNode = nodeOutputs[i].outputNode; parentGraph.connectionOutput = nodeOutputs[i]; } } else { parentGraph.wantsConnection = true; parentGraph.connectionNode = this; parentGraph.connectionOutput = nodeOutputs[i]; } } else { nodeOutputs[i].connectedToNode = null; nodeOutputs[i].isOccupied = false; parentGraph.wantsConnection = true; parentGraph.connectionNode = this; parentGraph.connectionOutput = nodeOutputs[i]; //TODO disconnect the output from the input Debug.Log("disconnect it!"); } } } } } }
public virtual void UpdateNodeGUI(Event e, Rect viewRect, Rect workViewRect, GUISkin guiSkin) { ProcessEvents(e, viewRect, workViewRect); if(WorkPreferences.liveEvaluate) evaluateNode(); nodeSkin = guiSkin; viewPortRect = viewRect; string currentStyle = isSelected ? "node_selected" : "node_default"; if (timePointer.isSelected) currentStyle = "node_selected"; GUI.Box(nodeRect, nodeName, guiSkin.GetStyle(currentStyle)); GUI.Box(new Rect(nodeRect.x, nodeRect.y, nodeRect.width, 27f), nodeName, guiSkin.GetStyle((currentStyle + "_titlebar_" + titleBarColor))); GUI.Box(new Rect(nodeRect.x, nodeRect.y + nodeRect.height - 27f, nodeRect.width, 27f), "", guiSkin.GetStyle(currentStyle)); DrawCurrentTimePosition(); if (timePointer != null) timePointer.drawArrow(e, viewRect, workViewRect, guiSkin); resizeNodeBox(); DrawNodeBoxInsideByType(viewRect); drawOutputHandles(guiSkin); drawInputHandles(guiSkin); DrawInputLines(); if(timePointer.hasTiming) dragButton.DrawDragButton(e, nodeRect, guiSkin); EditorUtility.SetDirty(this); }
//Rightside Red public void DrawNodeGraphOutputs(Rect viewRect, GUISkin guiSkin) { if (graphNode != null) { NodeBase mostOuterNode = getMostOuterNode(); if (ViewOptions.showShelf) { graphNodeRect = new Rect(viewRect.width - nodeShelfWidth - 32f, viewRect.y + (viewRect.height * 0.5f) - panY, 32f, 120f); } else { graphNodeRect = new Rect(viewRect.x + viewRect.width - 32f, viewRect.y + (viewRect.height * 0.5f) - panY, 32f, 120f); } graphNodeRect.x = graphNodeRect.x / zoom; graphNodeRect.x = graphNodeRect.x - panX; graphNodeRect.width = graphNodeRect.width / zoom; if(mostOuterNode != null) { if (graphNodeRect.x < (mostOuterNode.nodeRect.x + mostOuterNode.nodeRect.width + 100)) graphNodeRect.x = mostOuterNode.nodeRect.x + mostOuterNode.nodeRect.width + 100; } if (GUI.Button(graphNodeRect, "", guiSkin.GetStyle("node_multiInput"))) { if (wantsConnection) { for (int k = 0; k < graphNode.nodeOutputs.Count; k++) { if (graphNode.nodeOutputs[k].outputNode == null && graphNode.nodeOutputs[k].isOccupied == false) { graphNode.nodeOutputs[k].outputNode = connectionNode; graphNode.nodeOutputs[k].isOccupied = graphNode.nodeOutputs[k].outputNode != null; //graphNode.nodeOutputs[k].position = k; wantsConnection = false; connectionNode = null; Debug.Log("Connected to GroupNode Output at: " + k); return; } } if (graphNode.numberOfOutputs < graphNode.nodeOutputsMax) { int i = graphNode.nodeOutputs.Count; graphNode.numberOfOutputs = i + 1; graphNode.nodeOutputs.Add(new NodeOutput()); graphNode.nodeOutputs[i].outputNode = connectionNode; graphNode.nodeOutputs[i].isOccupied = graphNode.nodeOutputs[i].outputNode != null; Debug.Log("Increased Output of GroupNode and Connected"); } wantsConnection = false; connectionNode = null; } else { Debug.Log("Removing Group Node Outputs"); graphNode.nodeOutputs = new List<NodeOutput>(); graphNode.numberOfOutputs = graphNode.nodeOutputs.Count; } } GUI.Label(graphNodeRect, graphNode.nodeOutputs.Count + "", guiSkin.GetStyle("std_whiteText")); } }
public override void DrawNodeProperties(Rect viewRect, GUISkin guiSkin) { nodeValue = EditorGUILayout.FloatField("Float value", nodeValue, guiSkin.GetStyle("property_view")); base.DrawNodeProperties(viewRect, guiSkin); }
void OnGUI() { newSkin = GUI.skin; fieldStyle = newSkin.GetStyle("TextField"); fieldStyle.font = font; fieldStyle.wordWrap = false; GUI.backgroundColor = bgColor; GUI.contentColor = fgColor; GUI.SetNextControlName("Dummy Button"); GUI.depth = -100; GUI.color = new Color(1, 1, 1, 2); GUI.enabled = false; GUI.Button(new Rect(0, 14, position.width, position.height - 14), ""); GUI.enabled = true; GUI.color = Color.white; GUI.depth = 100; if (GUI.GetNameOfFocusedControl() == "Dummy Button") { GUI.FocusControl("Current Text"); } GUI.backgroundColor = Color.white; GUILayout.BeginVertical("Toolbar"); GUILayout.BeginHorizontal(); GUILayout.Space(4); GUI.backgroundColor = Color.white; GUILayout.Label("Background ", EditorStyles.toolbarButton); bgColor = EditorGUILayout.ColorField(bgColor, GUILayout.Width(40)); GUILayout.Label("Foreground ", EditorStyles.toolbarButton); fgColor = EditorGUILayout.ColorField(fgColor, GUILayout.Width(40)); font = EditorGUILayout.ObjectField(font, typeof(Font), false) as Font; if (GUILayout.Button("Save Prefs", EditorStyles.toolbarButton)) { SaveEditorPrefs(); } if (GUILayout.Button("Revert", EditorStyles.toolbarButton)) { LoadEditorPrefs(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); scrollPosition = EditorGUILayout.BeginScrollView( scrollPosition, GUILayout.Width(position.width), GUILayout.Height(position.height - 16)); GUI.backgroundColor = Color.clear; GUIContent stream = new GUIContent(GameConsole.instance.stream); float height = fieldStyle.CalcHeight(stream, position.width); fieldStyle.wordWrap = true; GUI.SetNextControlName("Console Area"); if (string.IsNullOrEmpty(GameConsole.instance.stream)) { EditorGUILayout.SelectableLabel(" ", fieldStyle, GUILayout.Height(height)); } else { EditorGUILayout.SelectableLabel(GameConsole.instance.stream, fieldStyle, GUILayout.Height(height)); } GUILayout.Space(20); GUILayout.BeginHorizontal(); string[] path = EditorApplication.currentScene.Split('/'); string scene = path[path.Length - 1]; if (scene.Contains(".unity")) { scene = scene.Remove(scene.Length - 6); } else { scene = "Untitled"; } scene = scene + "@" + Application.platform.ToString() + ":" + GameConsole.instance.contextString + "# > "; fieldStyle.wordWrap = false; GUIContent sceneText = new GUIContent(scene); Vector2 sceneSize = fieldStyle.CalcSize(sceneText); fieldStyle.wordWrap = true; GUIContent current = new GUIContent(currentText); height = fieldStyle.CalcHeight(current, position.width - sceneSize.x); GUI.SetNextControlName("Current Text"); string consoleText = GUILayout.TextField(scene + currentText, fieldStyle, GUILayout.Height(height)); Rect consoleTextRect = GUILayoutUtility.GetLastRect(); if (!consoleText.StartsWith(scene)) { consoleText = scene + currentText; GUI.FocusControl("Console Area"); Event.current.Use(); } currentText = consoleText.Remove(0, Mathf.Min(consoleText.Length, scene.Length)); if (GUI.GetNameOfFocusedControl() == "Current Text") { GUI.color = new Color(1,1,1,.75f); GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; GUI.depth = 100; if (string.IsNullOrEmpty(currentText)) GUI.enabled = false; if (GUI.Button(new Rect(consoleTextRect.x, consoleTextRect.y - 20, 60, 20),"Cut")) { EditorGUIUtility.systemCopyBuffer = currentText; currentText = ""; } if (GUI.Button(new Rect(consoleTextRect.x + 60, consoleTextRect.y - 20, 60, 20),"Copy")) { EditorGUIUtility.systemCopyBuffer = currentText; } if (GUI.Button(new Rect(consoleTextRect.x + 180, consoleTextRect.y - 20, 60, 20),"Clear")) { currentText = ""; } GUI.enabled = true; if (string.IsNullOrEmpty(EditorGUIUtility.systemCopyBuffer)) GUI.enabled = false; if (GUI.Button(new Rect(consoleTextRect.x + 120, consoleTextRect.y - 20, 60, 20),"Paste")) { currentText = EditorGUIUtility.systemCopyBuffer; } GUI.enabled = true; GUI.contentColor = fgColor; GUI.backgroundColor = bgColor; GUI.color = Color.white; } fieldStyle.wordWrap = false; GUI.contentColor = fgColor; GUI.backgroundColor = bgColor; fieldStyle.font = null; GUI.skin = null; GUILayout.EndHorizontal(); GUILayout.EndScrollView(); if (Event.current != null) { if (Event.current.type == EventType.KeyUp && GUI.GetNameOfFocusedControl() == "Console Area") { consoleText = scene + currentText; currentText = consoleText.Remove(0, Mathf.Min(consoleText.Length, scene.Length)); GUI.FocusControl("Current Text"); } Repaint(); if (Event.current.keyCode == KeyCode.UpArrow && Event.current.type == EventType.KeyUp) { if (GameConsole.instance.commandHistory.Count > 0) { if (commandPointer == -1) { commandPointer = GameConsole.instance.commandHistory.Count - 1; } currentText = GameConsole.instance.commandHistory[commandPointer]; commandPointer--; if (commandPointer < 0) { commandPointer = 0; } } } else if (Event.current.keyCode == KeyCode.DownArrow && Event.current.type == EventType.KeyUp) { if (GameConsole.instance.commandHistory.Count > 0 && commandPointer != -1) { currentText = GameConsole.instance.commandHistory[commandPointer]; commandPointer++; if (commandPointer > GameConsole.instance.commandHistory.Count - 1) { commandPointer = GameConsole.instance.commandHistory.Count - 1; } } } else if (Event.current.type == EventType.KeyUp && Event.current.keyCode != KeyCode.LeftArrow && Event.current.keyCode != KeyCode.RightArrow) { commandPointer = -1; } if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyUp) { GameConsole.instance.Input(currentText); scrollPosition += Vector2.up * 5000f; currentText = string.Empty; consoleText = scene + currentText; Event.current.Use(); GUI.FocusControl("Current Text"); } } }
public void drawNodeShelfGroupNode(Event e, float yCoord, GUISkin viewSkin) { GUI.Box(shelfNodeRect, shelfNodeName, viewSkin.GetStyle(("node_default_titlebar_blue"))); }
public PlayModeScreen( GUISkin Skin, SpriteRenderer BackgroundRenderer, MainMenu MainMenu ) : base(Skin, BackgroundRenderer, MainMenu) { Background = Resources.Load<Sprite>( "Sprites/GUI/Menu/mainMenu-playmode" ); backRct = new Rect( 353, 562, 150, 44 ); coworkRct = new Rect( 70, 200, 355, 175 ); studentRct = new Rect( 430, 200, 355, 175 ); styleMap = new Dictionary<Option, string> (); unselectedOptions = new Dictionary<Option, Texture2D>(); selectedOptions = new Dictionary<Option, Texture2D>(); styleMap.Add( Option.Coworker, "Coworker Opt" ); styleMap.Add( Option.Student , "Student Opt" ); unselectedOptions.Add( Option.Coworker, Resources.Load<Texture2D>( "Sprites/GUI/Menu/coworkerUnselected" ) ); unselectedOptions.Add( Option.Student , Resources.Load<Texture2D>( "Sprites/GUI/Menu/studentUnselected" ) ); selectedOptions.Add( Option.Coworker, Resources.Load<Texture2D>( "Sprites/GUI/Menu/coworkerSelected" ) ); selectedOptions.Add( Option.Student , Resources.Load<Texture2D>( "Sprites/GUI/Menu/studentSelected" ) ); currentSelection = Option.Coworker; Skin.GetStyle( styleMap[ currentSelection ] ).normal.background = selectedOptions[ currentSelection ]; }
public MenuScreen( GUISkin Skin, SpriteRenderer BackgroundRenderer, MainMenu MainMenu ) : base(Skin, BackgroundRenderer, MainMenu) { Background = Resources.Load<Sprite>( "Sprites/GUI/Menu/mainMenu-home"); unselectedButtonMap = new Dictionary<MenuButton, Texture2D>(); selectedButtonMap = new Dictionary<MenuButton, Texture2D>(); styleMap = new Dictionary<MenuButton, string>(); unselectedButtonMap.Add( MenuButton.Play , Resources.Load<Texture2D>( "Sprites/GUI/Menu/playUnselected" ) ); unselectedButtonMap.Add( MenuButton.Instructions, Resources.Load<Texture2D>( "Sprites/GUI/Menu/instructionsUnselected" ) ); unselectedButtonMap.Add( MenuButton.Credits , Resources.Load<Texture2D>( "Sprites/GUI/Menu/creditsUnselected" ) ); unselectedButtonMap.Add( MenuButton.Quit , Resources.Load<Texture2D>( "Sprites/GUI/Menu/quitUnselected" ) ); selectedButtonMap .Add( MenuButton.Play , Resources.Load<Texture2D>( "Sprites/GUI/Menu/playSelected" ) ); selectedButtonMap .Add( MenuButton.Instructions, Resources.Load<Texture2D>( "Sprites/GUI/Menu/instructionsSelected" ) ); selectedButtonMap .Add( MenuButton.Credits , Resources.Load<Texture2D>( "Sprites/GUI/Menu/creditsSelected" ) ); selectedButtonMap .Add( MenuButton.Quit , Resources.Load<Texture2D>( "Sprites/GUI/Menu/quitSelected" ) ); playRct = new Rect( 328, 207, 200, 75 ); instRct = new Rect( 213, 300, 431, 75 ); creditRct = new Rect( 287, 400, 282, 75 ); quitRct = new Rect( 328, 500, 203, 75 ); activeButton = MenuButton.Play; styleMap.Add( MenuButton.Play , "Play Button" ); styleMap.Add( MenuButton.Instructions, "Instruction Button" ); styleMap.Add( MenuButton.Credits , "Credit Button" ); styleMap.Add( MenuButton.Quit , "Quit Button" ); Skin.GetStyle( styleMap[ activeButton ] ).normal.background = selectedButtonMap[ activeButton ]; }
public override MenuState renderGUI(Vector2 pageOffset , GUISkin skin) { GUIStyle style_text_field = new GUIStyle(skin.GetStyle("textfield")); GUIStyle style_lable = new GUIStyle(skin.GetStyle("label")); GUI.Label(new Rect(MenuManager.field_offset.x+ pageOffset.x, 0 + pageOffset.y + MenuManager.field_offset_height, MenuManager.field_width, MenuManager.field_height), "Username: "******"Password: "******"Mail(optional): ",style_lable); _mail = GUI.TextField(new Rect(MenuManager.field_offset.x + MenuManager.field_width + pageOffset.x, MenuManager.field_offset.y*2 + pageOffset.y+ MenuManager.field_offset_height, MenuManager.field_width, MenuManager.field_height), _mail,style_text_field); if(GUI.Button(new Rect(MenuManager.field_offset.x + pageOffset.x,MenuManager.field_offset.y*4 + pageOffset.y+ MenuManager.field_offset_height,MenuManager.field_width,MenuManager.field_height),"Register",style_lable)) { AccountData data = new AccountData(_username,_password,_mail); StartCoroutine(Authenticator.getInstance().register(data)); } // if(GUI.Button(new Rect(0 + pageOffset.x,120 + pageOffset.y,MenuManager.field_width,MenuManager.field_height),"Back",skin)) // { // _error = ""; // Authenticator.getInstance().reset(); // return MenuManager.main; // } GUI.Label(new Rect(MenuManager.field_offset.x + MenuManager.field_width + pageOffset.x, MenuManager.field_offset.y*4 + pageOffset.y+ MenuManager.field_offset_height - MenuManager.field_height, MenuManager.field_width, MenuManager.field_height*2), _error,style_lable); if(Authenticator.getInstance().hasFinished()) { if(Authenticator.getInstance().hasSuccessed()) { _error = ""; Authenticator.getInstance().reset(); return MenuManager.login; } else { _error = Authenticator.getInstance().getError(); Authenticator.getInstance().reset(); return MenuManager.none; } } return MenuManager.none; }
public override MenuState renderGUI(Vector2 pageOffset, GUISkin skin) { // if(GUI.Button(new Rect(0 + pageOffset.x ,120 + pageOffset.y,100,30),"Register",skin)) // { // Authenticator.getInstance().reset(); // return MenuManager.register; // } // // if(GUI.Button(new Rect(0 + pageOffset.x ,160 + pageOffset.y,100,30),"Login",skin)) // { // Authenticator.getInstance().reset(); // return MenuManager.login; // } GUIStyle style = new GUIStyle(skin.GetStyle("label")); style.fontSize = 90; GUI.DrawTexture(new Rect(MenuManager.field_offset.x + pageOffset.x, 100 + pageOffset.y, 600, 125), (Texture)Resources.Load("textures/GUI/caravan_title", typeof(Texture))); return MenuManager.none; }
public static void DrawText ( GUISkin guiSkin, string text, Vector3 position, Color? color = null, int fontSize = 0, float yOffset = 0 ) { #if UNITY_EDITOR var prevSkin = GUI.skin; if ( guiSkin == null ) Debug.LogWarning ( "editor warning: guiSkin parameter is null" ); else GUI.skin = guiSkin; GUIContent textContent = new GUIContent ( text ); GUIStyle style = (guiSkin != null) ? new GUIStyle ( guiSkin.GetStyle ( "Label" ) ) : new GUIStyle (); if ( color != null ) style.normal.textColor = (Color)color; if ( fontSize > 0 ) style.fontSize = fontSize; Vector2 textSize = style.CalcSize ( textContent ); Vector3 screenPoint = Camera.current.WorldToScreenPoint ( position ); if ( screenPoint.z > 0 ) // checks necessary to the text is not visible when the camera is pointed in the opposite direction relative to the object { var worldPosition = Camera.current.ScreenToWorldPoint ( new Vector3 ( screenPoint.x - textSize.x * 0.5f, screenPoint.y + textSize.y * 0.5f + yOffset, screenPoint.z ) ); UnityEditor.Handles.Label ( worldPosition, textContent, style ); } GUI.skin = prevSkin; #endif }
public override void OnTextEditorGUI(int windowID) { this.windowID = windowID; if (!show) return; GUI.color = new Color(1,1,1,1); if (!editor.TestClickBlockers(editor.windowMousePos,this)) { GUI.BringWindowToFront(windowID); if (Event.current.type == EventType.MouseDown) { FocusWindow(); } } skin = editor.editorWindow.theme.skin; textEditorRect = editor.GetTextEditorRect(); textEditorRect.y += editor.tabRect.height; textEditorRect.height -= editor.tabRect.height; textEditorRectZeroPos = textEditorRect; textEditorRectZeroPos.x = 0; textEditorRectZeroPos.y = 0; UpdateRect(); GUI.skin = skin; Rect winRect = rect; winRect.x += textEditorRect.x; winRect.y += textEditorRect.y; Rect shadowClipRect = textEditorRect; shadowClipRect.x = 0; GUI.BeginGroup(shadowClipRect); GUIStyle shadowStyle = skin.GetStyle("DropShadow"); if (shadowStyle != null) { Rect shadowRect = rect; shadowRect.x += editor.lineNumberWidth; GUI.Box(shadowRect,"",shadowStyle); } GUI.EndGroup(); GUI.BeginGroup(textEditorRect); GUI.Window(windowID, winRect, DrawGUIWindow, "Find And Replace", new GUIStyle()); GUI.EndGroup(); GUI.skin = null; }
void OnLanguageChanged() { iTunesSkin = Localizer.Skins["mediabar"]; mediaBar = iTunesSkin.GetStyle("MediaBar"); songName = iTunesSkin.GetStyle("SongName"); songTitle = iTunesSkin.GetStyle("SongTitle"); mediaBarButton = iTunesSkin.GetStyle("MediaBarButton"); disabledButton = iTunesSkin.GetStyle("DisabledButton"); }
public void OnLanguageChanged() { skin = Localizer.Skins["main"]; demomodeIndicator = skin.GetStyle("demomode"); }
//Leftside Green public void DrawNodeGraphInputs(Rect viewRect, GUISkin guiSkin) { if(graphNode != null) { graphInputRects.Clear(); for (int i = 0; i < graphNode.nodeInputs.Count; i++) { Rect temp; if (ViewOptions.showShelf) { temp = new Rect(0, viewRect.y + (viewRect.height * (1f / (graphNode.nodeInputs.Count + 1))) * (i + 1), 32f, 64f); graphInputRects.Add(temp); } else { temp = new Rect(viewRect.x, viewRect.y + (viewRect.height * (1f / (graphNode.nodeInputs.Count + 1))) * (i + 1), 32f, 64f); graphInputRects.Add(temp); } NodeInput input = graphNode.nodeInputs[i]; if (GUI.Button(temp, "", guiSkin.GetStyle("node_multiOutput"))) { curveIndex = i; if (graphNode.parentGraph != null && input != null) { if(input.inputNode != null) { wantsConnection = true; connectionNode = input.inputNode; connectionOutput = input.inputNode.nodeOutputs[input.outputPos]; } } } } } }