本文整理汇总了C#中UnityEditor.Editor类的典型用法代码示例。如果您正苦于以下问题:C# Editor类的具体用法?C# Editor怎么用?C# Editor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Editor类属于UnityEditor命名空间,在下文中一共展示了Editor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
private bool Init(UnityEngine.Object obj, EditorFeatures requirements)
{
this.editor = Editor.CreateEditor(obj);
if (this.editor == null)
{
return false;
}
if ((requirements & EditorFeatures.PreviewGUI) > EditorFeatures.None && !this.editor.HasPreviewGUI())
{
return false;
}
Type type = this.editor.GetType();
MethodInfo method = type.GetMethod("OnSceneDrag", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method != null)
{
this.OnSceneDrag = (EditorWrapper.VoidDelegate)Delegate.CreateDelegate(typeof(EditorWrapper.VoidDelegate), this.editor, method);
}
else
{
if ((requirements & EditorFeatures.OnSceneDrag) > EditorFeatures.None)
{
return false;
}
this.OnSceneDrag = new EditorWrapper.VoidDelegate(this.DefaultOnSceneDrag);
}
return true;
}
示例2: OnEditModeStart
protected void OnEditModeStart(Editor editor, EditMode.SceneViewEditMode mode)
{
if (mode == EditMode.SceneViewEditMode.Collider && editor == this)
{
this.OnEditStart();
}
}
示例3: DoEditModeInspectorModeButton
public static void DoEditModeInspectorModeButton(SceneViewEditMode mode, string label, GUIContent icon, Bounds bounds, Editor caller)
{
if (!EditorUtility.IsPersistent(caller.target))
{
DetectMainToolChange();
if (s_EditColliderButtonStyle == null)
{
s_EditColliderButtonStyle = new GUIStyle("Button");
s_EditColliderButtonStyle.padding = new RectOffset(0, 0, 0, 0);
s_EditColliderButtonStyle.margin = new RectOffset(0, 0, 0, 0);
}
Rect rect = EditorGUILayout.GetControlRect(true, 23f, new GUILayoutOption[0]);
Rect position = new Rect(rect.xMin + EditorGUIUtility.labelWidth, rect.yMin, 33f, 23f);
GUIContent content = new GUIContent(label);
Vector2 vector = GUI.skin.label.CalcSize(content);
Rect rect3 = new Rect(position.xMax + 5f, rect.yMin + ((rect.height - vector.y) * 0.5f), vector.x, rect.height);
int instanceID = caller.GetInstanceID();
bool flag = (editMode == mode) && (ownerID == instanceID);
EditorGUI.BeginChangeCheck();
bool flag2 = GUI.Toggle(position, flag, icon, s_EditColliderButtonStyle);
GUI.Label(rect3, label);
if (EditorGUI.EndChangeCheck())
{
ChangeEditMode(!flag2 ? SceneViewEditMode.None : mode, bounds, caller);
}
}
}
示例4: OnEditModeEnd
protected void OnEditModeEnd(Editor editor)
{
if (editor == this)
{
this.OnEditEnd();
}
}
示例5: OnEnable
internal virtual void OnEnable()
{
this.m_ActiveEditorIndex = EditorPrefs.GetInt(this.GetType().Name + "ActiveEditorIndex", 0);
if (!((UnityEngine.Object) this.m_ActiveEditor == (UnityEngine.Object) null))
return;
this.m_ActiveEditor = Editor.CreateEditor(this.targets, this.m_SubEditorTypes[this.m_ActiveEditorIndex]);
}
示例6: OnEditModeStart
protected void OnEditModeStart(Editor editor, UnityEditorInternal.EditMode.SceneViewEditMode mode)
{
if ((mode == UnityEditorInternal.EditMode.SceneViewEditMode.Collider) && (editor == this))
{
this.OnEditStart();
}
}
示例7: OnGUI
void OnGUI()
{
InspectorTools.DrawLogoAndName(InspectorTools.GetLogo(), "Loot manager v1.0.0");
EditorGUILayout.BeginHorizontal();
EditorGUILayout.BeginVertical(GUILayout.Width(130));
ScrollElements = EditorGUILayout.BeginScrollView(ScrollElements);
CurrentItem = InspectorTools.DrawButtonsByList<LootItem>(LootData.Instance.Items, (x) => { }, CurrentItem);
EditorGUILayout.EndScrollView();
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical();
if (CurrentItem >= 0)
{
LootData.Instance.Items[CurrentItem].Image = EditorGUILayout.ObjectField("UI Image", LootData.Instance.Items[CurrentItem].Image, typeof(Sprite), GUILayout.MaxHeight(200)) as Sprite;
LootData.Instance.Items[CurrentItem].Name = EditorGUILayout.TextField("Name", LootData.Instance.Items[CurrentItem].Name);
LootData.Instance.Items[CurrentItem].Description = EditorGUILayout.TextField("Description", LootData.Instance.Items[CurrentItem].Description,GUILayout.MaxHeight(200));
LootData.Instance.Items[CurrentItem].Prefab = EditorGUILayout.ObjectField("Prefab", LootData.Instance.Items[CurrentItem].Prefab, typeof(GameObject)) as GameObject;
if (LootData.Instance.Items[CurrentItem].Prefab != null)
{
if (gameObjectEditor == null)
gameObjectEditor = Editor.CreateEditor(LootData.Instance.Items[CurrentItem].Prefab);
gameObjectEditor.OnPreviewGUI(GUILayoutUtility.GetRect(300, 400), null);
}
}
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
this.ChangeHotControllByClick();
}
示例8: OnEnable
internal virtual void OnEnable()
{
this.m_ActiveEditorIndex = EditorPrefs.GetInt(base.GetType().Name + "ActiveEditorIndex", 0);
if (this.m_ActiveEditor == null)
{
this.m_ActiveEditor = Editor.CreateEditor(base.targets, this.m_SubEditorTypes[this.m_ActiveEditorIndex]);
}
}
示例9: StartDrag
/// <summary>
/// Starts a drag operation on a GUI element.
/// </summary>
/// <param name="editorWindow">Reference to the current editor drawing the GUI (used when a Repaint is needed)</param>
/// <param name="draggableList">List containing the dragged item and all other relative draggable items</param>
/// <param name="dragItem">Item being dragged</param>
/// <param name="draggedItemIndex">DraggableList index of the item being dragged</param>
/// <param name="optionalData">Optional data that can be retrieved via the <see cref="optionalDragData"/> static property</param>
public static void StartDrag(EditorWindow editorWindow, IList draggableList, object dragItem, int draggedItemIndex, object optionalData = null)
{
if (_dragData != null) return;
Reset();
_editor = null;
_editorWindow = editorWindow;
_dragData = new GUIDragData(draggableList, dragItem, draggedItemIndex, optionalData);
}
示例10: DrawInspector
public static void DrawInspector(Editor wcEditor, System.Type baseType, List<string> ignoreClasses = null) {
var so = new SerializedObject(wcEditor.targets);
var target = wcEditor.target;
so.Update();
var baseTypes = new List<System.Type>();
var baseTargetType = target.GetType();
baseTypes.Add(baseTargetType);
while (baseType != baseTargetType) {
baseTargetType = baseTargetType.BaseType;
baseTypes.Add(baseTargetType);
}
baseTypes.Reverse();
SerializedProperty prop = so.GetIterator();
var result = prop.NextVisible(true);
EditorGUILayout.PropertyField(prop, false);
if (result == true) {
var currentType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
EditorGUILayout.BeginVertical();
{
while (prop.NextVisible(false) == true) {
var cType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
if (cType != currentType) {
currentType = cType;
var name = cType.Name;
if (ignoreClasses != null && ignoreClasses.Contains(name) == true) continue;
EditorUtilitiesEx.DrawSplitter(name);
}
EditorGUILayout.PropertyField(prop, true);
}
prop.Reset();
}
EditorGUILayout.EndVertical();
}
so.ApplyModifiedProperties();
}
示例11: OnGUI
void OnGUI()
{
if (serverConfig != null) {
if (serverConfigEditor == null) {
serverConfigEditor = Editor.CreateEditor(serverConfig);
}
serverConfigEditor.OnInspectorGUI();
}
}
示例12: ObjectPreviewPopup
public ObjectPreviewPopup(UnityEngine.Object previewObject)
{
if (previewObject == null)
{
Debug.LogError("ObjectPreviewPopup: Check object is not null, before trying to show it!");
return;
}
this.m_ObjectName = new GUIContent(previewObject.name, AssetDatabase.GetAssetPath(previewObject));
this.m_Editor = Editor.CreateEditor(previewObject);
}
示例13: OnGUI
private void OnGUI(){
if (database != null) {
if (editor == null || editor.target != database) {
editor = Editor.CreateEditor (database);
}
scroll=EditorGUILayout.BeginScrollView(scroll);
editor.OnInspectorGUI ();
EditorGUILayout.EndScrollView();
}
}
示例14: CreateCachedEditor
public static void CreateCachedEditor(UnityEngine.Object[] targetObjects, System.Type editorType, ref Editor previousEditor)
{
if ((previousEditor == null) || !ArrayUtility.ArrayEquals<UnityEngine.Object>(previousEditor.m_Targets, targetObjects))
{
if (previousEditor != null)
{
UnityEngine.Object.DestroyImmediate(previousEditor);
}
previousEditor = CreateEditor(targetObjects, editorType);
}
}
示例15: ObjectPreviewPopup
public ObjectPreviewPopup(Object previewObject)
{
if (previewObject == (Object) null)
{
Debug.LogError((object) "ObjectPreviewPopup: Check object is not null, before trying to show it!");
}
else
{
this.m_ObjectName = new GUIContent(previewObject.name, AssetDatabase.GetAssetPath(previewObject));
this.m_Editor = Editor.CreateEditor(previewObject);
}
}