-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateLocatorHere.cs
More file actions
42 lines (39 loc) · 1.15 KB
/
Copy pathCreateLocatorHere.cs
File metadata and controls
42 lines (39 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//CreateLocatorHere.cs
//
//Original Script is here (JavaScript):
//http://answers.unity3d.com/questions/7755/how-do-i-create-a-new-object-in-the-editor-as-a-ch.html
//
//CS Version made by N.Kobayashi 2014/06/14
//
using UnityEngine;
using System.Collections;
using UnityEditor;
namespace UnityChan
{
public class CreateLocatorHere
{
// Add menu to the main menu
[MenuItem("GameObject/Create Locator Here")]
static void CreateGameObjectAsChild ()
{
GameObject go = new GameObject ("Locator_");
go.transform.parent = Selection.activeTransform;
go.transform.localPosition = Vector3.zero;
}
// The item will be disabled if no transform is selected.
[MenuItem("GameObject/Create Locator Here",true)]
static bool ValidateCreateGameObjectAsChild ()
{
return Selection.activeTransform != null;
}
// Add context menu to Transform's context menu
[MenuItem("CONTEXT/Transform/Create Locator Here")]
static void CreateGameObjectAsChild (MenuCommand command)
{
Transform tr = (Transform)command.context;
GameObject go = new GameObject ("Locator_");
go.transform.parent = tr;
go.transform.localPosition = Vector3.zero;
}
}
}