- Home /
Question by
Chocolade · Dec 06, 2016 at 07:47 PM ·
c#scripting problemscript.
Why when using EditorWindow script type and MenuItem it's not add it to Hierarchy right click mouse context menu ?
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System;
public class Sorting : EditorWindow
{
string objectsName = "";
bool groupEnabled;
bool myBool = true;
float myFloat = 1.23f;
// Add menu named "Objects" to the GameObject menu
[MenuItem("GameObject/Test")]
static void Init()
{
// Get existing open window or if none, make a new one:
Sorting window = (Sorting)EditorWindow.GetWindow(typeof(Sorting));
window.Show();
}
void OnGUI()
{
GUILayout.Label("Base Settings", EditorStyles.boldLabel);
objectsName = EditorGUILayout.TextField("By Name", objectsName);
groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
myBool = EditorGUILayout.Toggle("Toggle", myBool);
myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
EditorGUILayout.EndToggleGroup();
GUILayout.FlexibleSpace();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
EditorGUI.BeginDisabledGroup(objectsName == "");
if (GUILayout.Button("Name"))
{
}
EditorGUILayout.EndHorizontal();
EditorGUI.EndDisabledGroup();
}
}
I'm using [MenuItem("GameObject/Test")] So when i click in the unity editor menu on GameObject i see in the context menu also the Test.
But when i make on the Hierarchy window right click on the mouse i don't see the Test in the context menu.
Comment
Your answer
Follow this Question
Related Questions
How can i prevent from mouse to collide with thirdpersoncontroller ? 0 Answers
How can i lock the mouse cursor in the middle of the screen ? 1 Answer
Why InputField don't have the property text ? 2 Answers
How can i change the walls height and keep the size for example 100x100 but height 0.1 ? 1 Answer
Why i'm getting UnassignedReferenceException when running the game ? 1 Answer