private void OnEnable()
 {
     script         = serializedObject.FindProperty("m_Script");
     graphListProp  = serializedObject.FindProperty("graphList");
     resetMenuProp  = serializedObject.FindProperty("resetMenu");
     menuProp       = serializedObject.FindProperty("menu");
     tempGraph      = ScriptableObject.CreateInstance <BridgeUI.Graph.UIGraph>();
     tempGraphObj   = new SerializedObject(tempGraph);
     bundleInfoList = new UIInfoListDrawer("资源包");
     bundleInfoList.InitReorderList(tempGraphObj.FindProperty("b_nodes"));
     prefabInfoList = new UIInfoListDrawer("预制体");
     prefabInfoList.InitReorderList(tempGraphObj.FindProperty("p_nodes"));
     UpdateMarchList();
 }
Beispiel #2
0
        protected override void DrawElementCallBack(Rect rect, int index, bool isActive, bool isFocused)
        {
            base.DrawElementCallBack(rect, index, isActive, isFocused);
            var prop      = property.GetArrayElementAtIndex(index);
            var graphGUID = prop.stringValue;

            BridgeUI.Graph.UIGraph graph = null;
            if (!string.IsNullOrEmpty(graphGUID))
            {
                var path = AssetDatabase.GUIDToAssetPath(graphGUID);
                if (!string.IsNullOrEmpty(path))
                {
                    graph = AssetDatabase.LoadAssetAtPath <Graph.UIGraph>(path);
                }
            }

            var graphName = graph == null ? "empty" : graph.name;

            rect = BridgeEditorUtility.DrawBoxRect(rect, index.ToString("00"));

            var btnRect = new Rect(rect.x, rect.y, rect.width - 30, EditorGUIUtility.singleLineHeight);

            if (GUI.Button(btnRect, graphName, EditorStyles.toolbarButton))
            {
                AssetDatabase.OpenAsset(graph);
            }

            btnRect = new Rect(rect.x + rect.width - 30, rect.y, 30, EditorGUIUtility.singleLineHeight);

            if (graph != null)
            {
                if (GUI.Button(btnRect, " ", EditorStyles.objectFieldMiniThumb))
                {
                    EditorGUIUtility.PingObject(graph);
                }
                DragGroupObj(btnRect, prop);
            }
            else
            {
                var graphNew = EditorGUI.ObjectField(btnRect, graph, typeof(BridgeUI.Graph.UIGraph), false) as Graph.UIGraph;
                if (graphNew != null && graphNew != graph)
                {
                    SetProperyValue(prop, graphNew);
                }
            }
        }