Esempio n. 1
0
        // Inspector 表示
        public override void OnInspectorGUI()
        {
            AssetCatalog t = this.target as AssetCatalog;
            Dictionary <string, AssetCatalog.SettingParam> dic = t.editParamDic;

            GUILayout.Space(5f);
            // Prefab 設定
            System.Array enumArray   = System.Enum.GetValues(typeof(U));
            int          objectCount = enumArray.Length;

            for (int i = 0; i < objectCount; ++i)
            {
                string key = enumArray.GetValue(i).ToString();
                AssetCatalog.SettingParam param = dic[key];
                GUILayout.BeginHorizontal();
                GUIContent content = new GUIContent(i.ToString("D3") + " " + key,
                                                    "Asset 指定");
                dic[key].origin = EditorGUILayout.ObjectField(content,
                                                              param.origin,
                                                              typeof(T),
                                                              false,
                                                              GUILayout.MinWidth(250f)) as T;
                dic[key].genCount = EditorGUILayout.IntField(param.genCount,
                                                             GUILayout.MaxWidth(100f));
                GUILayout.EndHorizontal();
            }
            if (GUI.changed || (objectCount != t.GetCatalogCount()))
            {
                t.UpdateSerializedList <U>();
                EditorUtility.SetDirty(t);
            }
        }
Esempio n. 2
0
        // 有効時
        void OnEnable()
        {
            AssetCatalog t = this.target as AssetCatalog;

            if (t != null)
            {
                bool changed = t.CreateDictionary <U>();
                // enum が増減していたら変更されてくる
                if (changed)
                {
                    t.UpdateSerializedList <U>();
                    EditorUtility.SetDirty(t);
                }
            }
        }
Esempio n. 3
0
        // 初期化
        // category : オブジェクトのカテゴリ指定
        // catalog : 複製オブジェクトカタログ
        public void Initialize(int category, AssetCatalog catalog)
        {
            // 初期化エラーチェック
            Debug.Assert(catalog != null && catalog.GetCatalogCount() > 0);
            this.category  = category;
            this.typeCount = catalog.GetCatalogCount();
            this.objList   = new T[this.typeCount][];
            this.objParams = new ObjectParam[this.typeCount];
            int capacity = 0;

            for (int type = 0; type < this.typeCount; ++type)
            {
                int genMax = catalog.GetGenerateCount(type);
                if (genMax == 0)
                {
                    continue;
                }
                this.objList[type]             = new T[genMax];
                this.objParams[type].pool      = new T[genMax];
                this.objParams[type].freeIndex = -1;
                Object prefab = catalog.GetObject(type);
                // 開発用にまだPrefab が用意されていない場合を考慮してnull を許容する
                if (prefab == null)
                {
                    continue;
                }
                this.objParams[type].genMax   = genMax;
                this.objParams[type].genCount = 0;
                this.objParams[type].prefab   = prefab as GameObject;
                // 親ノード作成
                GameObject typeGo = new GameObject(prefab.name);
                typeGo.isStatic = true;
                Transform typeRoot = typeGo.transform;
                this.objParams[type].root = typeRoot;
                // MEMO: シーン切替で自動で削除させない
                Object.DontDestroyOnLoad(typeGo);
                capacity += genMax;
            }
            this.activeObjTask = new TaskSystem <T>(capacity);
        }