You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
|
|
|
|
namespace MalbersAnimations.Scriptables
|
|
{
|
|
[AddComponentMenu("Malbers/Runtime Vars/Add Runtime GameObjects")]
|
|
public class AddRuntimeGameObjects : MonoBehaviour
|
|
{
|
|
[CreateScriptableAsset] public RuntimeGameObjects Collection;
|
|
|
|
private void OnEnable() => Collection?.Item_Add(gameObject);
|
|
|
|
private void OnDisable() => Collection?.Item_Remove(gameObject);
|
|
}
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
[UnityEditor.CustomEditor(typeof(AddRuntimeGameObjects)), UnityEditor.CanEditMultipleObjects]
|
|
public class AddRuntimeGameObjectsEditor : UnityEditor.Editor
|
|
{
|
|
public static GUIStyle StyleBlue => MTools.Style(new Color(0, 0.5f, 1f, 0.3f));
|
|
AddRuntimeGameObjects M;
|
|
|
|
private void OnEnable()
|
|
{
|
|
M = (AddRuntimeGameObjects)target;
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
serializedObject.Update();
|
|
var Collection = serializedObject.FindProperty("Collection");
|
|
UnityEditor.EditorGUILayout.PropertyField(Collection);
|
|
|
|
if (M.Collection && !string.IsNullOrEmpty(M.Collection.Description))
|
|
{
|
|
MalbersEditor.DrawDescription(M.Collection.Description);
|
|
}
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
}
|
|
}
|
|
#endif
|
|
} |