码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-09-06 00:26:12      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:生成   sources   set   ref   csharp   using   zab   resources   编辑器   

using UnityEditor;

public class PoolManagerEditor {
    [MenuItem("Manager/Creat GameObjectPoolConfig")]
    static void CreatGameObjectPoolList()
    {
        GameObjectPoolList poolList = ScriptableObject.CreateInstance<GameObjectPoolList>();//生成可编辑对象
        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<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编辑器生成可配置编辑文件

标签:生成   sources   set   ref   csharp   using   zab   resources   编辑器   

原文地址:http://www.cnblogs.com/trlq/p/7482478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!