protected void OnEnable() { titleContent = new GUIContent("Node Explorer", EditorGUIUtility.Load("React/ReactIcon.png") as Texture2D); categories["Core"] = new List <SearchResult>(); foreach (var registeredType in ReactTypeRegister.AllTypes) { var type = registeredType.type; if (ReactTypeRegister.IsCoreNode(type) || ReactTypeRegister.IsCoreDecorator(type)) { categories["Core"].Add(new SearchResult() { niceName = registeredType.niceName, type = registeredType.type, signature = registeredType.signature }); } else { var parts = registeredType.menuPath.Split('/'); List <SearchResult> results; if (!categories.TryGetValue(parts[0], out results)) { results = categories[parts[0]] = new List <SearchResult>(); } results.Add(new SearchResult() { niceName = registeredType.niceName, type = registeredType.type, signature = registeredType.signature }); } } view = position; }
internal bool IsValidParent(System.Type childType, BaseNode parent) { var childIsCore = ReactTypeRegister.IsCoreDecorator(childType); if (childType == typeof(Root)) { return(false); } var parentIsRoot = parent == root; if (parentIsRoot && !childIsCore) { return(false); } if (parentIsRoot && childIsCore && childType != typeof(OnMessage)) { foreach (var child in ((IParentNode)parent).GetChildren()) { if (child.GetType() == childType) { return(false); } } } if (!(parent is IParentNode)) { return(false); } if (childIsCore && !parentIsRoot) { return(false); } return(true); }
void PerformDrag() { Undo.RecordObject(target, "Drag & Drop"); var oldParent = dragNode.nodeParent as IParentNode; var newParent = dropZone.parent as IParentNode; if (ReactTypeRegister.IsCoreDecorator(dragNode.GetType()) && newParent != root) { EditorApplication.Beep(); return; } newParent.Insert(dropZone.index, BaseNode.Clone(dragNode)); if (!Event.current.shift) { oldParent.Remove(dragNode); } ExitDrag(); }
public void LoadDefaultResults() { foreach (var registeredType in ReactTypeRegister.AllTypes) { var type = registeredType.type; if (ReactTypeRegister.IsCoreNode(type) || ReactTypeRegister.IsCoreDecorator(type)) { if (target.IsValidParent(registeredType.type, target.reactor.hotNode)) { searchResults.Add(new SearchResult() { niceName = registeredType.niceName, type = registeredType.type, signature = registeredType.signature }); } } } searchResults.Sort((A, B) => A.niceName.CompareTo(B.niceName)); titleContent = new GUIContent("Node Search", EditorGUIUtility.Load("React/ReactIcon.png") as Texture2D); }
void DrawDecorator(DecoratorNode decorator) { //if node is a decorator, draw child and widgets. if (decorator != null) { if (ReactTypeRegister.IsCoreDecorator(decorator.GetType())) { DrawCoreDecorator(decorator); } if (decorator.Child != null) { cursor.x += decorator.rect.width + SPACING.x; cursor.y -= decorator.rect.height + SPACING.x / 2; Draw(decorator.Child, decorator); // var left = decorator.rect.xMax; // var mid = decorator.rect.center.y; // var right = decorator.Child.rect.xMin; // ReactEditorUtility.DrawLine(new Vector2(left, mid), new Vector3(right, mid), Color.white); cursor.x -= decorator.rect.width + SPACING.x; } dropZones.Add(new DropZone(decorator, decorator.rect)); } }