当前位置:网站首页>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");
}
}
}
边栏推荐
猜你喜欢

VMware virtual machine configuration static IP

WorldView卫星遥感影像数据/米级分辨率遥感影像

【cocos creator】点击按钮切换界面

JS common basic case sorting (continuous update)
![[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel](/img/51/04f5a9dbd03438fbdf25545a81b7ba.jpg)
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel

C language learning notes (mind map)
![[untitled]](/img/3d/27a7229e3f0ccf0ca5ae1f00a92513.jpg)
[untitled]

Research shows that breast cancer cells are more likely to enter the blood when patients sleep

Wpf: solve the problem that materialdesign:dialoghost cannot be closed

Unity2019_ Natural ambient light_ Sky box
随机推荐
Harmonyos third training notes
Lua framwrok framework starts
使用 FileChannel 进行文件的复制拷贝
Research shows that breast cancer cells are more likely to enter the blood when patients sleep
freetype库的移植
unity2019_ Input management
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
Redis批量启停脚本
the installer has encountered an unexpected error installing this package
JS to implement publish and subscribe
tp3.2和tp5.0的区别
Pat grade a 1029 median
vcs import src < ros2. Repos failed
[at] abc 258G - Triangle 三元組可達-暴力
【cocos creator】获取资源uuid
[MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel
Pat class a 1028 list sorting
Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
haproxy+keepalived搭建01