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>
public void OnWizardC
Unity-批量添加命名空间
最新推荐文章于 2022-06-01 15:58:30 发布
本文介绍了在Unity开发中如何快速、批量地为多个脚本添加合适的命名空间,提高代码组织和管理效率。通过使用Visual Studio的批量替换功能或者自定义脚本,可以实现对多个文件进行统一修改,确保项目代码结构清晰,便于维护。
摘要由CSDN通过智能技术生成