Unity編輯器生成可配置編輯文件
阿新 • • 發佈:2017-09-06
prefab tga 可編輯 edit 字段 work highlight save csharp
using UnityEditor; public class PoolManagerEditor { [MenuItem("Manager/Creat GameObjectPoolConfig")] static void CreatGameObjectPoolList() { GameObjectPoolList poolList = ScriptableObject.CreateInstance<GameObjectPoolList>();//生成可編輯對象 string path [email protected]"Assets/Framework/Resources/gameobjectpool.asset";//保存的路徑 AssetDatabase.CreateAsset(poolList,path);//第一步 AssetDatabase.SaveAssets();//第二步 } }
GameObjectPool類
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; [Serializable] public class GameObjectPool { [SerializeField]//類的私有字段,又可在Unity編輯器上列出 private string name; [SerializeField] private GameObject prefab; [SerializeField] private int maxAmount; [NonSerialized] private List<GameObject> goList = new List<GameObject>(); }
GameObjectPoolList類
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; [Serializable] public class GameObjectPoolList : ScriptableObject { public List<GameObjectPool> poolList; }
Unity編輯器生成可配置編輯文件