Initial commit
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e0addacfe5c5744faea3f1a2db541d6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
|
||||
#pragma warning disable CA1034 // Nested types should not be visible
|
||||
#pragma warning disable CA2235 // Mark all non-serializable fields
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MackySoft.SerializeReferenceExtensions.Example {
|
||||
|
||||
public class Example : MonoBehaviour {
|
||||
|
||||
// The type that implements ICommand will be displayed in the popup.
|
||||
[SerializeReference, SubclassSelector]
|
||||
ICommand m_Command;
|
||||
|
||||
// Collection support
|
||||
[SerializeReference, SubclassSelector]
|
||||
ICommand[] m_Commands = Array.Empty<ICommand>();
|
||||
|
||||
void Start () {
|
||||
m_Command?.Execute();
|
||||
|
||||
foreach (ICommand command in m_Commands) {
|
||||
command?.Execute();
|
||||
}
|
||||
}
|
||||
|
||||
// Nested type support
|
||||
[Serializable]
|
||||
public class NestedCommand : ICommand {
|
||||
public void Execute () {
|
||||
Debug.Log("Execute NestedCommand");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface ICommand {
|
||||
void Execute ();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class DebugCommand : ICommand {
|
||||
[SerializeField]
|
||||
string m_Message;
|
||||
public void Execute () {
|
||||
Debug.Log(m_Message);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class InstantiateCommand : ICommand {
|
||||
|
||||
[SerializeField]
|
||||
GameObject m_Prefab;
|
||||
|
||||
public void Execute () {
|
||||
UnityEngine.Object.Instantiate(m_Prefab,Vector3.zero,Quaternion.identity);
|
||||
}
|
||||
}
|
||||
|
||||
// Menu override support
|
||||
[AddTypeMenu("Example/Add Type Menu Command")]
|
||||
[Serializable]
|
||||
public class AddTypeMenuCommand : ICommand {
|
||||
public void Execute () {
|
||||
Debug.Log("Execute AddTypeMenuCommand");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b84d01d3056a974585aa0791b5434f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "MackySoft.SerializeReferenceExtensions.Example",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [
|
||||
"UNITY_2019_3_OR_NEWER"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b427d1329953ae946a0fcb528efcb3a3
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user