当前位置:网站首页>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");
}
}
}
边栏推荐
- Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)
- Unity one click AssetBundle
- [MySQL 12] MySQL 8.0.18 reinitialization
- tp3.2和tp5.0的区别
- Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
- register关键字
- Ventuz Foundation Series "one step at the door"
- [USACO12MAR]Cows in a Skyscraper G(状态压缩dp)
- Pat class a 1031 Hello world for u
- Huawei switch basic configuration (telnet/ssh login)
猜你喜欢
Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)
方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!
【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
一条通往服务器所有端口的隧道
What to do after the browser enters the URL
the installer has encountered an unexpected error installing this package
C language learning notes (mind map)
Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
haproxy+keepalived搭建01
Getting started with minicom
随机推荐
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel
[at] abc 258G - Triangle 三元組可達-暴力
Technical dry goods | thinking about the unification of dynamic and static diagrams of AI framework
Transfinite hacker cognition
Iterm2 setting
【LeetCode】2. Valid parentheses · valid parentheses
方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!
Usage of (case, when) in PostgreSQL
[MySQL 14] use dbeaver tool to remotely backup and restore MySQL database (Linux Environment)
Client server model
链式长取值
Wechat applet taro learning record
【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
Pat class a 1031 Hello world for u
多旅行商问题——公式和求解过程概述
Huawei switch basic configuration (telnet/ssh login)
Free use until 2015 -- viz artist multi touch plug-in package
JS to implement publish and subscribe
vcs import src < ros2. Repos failed
JSON与Object之间转换