Unity编辑器生成可配置编辑文件

using UnityEditor;

public class PoolManagerEditor {
    [MenuItem("Manager/Creat GameObjectPoolConfig")]
    static void CreatGameObjectPoolList()
    {
        GameObjectPoolList poolList = ScriptableObject.CreateInstance();//生成可编辑对象
        string path =@"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 goList = new List();
	
}

  

GameObjectPoolList类
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
[Serializable]
public class GameObjectPoolList : ScriptableObject {
    public List poolList;
}

  

转载于:https://www.cnblogs.com/trlq/p/7482478.html

你可能感兴趣的:(Unity编辑器生成可配置编辑文件)