コード例 #1
0
        // INITIALIZE: ----------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }

            this.spStatsAsset         = serializedObject.FindProperty("statsAsset");
            this.spAttributesAsset    = serializedObject.FindProperty("attrsAsset");
            this.spStatusEffectsAsset = serializedObject.FindProperty("statusEffectsAsset");

            if (this.spStatsAsset.objectReferenceValue == null)
            {
                string     path       = Path.Combine(ASSETS_PATH, STATSASSET_FILE);
                StatsAsset statsAsset = AssetDatabase.LoadAssetAtPath <StatsAsset>(path);

                if (statsAsset == null)
                {
                    statsAsset = CreateStatsAsset();
                }
                this.spStatsAsset.objectReferenceValue = statsAsset;

                serializedObject.ApplyModifiedPropertiesWithoutUndo();
                serializedObject.Update();
            }

            if (this.spAttributesAsset.objectReferenceValue == null)
            {
                string     path            = Path.Combine(ASSETS_PATH, ATTRSASSET_FILE);
                AttrsAsset attributesAsset = AssetDatabase.LoadAssetAtPath <AttrsAsset>(path);

                if (attributesAsset == null)
                {
                    attributesAsset = CreateAttributesAsset();
                }
                this.spAttributesAsset.objectReferenceValue = attributesAsset;

                serializedObject.ApplyModifiedPropertiesWithoutUndo();
                serializedObject.Update();
            }

            if (this.spStatusEffectsAsset.objectReferenceValue == null)
            {
                string             path = Path.Combine(ASSETS_PATH, STAEFASSET_FILE);
                StatusEffectsAsset statusEffectsAsset = AssetDatabase.LoadAssetAtPath <StatusEffectsAsset>(path);

                if (statusEffectsAsset == null)
                {
                    statusEffectsAsset = CreateStatusEffectsAsset();
                }
                this.spStatusEffectsAsset.objectReferenceValue = statusEffectsAsset;

                serializedObject.ApplyModifiedPropertiesWithoutUndo();
                serializedObject.Update();
            }

            this.statsAssetEditor         = (StatsAssetEditor)CreateEditor(this.spStatsAsset.objectReferenceValue);
            this.attrsAssetEditor         = (AttrsAssetEditor)CreateEditor(this.spAttributesAsset.objectReferenceValue);
            this.statusEffectsAssetEditor = (StatusEffectsAssetEditor)CreateEditor(this.spStatusEffectsAsset.objectReferenceValue);
        }
コード例 #2
0
        public static StatusEffectsAsset GetStatusEffectsAsset()
        {
            string             path = Path.Combine(ASSETS_PATH, STAEFASSET_FILE);
            StatusEffectsAsset statusEffectsAsset = AssetDatabase.LoadAssetAtPath <StatusEffectsAsset>(path);

            if (statusEffectsAsset == null)
            {
                statusEffectsAsset = CreateStatusEffectsAsset();
            }
            return(statusEffectsAsset);
        }
コード例 #3
0
        // INITIALIZERS: --------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            this.instance = (StatusEffectsAsset)target;

            this.spStatusEffects    = serializedObject.FindProperty("statusEffects");
            this.editorSortableList = new EditorSortableList();

            this.UpdateSubEditors(this.instance.statusEffects);
        }
コード例 #4
0
        public static StatusEffectsAsset CreateStatusEffectsAsset()
        {
            string filepath = ASSETS_PATH;
            string filename = STAEFASSET_FILE;

            StatusEffectsAsset asset = ScriptableObject.CreateInstance <StatusEffectsAsset>();

            GameCreatorUtilities.CreateFolderStructure(filepath);
            string path = Path.Combine(filepath, filename);

            path = AssetDatabase.GenerateUniqueAssetPath(path);

            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.ImportAsset(path);
            return(asset);
        }