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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity编辑器生成可配置编辑文件相关的知识,希望对你有一定的参考价值。

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编辑器生成可配置编辑文件的主要内容,如果未能解决你的问题,请参考以下文章

Unity3d使用TexturePacker制作Atlas

unity编辑器扩展一批量生成图片预制

Unity 之 实现读取代码写进Word文档功能实现 -- 软著脚本生成工具

Unity3D热更新技术点——ToLua

配置 VScode 编辑器 (前端篇)

Unity 项目更改不在可执行文件中