Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Question NodePropertyView Not visible in custom editor.

    Till now everything is running smoothly. But after updating property view schema class, there is no ui update in the custom editor. Tried to run the same code inside Help View for testing and it's running smoothly. Can you help me out as can't see the exact ui outputs for this and next video. Below is the snapshot of the editor and assets.
    Click image for larger version. 

Name:	20160419_152334.jpg 
Views:	97 
Size:	1.69 MB 
ID:	74619
    Also find attached the relevant cs files.
    Code:
    GraphPropertyView.cs
    
    	public class GraphPropertyView : BaseView {
    
    		private Vector2 _scrollPos;
    
    		public GraphPropertyView() : base("Property View") {
    
    		}
    
    		public override void UpdateView(Rect editorRect, Rect percentageRect, Event @event, Common.Editor.Graph.GraphSchema graph) {
    			base.UpdateView (editorRect, percentageRect, @event, graph);
    
    			GUI.Box(viewRect, "", viewSkin.GetStyle("PropertyViewBG"));
    
    			GUILayout.BeginArea(viewRect); {
    				if(currentGraph != null && currentGraph.showProperties) {
    					if(currentGraph.selectedNode != null && currentGraph.selectionNodes != null && currentGraph.selectionNodes.Count == 1) {
    						if(currentGraph.selectedNode.list == null) {
    							currentGraph.selectedNode.list = new UnityEditorInternal.ReorderableList(
    								currentGraph.selectedNode.relatedNode.metaData, typeof(List<InlineValue>), true, true, true, true);
    
    							_scrollPos = GUILayout.BeginScrollView(_scrollPos); {
    								currentGraph.selectedNode.DrawNodeProperties();
    
    								GUILayout.Space(3);
    
    								GUILayout.BeginHorizontal(); {
    									GUILayout.Space(5);
    									GUILayout.BeginVertical(); {
    										GUIUtils.DrawValuesList(currentGraph.selectedNode.relatedNode.metaData, 
    											currentGraph.selectedNode.list, 
    											currentGraph.selectedNode.relatedNode.nodeName + " Meta Data");
    									}
    									GUILayout.EndVertical();
    									GUILayout.Space(5);
    								}
    								GUILayout.EndHorizontal();
    							}
    							GUILayout.EndScrollView();
    						}
    					} else {
    						//TODO: Add showing the property for the graph itself containing all the graph variables.
    					}
    				}
    			}
    			GUILayout.EndArea();
    		}
    	}
    NodeSchemaProperties.cs
    Code:
    	public partial class NodeSchema {
    	
    		public virtual void DrawNodeProperties() {
    			TextEditor te = new TextEditor();
    
    			GUILayout.Space(3);
    			GUILayout.BeginHorizontal(); {
    				GUILayout.Space(5);
    				GUILayout.Label("Name", nodeSkin.GetStyle("PropertyLabel"), GUILayout.Width(45));
    				GUILayout.Space(5);
    				relatedNode.nodeName = GUILayout.TextField(relatedNode.nodeName, nodeSkin.GetStyle("EditorText"), GUILayout.ExpandWidth(true));
    				GUILayout.Space(5);
    
    				if(GUILayout.Button("Copy", nodeSkin.GetStyle("PropertyButton"), GUILayout.Width(40))) {
    					te.text = relatedNode.nodeName;
    					te.SelectAll();
    					te.Copy();
    				}
    				GUILayout.Space(5);
    			}
    			GUILayout.EndHorizontal();
    
    			GUILayout.Space(3);
    			GUILayout.BeginHorizontal(); {
    				GUILayout.Space(5);
    				GUILayout.Label(relatedNode.uid, nodeSkin.GetStyle("GuidID"), GUILayout.ExpandWidth(true));
    
    				if(GUILayout.Button("Copy UID", nodeSkin.GetStyle("PropertyButton"), GUILayout.Width(40))) {
    					te.text = relatedNode.uid.ToString();
    					te.SelectAll();
    					te.Copy();
    				}
    				GUILayout.Space(5);
    
    				if(GUILayout.Button("Copy GUID", nodeSkin.GetStyle("PropertyButton"), GUILayout.Width(72))) {
    					te.text = relatedNode.uid.MyGuid.ToString();
    					te.SelectAll();
    					te.Copy();
    				}
    				GUILayout.Space(5);
    			}
    			GUILayout.EndHorizontal();
    
    			GUILayout.Space(3);
    			GUILayout.BeginHorizontal(); {
    				GUILayout.Space(5);
    				GUILayout.Label("Comment", nodeSkin.GetStyle("PropertyLabel"), GUILayout.Width(70));
    				GUILayout.Space(5);
    				comment = GUILayout.TextField(comment, nodeSkin.GetStyle("EditorText"), GUILayout.ExpandHeight(true));
    				GUILayout.Space(5);
    			}
    			GUILayout.EndHorizontal();
    		}
    	}
    GUIUtils.class
    Code:
    	public static class GUIUtils {
    		
    		public static ReorderableList DrawValuesList(List<InlineValue> values, ReorderableList list, string header) {
    			list.drawHeaderCallback = rect => {
    				EditorGUI.LabelField(rect, header);	
    			};
    
    			list.drawElementBackgroundCallback = (rect, index, isActive, isFocused) => {
    				var element = (InlineValue)list.list[index];
    				float height = EditorGUIUtility.singleLineHeight;
    				var type = element.dataType;
    				element.name = EditorGUI.TextField(new Rect(rect.x, rect.y, 50, 50), element.name);
    				element.dataType = (DataType) EditorGUI.EnumPopup(new Rect(rect.x + 51, rect.y, 75, height), element.dataType);
    				float box = rect.width - 138 / 4 - 13.1f;
    				if(type == DataType.BOOL) {
    					element.boolValue = EditorGUI.Toggle(new Rect(rect.x + 128, rect.y, rect.width - 128, rect.height), element.boolValue);
    				} else if(type == DataType.INT) {
    					element.intValue = EditorGUI.IntField(new Rect(rect.x + 128, rect.y, rect.width - 128, rect.height), element.intValue);
    				} else if(type == DataType.FLOAT) {
    					element.floatValue = EditorGUI.FloatField(new Rect(rect.x + 128, rect.y, rect.width - 128, rect.height), element.floatValue);
    				} else if(type == DataType.STRING) {
    					element.stringValue = EditorGUI.TextField(new Rect(rect.x + 128, rect.y, rect.width - 128, rect.height), element.stringValue);
    				} else if(type == DataType.RECT) {
    					EditorGUI.LabelField(new Rect(rect.x + 128, rect.y, 13, rect.height), "x");
    					element.rectValue.x = EditorGUI.FloatField(new Rect(rect.x + 142, rect.y, box, rect.height), element.rectValue.x);
    					EditorGUI.LabelField(new Rect(rect.x + 142 + box, rect.y, 13, rect.height), "y");
    					element.rectValue.y = EditorGUI.FloatField(new Rect(rect.x + 158 + box, rect.y, box, rect.height), element.rectValue.y);
    					EditorGUI.LabelField(new Rect(rect.x + 159 + 2 * box, rect.y, 14, rect.height), "w");
    					element.rectValue.width = EditorGUI.FloatField(new Rect(rect.x + 175 + 2 * box, rect.y, box, rect.height), element.rectValue.width);
    					EditorGUI.LabelField(new Rect(rect.x + 177 + 3 * box, rect.y, 13, rect.height), "h");
    					element.rectValue.height = EditorGUI.FloatField(new Rect(rect.x + 191 + 3 * box, rect.y, box, rect.height), element.rectValue.height);
    				} else if(type == DataType.VECTOR2) {
    
    				} else if(type == DataType.VECTOR3) {
    
    				} else if(type == DataType.VECTOR4) {
    
    				} else if(type == DataType.QUATERNION) {
    
    				} else if(type == DataType.RECT) {
    
    				} else if(type == DataType.COLOR) {
    
    				} else if(type == DataType.ANIMCURVE) {
    
    				} else {
    					
    				}
    			};
    
    			list.onChangedCallback = l => {
    				values = (List<InlineValue>)l.list;
    			};
    
    			list.DoLayoutList();
    
    			return list;
    		}
    	}

  2. #2
    Join Date
    Jun 2008
    Location
    Iran / Tehran
    Posts
    285
    sorry if it's toooo late for the answer, I never paid attention to the threads inside the play list and i just found out that there were few posts there. it's long time scense i didn't open that solution, hopefully i will get time to continue the series soon because some job is left to be done for chapter two and i want to get back to this project myself, but....
    as much as i remember on top of my head, that code looks correct, although i remember that i tweaked it a little here and there during the second chapter and hopefully it should work, the only thing i see in this snippet that can cause the property view to not show the properties, is the condition on top of the first code snippet, it actually asks if you have a graph then asks if you have selected nodes and asks if you selected a single node, if those conditions are met, then it would read the node's draw property method.
    so, if this snippet is correct and there is no typo in there, i suggest you double check the code related to selection of nodes and i assume it was somewhere in the graphschema class. make sure everything is up to date and correct.
    If you want to learn something, start teaching about it to others, nothing will help you more than that !

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •