public void showHighlight() { float boarder = 2; Rect back = new Rect(location.position.x - boarder, location.position.y - boarder, location.width + boarder * 2, location.height + boarder * 2); HelperEditor.DrawColorBox(back, new Color(.65f, .65f, .15f), ""); }
//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void drawHandle(Vector3 point) { float boarder = 1; float size = 4; Rect box = new Rect(point.x - size / 2, point.y - size / 2, size, size); Rect box2 = new Rect(box.x - boarder, box.y - boarder, box.width + boarder * 2, box.height + boarder * 2); HelperEditor.DrawColorBox(box2, Color.gray); HelperEditor.DrawColorBox(box, Color.black); }
/// <summary> /// Draw the connection box on the screen. /// </summary> public void showNotSelected() { Vector2 center = HelperGraphics.quarterPoint(fromPT, toPT); Rect box = new Rect(center.x - width / 2, center.y - heigt / 2 + fromToCount * 40, width, heigt); if (from == to) { //Debug.Log("from = too"); box = new Rect(center.x - width - 40, center.y - heigt + fromToCount * 40, width, heigt); } /* * Rect editbox = new Rect(box.x,box.y,width,heigt+20); * Rect editboxBoarder = new Rect(box.x -1 ,box.y -1,width+2,heigt+20+2); */ float boarder = 2; Rect box2 = new Rect(box.x + boarder, box.y + boarder, box.width - boarder * 2, box.height - boarder * 2); location = box; if (selected) //we need to add the edit boxes { } else //just show the information { HelperEditor.DrawColorBox(box, boxColorBack, ""); if (conditions.Length > 0 && actions.Length > 0) { HelperEditor.DrawColorBox(box2, boxColor, id + ": " + eventName, "\n[" + conditions + "]\n/" + actions); } if (conditions.Length == 0 && actions.Length > 0) { HelperEditor.DrawColorBox(box2, boxColor, id + ": " + eventName, "\n/" + actions); } if (conditions.Length > 0 && actions.Length == 0) { HelperEditor.DrawColorBox(box2, boxColor, id + ": " + eventName, "\n[" + conditions + "]"); } if (conditions.Length == 0 && actions.Length == 0) { HelperEditor.DrawColorBox(box2, boxColor, id + ": " + eventName); } } }
//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void attributeInputBox(Rect frame, float boarder) { HelperEditor.DrawColorBox(new Rect(frame.x - boarder, frame.y - boarder, frame.width + boarder * 2, frame.height + boarder * 2), Color.gray, ""); HelperEditor.DrawColorBox(frame, new Color(.15f, .15f, .15f), "Attributes"); float lChunk = 25; float rightSide = frame.width - boarder * 2; float l1 = frame.y + 15; float width = 70; //atttributScroll = EditorGUILayout.BeginScrollView(atttributScroll, true, true, GUILayout.Width(frame.width), GUILayout.Height(frame.height-30)); atttributScroll = GUI.BeginScrollView(new Rect(frame.x + 5, l1 + 10, frame.width - 10, 200), atttributScroll, new Rect(frame.x + 5, 0, 0, lChunk * attributes.Count), false, false); for (int i = 0; i < attributes.Count; i++) { AttributePair attr = (AttributePair)attributes[i]; attr.label = GUI.TextField(new Rect(15, i * lChunk, width, 20), attr.label); GUI.Label(new Rect(20 + width, i * lChunk, 20, 20), "="); if (!Application.isPlaying) { attr.value = GUI.TextField(new Rect(15 + width + 25, i * lChunk, width / 1.5f, 20), attr.value); } else if (currentStateController != null) { GUI.TextField(new Rect(15 + width + 25, i * lChunk, width / 1.5f, 20), currentStateController.myStateMachine.getAtributeValue(attr.label)); } if (GUI.Button(new Rect(45 + width + width / 1.5f, i * lChunk, 20, 20), "-")) { attributes.Remove(attr); } } GUI.EndScrollView(); GUILayout.BeginArea(new Rect(frame.x + 70, frame.y + frame.height - 20, 60, 20)); if (GUILayout.Button("NEW")) { attributes.Add(new AttributePair("", "")); } GUILayout.EndArea(); }
//--------------------------------------------------------------------------------- public void show() { Rect back = location; float boarder = 8; back.width += boarder; back.height += boarder; back.x -= boarder / 2.0f; back.y -= boarder / 2.0f; Rect pt = new Rect(location.position.x, location.position.y + location.height + 2, 10, 10); EndPoint ep = new EndPoint(pt); Rect resized = new Rect(ep.location.x - 1, ep.location.y - 1, ep.location.width + 2, ep.location.height + 2); HelperEditor.DrawColorBox(resized, new Color(.35f, .35f, .35f), ""); HelperEditor.DrawColorBox(pt, new Color(.15f, .15f, .15f), ""); activeEndPoint = ep; }
}// //---------------------------------------------------------------------------- void DoPanelWindow(int windowID) { if (GUI.Button(new Rect(180, 0, 20, 15), "-")) { //Debug.Log("Delete "+windowID); states[windowID].markedForDeath = true; dirty = true; } // states[windowID].stateName = GUILayout.TextField(states[windowID].stateName); states[windowID].stateName = states[windowID].stateName.Replace(" ", ""); states[windowID].stateName = states[windowID].stateName.Replace(".", ""); states[windowID].stateName = states[windowID].stateName.Replace(",", ""); states[windowID].stateName = states[windowID].stateName.Replace("/", ""); states[windowID].stateName = states[windowID].stateName.Replace("\"", ""); states[windowID].stateName = states[windowID].stateName.Replace(";", ""); states[windowID].stateName = states[windowID].stateName.Replace(":", ""); states[windowID].stateDiscription = GUILayout.TextArea(states[windowID].stateDiscription); //Debug.Log("-+"+currentState+" --"+states[windowID].stateName); if (Application.isPlaying && currentState == states[windowID].stateName) { runCounter += 2; int adjRC = runCounter % ((int)HelperConstants.StateWidth - 10); int adjX = runCounter % ((int)HelperConstants.StateWidth - 25); int adjY = runCounter % ((int)45); HelperEditor.DrawColorBox(new Rect(5, HelperConstants.StateHeight - 15, 5 + adjRC, 10), Color.green); //HelperEditor.DrawColorBox(new Rect(5+adjX-10,HelperConstants.StateHeight-20,25,15),Color.green); } else { //runCounter=0; // HelperEditor.DrawColorBox(new Rect(5,HelperConstants.StateHeight-10,HelperConstants.StateWidth-10,5),Color.gray); } //GUI.Box(,) GUI.DragWindow(); //return null; }
/// <summary> /// Draw the connection box on the screen. /// </summary> public void showSelected() { Vector2 center = HelperGraphics.quarterPoint(fromPT, toPT); Rect box = new Rect(center.x - width / 2, center.y - editHeigt / 2 + fromToCount * 40, width, editHeigt); if (from == to) { //Debug.Log("from = too"); box = new Rect(center.x - width - 40, center.y - editHeigt + fromToCount * 40, width, editHeigt); } Rect editbox = new Rect(box.x, box.y, width, editHeigt + 20); Rect editboxBoarder = new Rect(box.x - 1, box.y - 1, width + 2, editHeigt + 20 + 2); float boarder = 2; Rect box2 = new Rect(box.x + boarder, box.y + boarder, box.width - boarder * 2, box.height - boarder * 2); location = box; if (selected) //we need to add the edit boxes { HelperEditor.DrawColorBox(editboxBoarder, editboxColorBoarder, ""); HelperEditor.DrawColorBox(editbox, editboxColorBack, ""); GUILayout.BeginArea(new Rect(box.x + 2, box.y + 2, 40, 20)); GUILayout.Label("Name:"); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(box.x + 40, box.y + 2, 80, 20)); eventName = GUILayout.TextField(eventName); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(box.x + 2, box.y + 22, 10, 20)); GUILayout.Label("["); GUILayout.EndArea(); // GUILayout.BeginArea(new Rect(box.x + 12, box.y + 22, 100, 20)); conditions = GUILayout.TextField(conditions); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(box.x + 115, box.y + 22, 10, 20)); GUILayout.Label("]"); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(box.x + 2, box.y + 44, 10, 20)); GUILayout.Label("/"); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(box.x + 12, box.y + 44, 100, 20)); actions = GUILayout.TextField(actions); GUILayout.EndArea(); if (GUI.Button(new Rect(box.x + box.width - 10, box.y - 7, 20, 15), "-")) { Debug.Log("delete"); markedForDeath = true; } } else //just show the information { } }
//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void fileControlPanel(Vector2 point) { HelperEditor.DrawColorBox(new Rect(point.x - 7, point.y - 7, 204, 274), Color.gray); HelperEditor.DrawColorBox(new Rect(point.x - 5, point.y - 5, 200, 270), new Color(.15f, .15f, .15f)); GUI.Label(new Rect(point.x, point.y, 150, 20), "Resource Directory"); resourcesDirectory = GUI.TextField(new Rect(point.x, point.y + 20, 180, 20), resourcesDirectory); GUI.Label(new Rect(point.x, point.y + 45, 200, 20), "Resource Filename"); filename = GUI.TextField(new Rect(point.x, point.y + 65, 150, 20), filename); GUILayout.BeginArea(new Rect(point.x, point.y + 90, 80, 50)); if (GUILayout.Button("SAVE FSM")) { Debug.Log(("SAVE FSM " + Application.dataPath + resourcesDirectory)); save(); HelperFile.saveToFile(Application.dataPath + resourcesDirectory + "/" + filename + ".txt", getFSMString()); //AssetDatabase.ImportAsset(Application.dataPath + resourcesDirectory+"/"+filename+".txt"); //loadFSM(HelperFile.getTextFileFromResource(filename)); Repaint(); } // GUILayout.EndArea(); GUILayout.BeginArea(new Rect(point.x + 100, point.y + 90, 80, 50)); if (GUILayout.Button("LOAD FSM")) { Debug.Log(("LOAD FSM " + Application.dataPath + resourcesDirectory)); save(); //HelperFile.saveToFile(Application.dataPath + resourcesDirectory+"/"+filename+".txt",getFSMString()); string filestring = HelperFile.getTextFileFromResource(filename); //filestring = EditorGUILayout.ObjectField(filestring,typeof(object), true); if (filestring.Length > 3) { loadFSM(filestring); } } GUILayout.EndArea(); GUI.Label(new Rect(point.x, point.y + 130, 200, 20), "Controller name"); controllerName = GUI.TextField(new Rect(point.x, point.y + 150, 180, 20), controllerName); GUILayout.BeginArea(new Rect(point.x, point.y + 175, 100, 50)); if (GUILayout.Button("Build Controller")) { if (controllerName == "stateController") { controllerName = controllerName + "1"; } Debug.Log("Make Controller: " + Application.dataPath + "/" + controllerName); save(); HelperFile.saveToFile(Application.dataPath + "/stateMachine/Controllers/" + controllerName + ".cs", HelperFormater.makeFileUsing(controllerName, filename, states)); //AssetDatabase.ImportAsset(Application.dataPath+"/"+controllerName+".cs"); //loadFSM(HelperFile.getTextFileFromResource(filename)); //if(currentStateController == null) if (source == null) { Debug.Log("No controller selected"); GameObject o = new GameObject(); o.name = controllerName; source = o; needToAddControllerScript = true; AssetDatabase.Refresh(); // //GameObject go = (GameObject)Instantiate(o); //o.AddComponent(controllerName);// } else { GameObject so = (GameObject)source; object testO = so.GetComponent(controllerName); if (testO == null) { needToAddControllerScript = true; AssetDatabase.Refresh(); // } } Repaint(); } GUILayout.EndArea(); string beforeSource = ""; if (source != null) { beforeSource = source.name; } GUI.Label(new Rect(point.x, point.y + 210, 200, 20), "Target"); GUILayout.BeginArea(new Rect(point.x + 50, point.y + 210, 135, 50)); source = EditorGUILayout.ObjectField(source, typeof(GameObject), true); GUILayout.EndArea(); if (source != null) { if (source.name != beforeSource) { PlayerPrefs.SetString("target", source.name); PlayerPrefs.Save(); GameObject o = (GameObject)source; stateController tempSC = o.GetComponent <stateController>(); if (tempSC != null) { controllerName = getShortName(tempSC.ToString()); PlayerPrefs.SetString("controllerName", controllerName); PlayerPrefs.Save(); } } } // GUILayout.BeginArea(new Rect(point.x, point.y + 240, 100, 50)); if (GUILayout.Button("Clear Screen")) { reset(); } GUILayout.EndArea(); }