Beispiel #1
0
 private void DrawSystemSort(SystemSort sort, SystemType systemType)
 {
     GUILayoutExtension.HorizontalGroup(() =>
     {
         EditorGUILayout.LabelField(sort.typeName);
         MiscHelper.Btn("Up", 50, 35, () =>
         {
             sort.sort--;
             UpdateSystemSort();
         });
         MiscHelper.Btn("Down", 50, 35, () =>
         {
             sort.sort++;
             UpdateSystemSort();
         });
         MiscHelper.Btn("Del", 50, 35, () =>
         {
             sortAsset.GetSystemSorts(systemType).Remove(sort);
             UpdateSystemSort();
         });
         MiscHelper.Dropdown(systemType.ToString(), systemTyps, (int x) =>
         {
             SystemType newType = (SystemType)x;
             if (newType == systemType)
             {
                 return;
             }
             sortAsset.GetSystemSorts(systemType).Remove(sort);
             sortAsset.GetSystemSorts(newType).Add(sort);
             UpdateSystemSort();
         });
     });
 }
Beispiel #2
0
        public SystemSort GetSystemSort(string fullName)
        {
            SystemSort sort = GetSystemSort(updateSystems, fullName);

            if (sort != null)
            {
                return(sort);
            }
            sort = GetSystemSort(fixedUpdateSystems, fullName);
            if (sort != null)
            {
                return(sort);
            }
            sort = GetSystemSort(threadSystems, fullName);
            if (sort != null)
            {
                return(sort);
            }
            return(null);
        }
Beispiel #3
0
        private void OnEnable()
        {
            systemTyps.Clear();
            foreach (var item in Enum.GetNames(typeof(SystemType)))
            {
                systemTyps.Add(item);
            }

            sortAsset = target as SystemSortAsset;
            foreach (var item in ReflectionHelper.GetChildTypes <BaseSystem>())
            {
                if (sortAsset.GetSystemSort(item.FullName) == null)
                {
                    SystemSort sort = new SystemSort();
                    sort.typeName     = item.Name;
                    sort.typeFullName = item.FullName;
                    sort.sort         = sortAsset.updateSystems.Count;
                    sortAsset.updateSystems.Add(sort);
                }
            }
        }
Beispiel #4
0
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            MiscHelper.Btn("清除废弃系统", 250, 35, () =>
            {
                for (int i = 0; i < sortAsset.updateSystems.Count; i++)
                {
                    SystemSort sort = sortAsset.updateSystems[i];
                    if (ReflectionHelper.GetType(sort.typeFullName) == null)
                    {
                        sortAsset.updateSystems.RemoveAt(i);
                    }
                }

                for (int i = 0; i < sortAsset.fixedUpdateSystems.Count; i++)
                {
                    SystemSort sort = sortAsset.fixedUpdateSystems[i];
                    if (ReflectionHelper.GetType(sort.typeFullName) == null)
                    {
                        sortAsset.fixedUpdateSystems.RemoveAt(i);
                    }
                }

                for (int i = 0; i < sortAsset.threadSystems.Count; i++)
                {
                    SystemSort sort = sortAsset.threadSystems[i];
                    if (ReflectionHelper.GetType(sort.typeFullName) == null)
                    {
                        sortAsset.threadSystems.RemoveAt(i);
                    }
                }

                UpdateSystemSort();
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label($"系统运行排序", bigLabel.value);
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label(" ----------- Update ----------- ", bigLabel.value);
                List <SystemSort> upSorts = sortAsset.GetSystemSorts(SystemType.Update);
                for (int i = 0; i < upSorts.Count; i++)
                {
                    DrawSystemSort(upSorts[i], SystemType.Update);
                }

                GUILayout.Label(" ----------- FixedUpdate ----------- ", bigLabel.value);
                List <SystemSort> fixedSorts = sortAsset.GetSystemSorts(SystemType.FixedUpdate);
                for (int i = 0; i < fixedSorts.Count; i++)
                {
                    DrawSystemSort(fixedSorts[i], SystemType.FixedUpdate);
                }

                //GUILayout.Label(" ----------- Thread ----------- ", bigLabel.value);
                //List<SystemSort> threadSorts = sortAsset.GetSystemSorts(SystemType.Thread);
                //for (int i = 0; i < threadSorts.Count; i++)
                //{
                //    DrawSystemSort(threadSorts[i], SystemType.Thread);
                //}
            });
        }