public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); var paddedBOunds = Bounds.PadSides(5); var headerBounds = paddedBOunds.WithHeight(20).Translate(0,10); Rect imageBounds; var hasHeader = !string.IsNullOrEmpty(NodeViewModel.HeaderText); var hasComments= !string.IsNullOrEmpty(NodeViewModel.Comments); if (hasHeader) { imageBounds = paddedBOunds.Below(headerBounds).Translate(0, 5).Clip(paddedBOunds); } else { imageBounds = paddedBOunds; } if (hasHeader) { var ts =platform.CalculateTextSize(NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle); platform.DrawLabel(headerBounds, NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle); var hmRect = new Rect().Align(headerBounds).WithSize(ts.x,2).Below(headerBounds).Translate(0,3); platform.DrawRect(hmRect, CachedStyles.GetColor(NodeColor.Gray)); } if (!string.IsNullOrEmpty(NodeViewModel.ImageName) && Image != null) { platform.DrawImage(imageBounds,Image,true); } else platform.DrawLabel(imageBounds,"Image Not Found",CachedStyles.WizardSubBoxTitleStyle); }
public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); var paddedBOunds = Bounds.PadSides(5); var headerBounds = paddedBOunds.WithHeight(20).Translate(0,10); Rect textBounds; var hasHeader = !string.IsNullOrEmpty(NodeViewModel.HeaderText); if (hasHeader) { textBounds = paddedBOunds.Below(headerBounds).Translate(0, 5).Clip(paddedBOunds); } else { textBounds = paddedBOunds; } if (NodeViewModel.ShowMark) { textBounds = textBounds.Pad(6, 0, 6, 0); } if (hasHeader) { var ts =platform.CalculateTextSize(NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle); platform.DrawLabel(headerBounds, NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle); var hmRect = new Rect().Align(headerBounds).WithSize(ts.x,2).Below(headerBounds).Translate(0,3); platform.DrawRect(hmRect, CachedStyles.GetColor(NodeColor.Gray)); } if (NodeViewModel.ShowMark) { var markRect = textBounds.WithWidth(3).Pad(0,10,0,20).Translate(-6, 0); platform.DrawRect(markRect,CachedStyles.GetColor(NodeViewModel.MarkColor)); } platform.DrawLabel(textBounds,ViewModel.Comments,CachedStyles.ListItemTitleStyle); }
public void DrawInspector(Object target) { GUIHelpers.IsInsepctor = true; var entityComponent = target as Entity; if (entityComponent != null) { //if (Repository != null) //{ // EditorGUILayout.HelpBox("0 = Auto Assign At Runtime", MessageType.Info); //} //if (GUILayout.Button("Create New Component")) //{ // if (TreeModel == null) // { // TreeModel = new TreeViewModel() // { // Data = Container.Resolve<IRepository>().AllOf<ModuleNode>().Select(item=>new SelectionMenuItem(item, // () => // { // })).Cast<IItem>().ToList() // }; // } // else // { // TreeModel = null; // } //} //if (TreeModel != null) //{ // var lastRect = GUILayoutUtility.GetLastRect(); // var rect = GUILayoutUtility.GetRect(lastRect.x, lastRect.y, 300, 500); // Signal<IDrawTreeView>(_=>_.DrawTreeView(rect,TreeModel,(p,x)=>{ // var item = (x as SelectionMenuItem).DataObject as IDiagramNode; // Execute(new NavigateToNodeCommand() // { // Node = item as IDiagramNode // }); // Execute(new CreateNodeCommand() // { // NodeType = typeof(ComponentNode), // GraphData = InvertGraphEditor.CurrentDiagramViewModel.GraphData, // }); // TreeModel = null; // })); //} } var component = target as EcsComponent; //if (component != null) //{ if (Repository != null) { var attribute = target.GetType().GetCustomAttributes(typeof(uFrameIdentifier), true).OfType <uFrameIdentifier>().FirstOrDefault(); if (attribute != null) { var item = Repository.GetSingle <ComponentNode>(attribute.Identifier); if (component != null) { var inspectorBounds = new Rect(0, 0, Screen.width, Screen.height); //var iconBounds = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(inspectorBounds); //Drawer.DrawImage(iconBounds,"CommandIcon",true); //if (GUIHelpers.DoToolbarEx("System Handlers")) //{ // foreach ( // var handlerNode in // Repository.All<HandlerNode>() // .Where(p => p.EntityGroup != null && p.EntityGroup.Item == item)) // { // if (GUILayout.Button(handlerNode.Name)) // { // Execute(new NavigateToNodeCommand() // { // Node = handlerNode, // Select = true // }); // } // } //} if (GUIHelpers.DoToolbarEx("uFrame Designer")) { var toolbarButton = ComponentEditorToolbarButtonStyle; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Serving Handlers:"); EditorGUILayout.EndHorizontal(); foreach ( var handlerNode in Repository.All <HandlerNode>() .Where(p => p.HandlerInputs.Any(x => x.Item != null && x.Item.SelectComponents.Contains(item)))) { EditorGUILayout.BeginHorizontal(); var text = handlerNode.Name; if (GUILayout.Button(text, toolbarButton)) { Execute(new NavigateToNodeCommand() { Node = handlerNode, Select = true }); } var descRect = GUILayoutUtility.GetLastRect(); //GUILayout.FlexibleSpace(); var meta = handlerNode.Meta as EventMetaInfo; if (meta != null && meta.Dispatcher && component.gameObject.GetComponent(meta.SystemType) == null) { Drawer.DrawImage(new Rect().WithSize(16, 16).InnerAlignWithCenterLeft(descRect).Translate(4, 0), "RedDotIcon", true); var cb = GUI.backgroundColor; GUI.backgroundColor = CachedStyles.GetColor(NodeColor.Carrot); //if (GUILayout.Button("+ " + meta.SystemType.Name,EditorStyles.toolbarButton)) if (GUILayout.Button(new GUIContent("Add", string.Format("Add {0} which is used to invoke the corresponding event", meta.SystemType.Name)), EditorStyles.toolbarButton, GUILayout.Width(60))) { component.gameObject.AddComponent(meta.SystemType); } GUI.backgroundColor = cb; } else { Drawer.DrawImage(new Rect().WithSize(16, 16).InnerAlignWithCenterLeft(descRect).Translate(4, 0), "GreenDotIcon", true); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label(""); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var cachedBackgroundColor = GUI.backgroundColor; GUI.backgroundColor = CachedStyles.GetColor(NodeColor.SgiTeal); if (GUILayout.Button("Edit In Designer", EditorStyles.toolbarButton)) { Execute(new NavigateToNodeCommand() { Node = item, Select = true }); } GUI.backgroundColor = cachedBackgroundColor; EditorGUILayout.EndHorizontal(); } } } } //} }