public override void OnXGUI() { GUI.SetNextControlName("CommandControl"); command = CreateStringField("Input ur command : ", command); if (Event.current != null) { HandleInput(Event.current); } DisableFragment(true, () => { CreateLabel(string.Format("Type : {0}", type == null ? "None" : type.FullName)); }); draggedObject = CreateObjectField(draggedObject); for (int pos = 0; pos < searchCollection.Count; pos++) { GUI.SetNextControlName(searchCollection[pos]); GUIStyle style = XStyles.GetInstance().button; DoButton(searchCollection[pos], () => { OnSelectionButton(); return; }, style); } }
protected void DrawEvent(int eventIndex, int stateIndex) { var targetEvent = target.totalEvent[eventIndex]; var targetState = totalNode[stateIndex]; var bounds = new Rect(targetState.DrawBounds.position + new Vector2(0, -100), new Vector2(100, 50)); GUI.Box(bounds, target.totalEvent[eventIndex].Name, XStyles.GetInstance().skin.window); var arrow = new Rect(targetState.DrawBounds.position + new Vector2(50, -50), new Vector2(10, 50)); GUI.Box(arrow, "", XStyles.GetInstance().skin.window); }
public static XStyles GetInstance() { if (styles == null) { var path = FileUtil.GetProjectRelativePath(XEditorSetting.PluginPath + "/Templates/XGUIStyle.asset"); XLogger.Log(path); styles = AssetDatabase.LoadAssetAtPath <XStyles> (path); XLogger.Log(styles == null); } return(styles); }
public override void Draw() { GUI.Box(DrawBounds, "", isCustomState ? XStyles.GetInstance().FindStyle("RedBox") : XStyles.GetInstance().FindStyle("GreyBox")); DrawChildNodes(); if (Selected) { GUI.Box(DrawBounds, "", isCustomState ? XStyles.GetInstance().FindStyle("GreenBox") : XStyles.GetInstance().FindStyle("BlueBox")); } if (BtState.Owner.currState != null && BtState.Name == BtState.Owner.currState.Name) { GUI.Box(DrawBounds, "", XStyles.GetInstance().FindStyle("OrangleBox")); } for (int i = 0; i < BtState.totalEvent.Count; i++) { Rect button = GetEventRect(i); var targetEvent = BtState.totalEvent[i]; bool isCurrentEvent = targetEvent == BTEditorWindow.instance.currentEvent; if (GUI.Button(button, targetEvent.Name, XStyles.GetInstance().skin.button)) { BTEditorWindow.instance.SetCurrentEvent(targetEvent); } if (isCurrentEvent) { BTEditorWindow.instance.SetCurrentRect(button); } BTNode targetStateNode = null; if (targetEvent.TargetState != null) { targetStateNode = BTEditorWindow.instance.FindBTNode(targetEvent.TargetState); DrawBesizeFromRect(button, targetStateNode.DrawBounds); } if (totalRunningEvent.ContainsKey(targetEvent)) { DrawLine(i, targetStateNode.DrawBounds); } } GUI.Box(DrawBounds, ThumbnailTexture, XStyles.GetInstance().FindStyle("TextureBox")); GUI.Label(DrawBounds, Title, XStyles.GetInstance().skin.label); }
public void DrawBox(FsmState fsmState) { var stateRect = GetStateRect(fsmState); GUI.Box(stateRect, "", XStyles.GetInstance().window); for (int i = 0; i < fsmState.Count; i++) { // TODO loop in fsmState.Count var rect = GetEventRect(fsmState[i]); if (GUI.Button(rect, fsmState[i].name)) { FsmEditor.selectEvent = fsmState[i]; } DrawLink(fsmState[i], fsmState[i].target); } fsmState.name = GUI.TextField(new Rect(fsmState.position, stateRect.size), fsmState.name, XStyles.GetInstance().box); }
public override void OnGraphGUI() { // Show node subwindows. m_Host.BeginWindows(); foreach (var node in graph.nodes) { // Recapture the variable for the delegate. var node2 = node as BTNode.BTNode; // Subwindow style (active/nonactive) var isActive = selection.Contains(node); //var style = UnityEditor.Graphs.Styles.GetNodeStyle( node.style, node.color, isActive ); var style = node2.isCustomState ? XStyles.GetInstance().FindStyle("RedBox") : XStyles.GetInstance().FindStyle("GreyBox"); // Show the subwindow of this node. node.position = GUILayout.Window( node.GetInstanceID(), node2.position, delegate { NodeGUI(node2); }, node.title, style ); } // Workaround: If there is no node in the graph, put an empty // window to avoid corruption due to a bug. // if( graph.nodes.Count == 0 ) // GUILayout.Window( 0, new Rect( 0, 0, 1, 1 ), delegate { // }, "", "MiniLabel" ); m_Host.EndWindows(); // Graph edges edgeGUI.DoEdges(); edgeGUI.DoDraggedEdge(); // Mouse drag DragSelection(new Rect(-5000, -5000, 10000, 10000)); // Context menu ShowCustomContextMenu(); HandleMenuEvents(); }
public static void CreateStyleAsset() { string path = EditorUtility.SaveFilePanel("Create GUI Style", XEditorSetting.PluginPath, "Default.asset", "asset"); if (path == "") { return; } path = FileUtil.GetProjectRelativePath(path); XStyles xstyle = CreateInstance <XStyles> (); GUISkin data = Instantiate(Selection.objects [0]) as GUISkin; xstyle.skin = data; AssetDatabase.CreateAsset(xstyle, path); AssetDatabase.AddObjectToAsset(data, path); AssetDatabase.SaveAssets(); }
public void Children_Not_Null() { var target = new XStyles(); Assert.NotNull(target.Children); }
public void Inherits_From_ObservableResource() { var target = new XStyles(); Assert.True(target is ObservableResource); }
private static void DrawHierarchyItem(int instanceId, Rect selectionRect) { try{ BuildStyles(); GameObject target = EditorUtility.InstanceIDToObject(instanceId) as GameObject; if (target == null) { return; } // Reserve the draw rects Rect visRect = new Rect(selectionRect) { xMin = selectionRect.xMax - (selectionRect.height * 2.1f), xMax = selectionRect.xMax - selectionRect.height }; Rect lockRect = new Rect(selectionRect) { xMin = selectionRect.xMax - selectionRect.height }; // Draw the visibility toggle bool isActive = target.activeSelf; if (isActive != GUI.Toggle(visRect, isActive, GUIContent.none, styleVisible)) { SetVisible(target, !isActive); EditorApplication.RepaintHierarchyWindow(); } // Draw lock toggle bool isLocked = (target.hideFlags & HideFlags.NotEditable) > 0; // Decide which GUIStyle to use for the button // If this item is currently selected, show the visible lock style, if not, invisible lock style GUIStyle lockStyle = (Selection.activeInstanceID == instanceId) ? styleLock : styleLockUnselected; if (isLocked != GUI.Toggle(lockRect, isLocked, GUIContent.none, lockStyle)) { SetLockObject(target, !isLocked); EditorApplication.RepaintHierarchyWindow(); } var monos = target.GetComponents <Behaviour> (); int startIndex = 0; for (int i = 0; i < monos.Length; i++) { if (monos [i] == null) { continue; } var e = monos [i].enabled; Rect monoRect = new Rect(selectionRect) { xMin = selectionRect.xMax - (startIndex + 3) * selectionRect.height }; if ((monos [i].hideFlags & HideFlags.HideInInspector) != 0 || showHideComponents) { continue; } else { startIndex++; } var guiContent = EditorGUIUtility.ObjectContent(monos [i], monos [i].GetType()); if (guiContent != null && guiContent.image != null && e != GUI.Toggle(monoRect, e, guiContent.image, XStyles.GetInstance().GetCustomSkin("LightSkin").toggle)) { SetVisible(monos [i], !e); EditorApplication.RepaintHierarchyWindow(); var window = InspectorUtilites.GetInspectorWindow(); window.Repaint(); } } }catch (Exception e) { XLogger.Log(e.ToString()); var lineNumber = 0; const string lineSearch = ":line "; var index = e.StackTrace.LastIndexOf(lineSearch); if (index != -1) { var lineNumberText = e.StackTrace.Substring(index + lineSearch.Length); if (int.TryParse(lineNumberText, out lineNumber)) { } } XLogger.Log(lineNumber); } }
public override void OnXGUI() { base.OnXGUI(); targetState.Owner = CreateObjectField("Owner", targetState.Owner) as BTFsm; targetState.Name = CreateStringField("Name", targetState.Name); Space(); Space(); var totalEvent = targetState.totalEvent; CreateLabel("total events :"); int deleteIndex = -1; for (int i = 0; i < totalEvent.Count; i++) { BeginHorizontal(); totalEvent[i].Name = CreateStringField(totalEvent[i].Name); DoButton("Delete", () => { deleteIndex = i; }); EndHorizontal(); } if (deleteIndex != -1) { totalEvent.RemoveAt(deleteIndex); } //var totalEventProperty = serializedObject.FindProperty( "totalEvent" ); //CreatePropertyField( totalEventProperty ); Space(); Space(); CreateLabel("total actions :"); var totalAction = targetState.totalActions; deleteIndex = -1; for (int i = 0; i < totalAction.Count; i++) { BeginHorizontal(); CreateObjectField(totalAction[i]); DoButton("Delete", () => { deleteIndex = i; }); EndHorizontal(); } if (deleteIndex != -1) { var action = totalAction[deleteIndex]; DestroyImmediate(action, true); totalAction.RemoveAt(deleteIndex); } Space(); Space(); DoButton("Back to Fsm", () => { Selection.objects = new UnityEngine.Object[] { targetState.Owner }; }); //ShowXAttributeMember( target ); targetState.GlobalEvent.Name = CreateStringField("GlobalEvent", targetState.GlobalEvent.Name); targetState.GlobalEvent.isGlobal = CreateCheckBox("isGlobal", targetState.GlobalEvent.isGlobal); targetState.Bounds = CreateRectField("Bounds", targetState.Bounds); targetState.Notes = EditorGUILayout.TextArea(targetState.Notes, XStyles.GetInstance().skin.textArea); targetState.Priority = CreateIntField("Priority", targetState.Priority); serializedObject.Update(); serializedObject.UpdateIfDirtyOrScript(); }