コード例 #1
0
        private void DrawGroupList()
        {
            if (groupList == null)
            {
                groupList = new ReorderableList(serializedObject, graphListProp, true, true, true, true);
                groupList.drawHeaderCallback = (rect) =>
                {
                    EditorGUI.LabelField(rect, "界面配制图表");
                };
                groupList.drawElementCallback = (rect, index, isActive, isFocused) =>
                {
                    var prop    = graphListProp.GetArrayElementAtIndex(index);
                    var key     = prop.FindPropertyRelative("graphName");
                    var guid    = prop.FindPropertyRelative("guid");
                    var btnRect = new Rect(rect.x, rect.y + 2, rect.width - 30, EditorGUIUtility.singleLineHeight);

                    if (GUI.Button(btnRect, key.stringValue, EditorStyles.miniButton))
                    {
                        var path = AssetDatabase.GUIDToAssetPath(guid.stringValue);
                        if (!string.IsNullOrEmpty(path))
                        {
                            NodeGraph.DataModel.NodeGraphObj graph = AssetDatabase.LoadAssetAtPath <NodeGraph.DataModel.NodeGraphObj>(path);
                            AssetDatabase.OpenAsset(graph);
                        }
                    }
                    btnRect = new Rect(rect.x + rect.width - 30, rect.y + 2, 30, EditorGUIUtility.singleLineHeight);

                    if (!string.IsNullOrEmpty(guid.stringValue) && !String.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(guid.stringValue)))
                    {
                        if (GUI.Button(btnRect, " ", EditorStyles.objectFieldMiniThumb))
                        {
                            var path = AssetDatabase.GUIDToAssetPath(guid.stringValue);
                            if (!string.IsNullOrEmpty(path))
                            {
                                EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <NodeGraph.DataModel.NodeGraphObj>(path));
                            }
                        }
                        DragGroupObj(btnRect, prop);
                    }
                    else
                    {
                        var obj = EditorGUI.ObjectField(btnRect, null, typeof(NodeGraph.DataModel.NodeGraphObj), false);
                        if (obj)
                        {
                            var path = AssetDatabase.GetAssetPath(obj);
                            guid.stringValue = AssetDatabase.AssetPathToGUID(path);
                            key.stringValue  = obj.name;
                            prop.serializedObject.ApplyModifiedProperties();
                        }
                    }
                };
            }
            groupList.DoLayoutList();
        }
コード例 #2
0
        internal static NodeGraphController CreateController(NodeGraph.DataModel.NodeGraphObj graph)
        {
            var type = CustomControllerTypes.Find(x => x.FullName == graph.ControllerType);

            if (type != null)
            {
                var ctrl  = System.Activator.CreateInstance(type);
                var gctrl = ctrl as NodeGraphController;
                gctrl.TargetGraph = graph;
                return(gctrl);
            }
            else
            {
                Debug.LogError("can not find controllerType:" + graph.ControllerType);
                return(null);
            }
        }
コード例 #3
0
 protected virtual void DrawGraphItems()
 {
     GUI.backgroundColor = Color.yellow;
     EditorGUILayout.LabelField("界面配制图表", EditorStyles.helpBox);
     GUI.backgroundColor = Color.white;
     for (int i = 0; i < graphListProp.arraySize; i++)
     {
         var item = graphListProp.GetArrayElementAtIndex(i);
         var key  = item.FindPropertyRelative("graphName");
         var guid = item.FindPropertyRelative("guid");
         if (GUILayout.Button(key.stringValue, EditorStyles.toolbarButton))
         {
             var path = AssetDatabase.GUIDToAssetPath(guid.stringValue);
             if (!string.IsNullOrEmpty(path))
             {
                 NodeGraph.DataModel.NodeGraphObj graph = AssetDatabase.LoadAssetAtPath <NodeGraph.DataModel.NodeGraphObj>(path);
                 AssetDatabase.OpenAsset(graph);
             }
         }
     }
 }