当前位置:网站首页>Editor Extensions
Editor Extensions
2022-07-03 08:01:00 【qq_ two billion three hundred and eighty-five million seven hun】
Assets==》Editor==》Tools
public class Tools
{
// Of each menu bar Priority Priority default 1000
[MenuItem("Tools/Show Info", false, 13)]
static void ShowInfo()
{
Debug.Log(Selection.activeGameObject.name);
}
// Button verification method , Determine whether the following methods can be executed , The method name is followed by Validate
[MenuItem("GameObject/my delete", true, 2)]
static bool MyDeleteValidate()
{
if (Selection.objects.Length > 0)
return true;
else
return false;
}
// The difference between the number and the number 11 Can be classified
[MenuItem("GameObject/my delete", false, 2)]
static void MyDelete()
{
foreach (Object o in Selection.objects)
{
// Press down ctrl+z Revocable
Undo.DestroyObjectImmediate(o);
}
// You need to register the deletion operation in the record
}
// Shortcut key operation There is a space in the middle +"_"
//%=ctrl #=shift &=alt Operation for : %k
[MenuItem("Tools/Kuaijie _k", false, 1)]
static void KuaiJieKey()
{
Debug.Log(" Shortcut key ");
}
[MenuItem("Assets/test4")]
static void Test5()
{
Debug.Log(" test 4");
}
}
Create dialog , Modify the value of multiple enemies
using UnityEditor;
public class EnemyChange : ScriptableWizard
{
// Create dialog
[MenuItem("Tools/CreatWizard")]
static void CreatWizard()
{
// Show dialog , Dialog type , title
ScriptableWizard.DisplayWizard<EnemyChange>(" Unified modification of the enemy ", "ChangeAndClose","Change");
}
public int changeHealth = 10;
public int changeSpeed = 1;
void OnEnable()
{
changeHealth = EditorPrefs.GetInt("Health", changeHealth);
changeSpeed = EditorPrefs.GetInt("Speed", changeSpeed);
}
// testing ChangeAndClose Button click , The method name is fixed
void OnWizardCreate()
{
GameObject[] enemyPrefabs = Selection.gameObjects;
// Progress bar
EditorUtility.DisplayProgressBar(" speed of progress ", "0/" + enemyPrefabs.Length + " complete ", 0);
int count = 0;
foreach (GameObject go in enemyPrefabs)
{
CompleteProject.EnemyHealth hp = go.GetComponent<CompleteProject.EnemyHealth>();
// Record the changes
Undo.RecordObject(hp, "change heath");
hp.startingHealth += changeHealth;
hp.sinkSpeed += changeSpeed;
count++;
EditorUtility.DisplayProgressBar(" speed of progress ", count + "/" + enemyPrefabs.Length + " complete ", count / (float)enemyPrefabs.Length);
}
EditorUtility.ClearProgressBar();// Close progress bar
ShowNotification(new GUIContent(Selection.gameObjects.Length + " Game objects have been modified "));
}
//Change Button execution method
void OnWizardOtherButton()
{
OnWizardCreate();
}
// When the value of the field is modified, call
void OnWizardUpdate()
{
errorString = null;
helpString = null;
if (Selection.gameObjects.Length > 0)
{
helpString = " You currently selected " + Selection.gameObjects.Length + " individual ";
}
else
{
errorString = " Please select at least one enemy ";
}
EditorPrefs.SetInt("Health", changeHealth);
EditorPrefs.SetInt("Speed", changeSpeed);
}
// When the selected object changes, call
void OnSelectionChange()
{
OnWizardUpdate();
}
}
Create a form
using UnityEditor;
public class MyWindow : EditorWindow
{
[MenuItem("Window/Show mywindow")]
static void ShowMyWindow()
{
MyWindow window = EditorWindow.GetWindow<MyWindow>();
window.Show();
}
private string name = "";
void OnGUI()
{
GUILayout.Label(" My window ");
name = GUILayout.TextField(name);
if (GUILayout.Button(" establish "))
{
GameObject go = new GameObject(name);
// Record
Undo.RegisterCreatedObjectUndo(go, "Creat gameobject");
}
}
}
边栏推荐
- PHP wechat red packet grabbing algorithm
- haproxy+keepalived集群搭建02
- [cocos creator] Click the button to switch the interface
- MaxCompute字符串分割函数-SPLIT_PART
- *p++、*++p、++*p、(*p)++
- A tunnel to all ports of the server
- Unity one click AssetBundle
- 【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
- Pat grade a 1029 median
- [at] ABC 258g - triple Reach - violence
猜你喜欢
在浏览器输入url后执行什么
Are you still watching the weather forecast on TV?
【LeetCode】2. Valid parentheses · valid parentheses
WPF:解决MaterialDesign:DialogHost 无法关闭问题
一条通往服务器所有端口的隧道
[MySQL 12] MySQL 8.0.18 reinitialization
一篇文章让你读懂-曼彻斯特编码
My touch screen production "brief history" 1
Unity2019_ Lighting system
LwIP learning socket (application)
随机推荐
【LeetCode】4. Best time to buy and sell stock
[MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
L'installateur a été installé avec une erreur inattendue
Quelle est la définition? Qu'est - ce qu'une déclaration? Quelle est la différence?
When did you find out that youth was over
Lua framwrok framework starts
A tunnel to all ports of the server
Product creation and commercial realization of chat robot (according to La Ma Bang - Dr. Wang Jingjing - speech)
Conversion between JSON and object
Redis配置文件
IP production stream is so close to me
[at] abc 258G - Triangle 三元组可达-暴力
超限黑客认知
WPF:解决MaterialDesign:DialogHost 无法关闭问题
Harmonyos third training notes
freetype库的移植
Precautions for opensips and TLS SIP trunk docking
How to clear the console password for s7700 device
Iterm2 setting
[at] abc 258G - Triangle 三元組可達-暴力