예제 #1
0
        /// <summary>
        ///     Shrinks the data arrays in the RpgDataRegistry if they have null references
        /// </summary>
        private static void CleanNullReferencesFromRpgRegistry()
        {
            // Find the RpgDataRegistry
            RpgDataRegistry registry = RpgDataAssetUtility.FindRpgDataRegistry();

            // Clean the arrays in the registry of null references
            registry.CleanMissingReferences();
        }
        private static void CreateAbilityAsset()
        {
            Ability newData = CustomDataAssetUtility.CreateAndReturnDataAsset <Ability>();

            newData.Init();

            RpgDataRegistry registry = RpgDataAssetUtility.FindRpgDataRegistry();

            RpgRegistryUtility.AdderOfAbility newAdder;
            newAdder.ability = newData;
            registry.AddRpgDataObject(newAdder);
        }
        private static void CreateSkillStatAsset()
        {
            SkillStat newData = CustomDataAssetUtility.CreateAndReturnDataAsset <SkillStat>();

            newData.Init();

            RpgDataRegistry registry = RpgDataAssetUtility.FindRpgDataRegistry();

            RpgRegistryUtility.AdderOfSkillStat newAdder;
            newAdder.skillStat = newData;
            registry.AddRpgDataObject(newAdder);
        }
        private static void CreateXpProgressorAsset()
        {
            XpProgressor newData = CustomDataAssetUtility.CreateAndReturnDataAsset <XpProgressor>();

            newData.Init();

            RpgDataRegistry registry = RpgDataAssetUtility.FindRpgDataRegistry();

            RpgRegistryUtility.AdderOfXpProgressor newAdder;
            newAdder.xpProgressor = newData;
            registry.AddRpgDataObject(newAdder);
        }
        /// <summary>
        ///     Searches the Unity project for the prefab that holds the only instance of RpgDataRegistryObject.
        ///     Editor only.
        /// </summary>
        public static RpgDataRegistry FindRpgDataRegistry()
        {
            if (RpgDataAssetUtility.rpgRegistryInstance == null)
            {
                string[] folders       = { RpgDataAssetUtility.RpgSystemProjectPath };
                string[] searchResults = AssetDatabase.FindAssets(RpgDataRegistry.RpgRegistryPrefabName, folders);

                if (searchResults == null)
                {
                    Debug.LogError("Could not find the prefab RpgDataRegistryObject in the project! Did someone move or delete it?");
                    RpgDataAssetUtility.rpgRegistryInstance = null;
                }
                else
                {
                    // Get the path of the given GUIDs
                    string path = AssetDatabase.GUIDToAssetPath(searchResults[0]);

                    // Get the GameObject from the path
                    GameObject registryObject = AssetDatabase.LoadAssetAtPath <GameObject>(path);

                    Object oldSelection = Selection.activeObject;
                    Selection.activeObject = registryObject;

                    // Get the registry from the game object
                    RpgDataRegistry theRegistry = registryObject.GetComponent <RpgDataRegistry>();
                    if (theRegistry == null)
                    {
                        Debug.LogError("RpgDataRegistry is missing from the associated prefab RpgDataRegistryObject!");
                    }

                    Selection.activeObject = oldSelection;

                    RpgDataAssetUtility.rpgRegistryInstance = theRegistry;
                }
            }

            return(RpgDataAssetUtility.rpgRegistryInstance);
        }
예제 #6
0
 void OnEnable()
 {
     this.registry = target as RpgDataRegistry;
 }