BS 0.1 基础构建完成 / 0.2 Visual 同为Unity UI控件部分
This commit is contained in:
43
Convention/[ES3]/Easy Save 3/Editor/ES3GameObjectEditor.cs
Normal file
43
Convention/[ES3]/Easy Save 3/Editor/ES3GameObjectEditor.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ES3Internal
|
||||
{
|
||||
[CustomEditor(typeof(ES3GameObject))]
|
||||
public class ES3GameObjectEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
var es3Go = (ES3GameObject)target;
|
||||
|
||||
EditorGUILayout.HelpBox("This Component allows you to choose which Components are saved when this GameObject is saved using code.", MessageType.Info);
|
||||
|
||||
if (es3Go.GetComponent<ES3AutoSave>() != null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("This Component cannot be used on GameObjects which are already managed by Auto Save.", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var component in es3Go.GetComponents<Component>())
|
||||
{
|
||||
var markedToBeSaved = es3Go.components.Contains(component);
|
||||
var newMarkedToBeSaved = EditorGUILayout.Toggle(component.GetType().Name, markedToBeSaved);
|
||||
|
||||
if(markedToBeSaved && !newMarkedToBeSaved)
|
||||
{
|
||||
Undo.RecordObject(es3Go, "Marked Component to save");
|
||||
es3Go.components.Remove(component);
|
||||
}
|
||||
|
||||
if (!markedToBeSaved && newMarkedToBeSaved)
|
||||
{
|
||||
Undo.RecordObject(es3Go, "Unmarked Component to save");
|
||||
es3Go.components.Add(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user