-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUContextMenuExtensions.cs
49 lines (40 loc) · 1.89 KB
/
UContextMenuExtensions.cs
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
43
44
45
46
47
48
49
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
namespace UnscriptedEngine
{
public static class UContextMenuExtensions
{
public const string PATHNAME = "GameObject/UnscriptedEngine/";
[MenuItem(PATHNAME + "Camera/Create RTSCamera")]
public static void CreateLevelObject(MenuCommand command)
{
GameObject go = new GameObject("RTSCamera_Parent");
GameObject rtsCamera = new GameObject("RTSCamera");
rtsCamera.transform.SetParent(go.transform);
rtsCamera.transform.SetLocalPositionAndRotation(new Vector3(0, 9, -10), Quaternion.Euler(new Vector3(60, 0, 0)));
rtsCamera.AddComponent<Camera>();
rtsCamera.AddComponent<AudioListener>();
//rtsCamera.AddComponent<UniversalAdditionalCameraData>();
//rtsCamera.AddComponent<URTSCamera>();
GameObjectUtility.SetParentAndAlign(go, command.context as GameObject);
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeGameObject = go;
}
[MenuItem(PATHNAME + "UI/Create Button Component")]
public static void CreateButtonComponent(MenuCommand command)
{
GameObject buttonComponent = new GameObject("ButtonComponent");
GameObjectUtility.SetParentAndAlign(buttonComponent, command.context as GameObject);
buttonComponent.AddComponent<RectTransform>();
buttonComponent.AddComponent<CanvasRenderer>();
buttonComponent.AddComponent<Image>();
buttonComponent.AddComponent<Button>();
buttonComponent.AddComponent<UButtonComponent>();
Undo.RegisterCreatedObjectUndo(buttonComponent, "Create " + buttonComponent.name);
Selection.activeGameObject = buttonComponent;
}
}
}
#endif