using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
/// <summary>
/// 批量添加和修改代码命名空间工具(放在Editor文件夹)
/// </summary>
public class AutoAddNameSpaceEditor : ScriptableWizard
{
public string folder = "Assets/";
public string namespaceName;
static float windowWidth = 500f;
static float windowHeight = 500f;
static AutoAddNameSpaceEditor editor;
void OnEnable()
{
if (Selection.activeObject != null)
{
string dirPath = AssetDatabase.GetAssetOrScenePath(Selection.activeObject);
if (File.Exists(dirPath))
{
dirPath = dirPath.Substring(0, dirPath.LastIndexOf("/"));
}
folder = dirPath;
}
}
//%:Ctrl,#:Shift,&:Alt %#&z:Ctrl+Shift+Alt+A
[MenuItem("编辑器扩展/Add Namespace", false, 10)]
static void CreateWizard()
{
editor = ScriptableWizard.DisplayWizard<AutoAddNameSpaceEditor>("Add Namespace", "添加命名空间", "取消");
editor.minSize = new Vector2(windowWidth, windowHeight);
}
/// <summary>
/// 点击取消按钮时调用
/// </summary>
private void OnWizardOtherButton()
{
editor.Close();
}
/// <summary>
/// 点击确定按钮时调用,这里的确定按钮就是"添加命名空间"
/// </summary>
publ