August 2018
Intermediate to advanced
794 pages
28h 4m
English
To work with selected objects and deactivate menu items follow these steps:
using UnityEditor; using UnityEngine; public class SelectedObjectManager : EditorWindow { [MenuItem("MyMenu/Move To Origin")] static void ZeroPosition() { GameObject selectedGameObject = Selection.activeTransform.gameObject; Undo.RecordObject (selectedGameObject.transform, "Zero Transform Position"); selectedGameObject.transform.position = Vector3.zero; } [MenuItem("MyMenu/Move To Origin", true)] static bool ValidateZeroPosition() { // Return false if no transform is selected. return ...Read now
Unlock full access