using UnityEditor
using System.Collections
// This example shows how to create a context menu inside a custom EditorWindow.
// context-click the green area to show the menu
public class GenericMenuExample : EditorWindow
{
[MenuItem("Example/Open Window")]
static void Init()
{
var window = GetWindow<GenericMenuExample>()
window.position = new Rect(50, 50, 250, 60)
window.Show()
}
void Callback(object obj)
{
Debug.Log("Selected: " + obj)
}
void OnGUI()
{
Event currentEvent = Event.current
Rect contextRect = new Rect(10, 10, 100, 100)
EditorGUI.DrawRect(contextRect, Color.green)
if (currentEvent.type == EventType.ContextClick)
{
Vector2 mousePos = currentEvent.mousePosition
if (contextRect.Contains(mousePos))
{
// Now create the menu, add items and show it
GenericMenu menu = new GenericMenu()
menu.AddItem(new GUIContent("MenuItem1"), false, Callback, "item 1")
menu.AddItem(new GUIContent("MenuItem2"), false, Callback, "item 2")
menu.AddSeparator("")
menu.AddItem(new GUIContent("SubMenu/MenuItem3"), false, Callback, "item 3")
menu.ShowAsContext()
currentEvent.Use()
}
}
}
}
using UnityEngine
using UnityEditor
using System.Collections
// This example shows how to create a context menu inside a custom EditorWindow.
// context-click the green area to show the menu
public class GenericMenuExample : EditorWindow
{
[MenuItem("Example/Open Window")]
static void Init()
{
var window = GetWindow<GenericMenuExample>()
window.position = new Rect(50, 50, 250, 60)
window.Show()
}
void Callback(object obj)
{
Debug.Log("Selected: " + obj)
}
void OnGUI()
{
Event currentEvent = Event.current
RectcontextRect = new Rect(10, 10, 100, 100)
EditorGUI.DrawRect(contextRect, Color.green)
if (currentEvent.type == EventType.ContextClick)
{
Vector2mousePos = currentEvent.mousePosition
if (contextRect.Contains(mousePos))
{
// Now create the menu, add items and show it
GenericMenumenu = new GenericMenu()
menu.AddItem(new GUIContent("MenuItem1"), false, Callback, "item 1")
menu.AddItem(new GUIContent("MenuItem2"), false, Callback, "item 2")
menu.AddSeparator("")
menu.AddItem(new GUIContent("SubMenu/MenuItem3"), false, Callback, "item 3")
menu.ShowAsContext()
currentEvent.Use()
}
}
}
}
unity添加天空盒有两种方法,分别为向场景添加和向摄像机添加。首先我们在assert里面导入skybox素材。向camera里导入:
点击camera或者main camera,再点击component,选renderin,点skybox.再inspector里面会成这样,注意,第一个框框必须是skybox。然后在第二个框框里面导入素材。
向scene里导入:
在edit里点render setting即可。再在红框框处选择。
scene里面添加skybox什么时候都可以看到,camera只有在该摄像机里面可以看到。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)