Skip to content

Instantly share code, notes, and snippets.

@s2kw
Created October 6, 2013 14:45
Show Gist options
  • Save s2kw/6854933 to your computer and use it in GitHub Desktop.
Save s2kw/6854933 to your computer and use it in GitHub Desktop.
CodeIQ presents, Unity Editor Seminar. Question1. I checked How to use MenuItem's 2nd argument.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class Question1Editor : Editor {
[MenuItem("Editor10/Question1")]
static void Question1_Basic(){}
[MenuItem("Editor10/Question1_ #&n",false)]
static bool Validateaaa()
{
Debug.Log("Validate");
return Selection.activeTransform;
// http://docs.unity3d.com/Documentation/ScriptReference/Selection-activeTransform.html
}
[MenuItem("Editor10/Question1_ #&n",true)]
static void Question1_Practical()
{
Debug.Log("1");
GameObject childObj = new GameObject();
if(childObj == null) return;
childObj.transform.parent = Selection.activeGameObject.transform;
}
[MenuItem("Editor10/Question1_ #&n")]
static void Question1_Practical2()
{
Debug.Log("2");
GameObject childObj = new GameObject();
if(childObj == null) return;
childObj.transform.parent = Selection.activeGameObject.transform;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment