zoukankan      html  css  js  c++  java
  • Unity创建asset文件的扩展编辑器

     1 using UnityEngine;
     2 using UnityEditor;
     3 using System.IO;
     4 
     5 public class CreateAsset : EditorWindow
     6 {
     7     private string mConfigName = "TestAsset";
     8     private string mAssetPath = "Assets/Config/";
     9     private string mAssetName = "MyAsset";
    10 
    11     [MenuItem("Tools/CreateAsset")]
    12     public static void GenAsset()
    13     {
    14         GetWindow(typeof(CreateAsset));
    15     }
    16 
    17     private void OnGUI()
    18     {
    19         mConfigName = EditorGUILayout.TextField("Asset类名:", mConfigName);
    20         mAssetPath = EditorGUILayout.TextField("生成Asset路径", mAssetPath);
    21         mAssetName = EditorGUILayout.TextField("生成Asset名称", mAssetName);
    22         if (GUILayout.Button(new GUIContent("生成Asset")))
    23         {
    24             if (string.IsNullOrEmpty(mConfigName) || string.IsNullOrEmpty(mAssetPath) || string.IsNullOrEmpty(mAssetName))
    25             {
    26                 Debug.LogError("Err!");
    27                 return;
    28             }
    29 
    30             var newAsset = CreateInstance(mConfigName);
    31             string fullPath = mAssetPath + mAssetName + ".asset";
    32             AssetDatabase.CreateAsset(newAsset, fullPath);
    33             Debug.Log(fullPath);
    34             AssetDatabase.SaveAssets();
    35             AssetDatabase.Refresh();
    36             EditorUtility.FocusProjectWindow();
    37             Selection.activeObject = newAsset;
    38         }
    39     }
    40 }
  • 相关阅读:
    nova 注入adminpass 添加用户等设置
    mysql 集群 avc error
    openstack novnc console haproxy mitaka
    NFS金陵科技学院
    windows下命令行格式化U盘
    linux下安装mysql
    连表查询
    查询语句
    索引
    插入,更新与删除数据
  • 原文地址:https://www.cnblogs.com/dawenhao/p/9871327.html
Copyright © 2011-2022 走看看