/// <summary>
        /// 绘制流程
        /// </summary>
        /// <param name="root"></param>
        /// <param name="allProcedureNames"></param>
        private void DrawProcedures(Component root, string[] allProcedureNames)
        {
            GUILayout.Space(5);

            if (EditorApplication.isPlaying)
            {
                InspectorTool.LabelBox("GUI Procedures:", () =>
                {
                    EditorGUILayout.HelpBox("Stop running to modify.", MessageType.Info);
                });
                return;
            }

            InspectorTool.LabelBox("GUI Procedures:", () =>
            {
                if (allProcedureNames.Length <= 0)
                {
                    EditorGUILayout.HelpBox("No optional procedure", MessageType.Info);
                    return;
                }

                InspectorTool.Vertical(() =>
                {
                    foreach (var procedureName in allProcedureNames)
                    {
                        bool selected = currentAvailableProcedureTypeNames.Contains(procedureName);
                        if (selected != EditorGUILayout.ToggleLeft(procedureName, selected))
                        {
                            if (!selected)
                            {
                                currentAvailableProcedureTypeNames.Add(procedureName);
                                WriteAvailableProcedureTypeNames();
                            }
                            else
                            {
                                currentAvailableProcedureTypeNames.Remove(procedureName);
                                WriteAvailableProcedureTypeNames();
                            }
                        }
                    }
                });
            });


            if (currentAvailableProcedureTypeNames.Count > 0)
            {
                EditorGUILayout.Separator();

                int selectedIndex = EditorGUILayout.Popup("Entrance Procedure", entranceProcedureIndex, currentAvailableProcedureTypeNames.ToArray());
                if (selectedIndex != entranceProcedureIndex)
                {
                    entranceProcedureIndex = selectedIndex;
                    entranceProcedureTypeName.stringValue = currentAvailableProcedureTypeNames[selectedIndex];
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Select available procedures first.", MessageType.Info);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 绘制服务提供者
        /// </summary>
        /// <param name="root">根节点信息</param>
        /// <param name="serviceProviders">服务提供者列表</param>
        private void DrawServiceProvider(Component root, IDictionary <Type, Component> serviceProviders)
        {
            GUILayout.Space(5);

            if (EditorApplication.isPlaying)
            {
                InspectorTool.LabelBox("GUI Service Providers:", () =>
                {
                    EditorGUILayout.HelpBox("Stop running to modify.", MessageType.Info);
                });
                return;
            }

            var reload = false;

            InspectorTool.LabelBox("GUI Service Providers:", () =>
            {
                if (serviceProviders.Count <= 0)
                {
                    EditorGUILayout.HelpBox("No optional service provider", MessageType.Info);
                    return;
                }

                foreach (var providerAndGameObject in serviceProviders)
                {
                    var enable = providerAndGameObject.Value != null;
                    InspectorTool.Horizontal(() =>
                    {
                        reload = ToggleProvider(root.gameObject, providerAndGameObject.Key, providerAndGameObject.Value) != enable || reload;

                        if (InspectorTool.Button("Go", "Goto The GameObject", enable, 40, 16) && enable)
                        {
                            Selection.activeObject = providerAndGameObject.Value;
                        }
                    });
                }
            });

            if (reload)
            {
                RefreshServiceProviders();
            }
        }