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 }
  • 相关阅读:
    Django ListView实现分页
    redis-pipeline
    MRO
    进程状态
    ORM基本操作回顾
    协程回顾
    线程的回顾
    multiprocessing- 基于进程的并行性
    Fix Curl client hung issue
    Curl request 'Expect: 100-Continue' Issues and Risks
  • 原文地址:https://www.cnblogs.com/dawenhao/p/9871327.html
Copyright © 2011-2022 走看看