浏览代码

Create CustomBaseEditor.cs

Custom base editor class. Inherited from Editor class.
Contains handy method to use.
/main
rainaldisatria 4 年前
当前提交
aeba46f4
共有 2 个文件被更改,包括 39 次插入0 次删除
  1. 28
      UOP1_Project/Assets/Scripts/Editor/CustomBaseEditor.cs
  2. 11
      UOP1_Project/Assets/Scripts/Editor/CustomBaseEditor.cs.meta

28
UOP1_Project/Assets/Scripts/Editor/CustomBaseEditor.cs


using UnityEditor;
using UnityEngine;
/// <summary>
/// Custom base editor class. Inherited from Editor class.
/// Contains handy method to use.
/// </summary>
public class CustomBaseEditor : Editor
{
/// <summary>
/// Draw reference information about script being edited.
/// </summary>
/// <typeparam name="T">Inspected type.</typeparam>
public void DrawNonEdtiableScriptReference<T>() where T : Object
{
//Make GUI not editable.
GUI.enabled = false;
//Draw reference information about script being edited.
if (typeof(ScriptableObject).IsAssignableFrom(typeof(T)))
EditorGUILayout.ObjectField("Script", MonoScript.FromScriptableObject((ScriptableObject)target), typeof(T), false);
else if (typeof(MonoBehaviour).IsAssignableFrom(typeof(T)))
EditorGUILayout.ObjectField("Script", MonoScript.FromMonoBehaviour((MonoBehaviour)target), typeof(T), false);
//Make GUI editable.
GUI.enabled = true;
}
}

11
UOP1_Project/Assets/Scripts/Editor/CustomBaseEditor.cs.meta


fileFormatVersion: 2
guid: fdbc89f1f51984e49a0d6742a3bb776d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存