Esempio n. 1
0
        private void SetupCategories()
        {
            if (DisplayGroups != null && DisplayGroups.Count > 0)
            {
                return;
            }

            // Add all states to list for lookup
            Type[]        assemblyTypes = UnityReflectionUtil.GetTypesInAssembly(typeof(State));
            List <string> groupsTypes   = new List <string> ();

            // We only want to check once as they'll update when Unity recompiles
            DisplayGroups = new Dictionary <string, List <StateName> > ();

            // Create cached arrays to have quick references
            StateNames = new string[assemblyTypes.Length];

            // Get each state
            for (int i = 0; i < assemblyTypes.Length; i++)
            {
                // Get state data
                string stateName   = assemblyTypes[i].FullName;
                string displayName = GetStateName(stateName);

                string group = GetGroupName(stateName);

                StateName name = new StateName(stateName, displayName);
                if (DisplayGroups.ContainsKey(group))
                {
                    DisplayGroups[group].Add(name);
                }
                else
                {
                    DisplayGroups.Add(group, new List <StateName> ()
                    {
                        name
                    });
                }

                StateNames[i] = stateName;
                groupsTypes.Add(group);
            }

            GroupNames = groupsTypes.ToArray();
        }
Esempio n. 2
0
        private void OnSerialize()
        {
            //Get state types
            if (StateTypes == null)
            {
                StateTypes = UnityReflectionUtil.GetTypesInAssembly(typeof(State));
            }

            //Return if no states exist
            if (StateTypes == null || StateTypes.Length == 0)
            {
                Debug.LogWarning("Cannot find any state types in the project.");
                return;
            }
            else
            if (RegisteredStates == null)
            {
                Initialize();
            }
        }