浏览代码

Merge branch 'create-editorBase-for-custom-inspector' of https://github.com/rainaldisatria/open-project-1 into main

# Conflicts:
#	UOP1_Project/Assets/Scripts/Editor/GameSceneSOEditor.cs
/release
Ciro Continisio 4 年前
当前提交
3f2b0d3c
共有 3 个文件被更改,包括 42 次插入1 次删除
  1. 4
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/Editor/AnimatorParameterActionSOEditor.cs
  2. 28
      UOP1_Project/Assets/Scripts/Editor/CustomBaseEditor.cs
  3. 11
      UOP1_Project/Assets/Scripts/Editor/CustomBaseEditor.cs.meta

4
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/Editor/AnimatorParameterActionSOEditor.cs


using UOP1.StateMachine;
[CustomEditor(typeof(AnimatorParameterActionSO)), CanEditMultipleObjects]
public class AnimatorParameterActionSOEditor : UnityEditor.Editor
public class AnimatorParameterActionSOEditor : CustomBaseEditor
DrawNonEdtiableScriptReference<AnimatorParameterActionSO>();
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("whenToRun"));

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:
正在加载...
取消
保存