diff options
author | chai <chaifix@163.com> | 2020-10-15 07:04:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-10-15 07:04:38 +0800 |
commit | b71d5611db087772179505ed10c82ca958900df7 (patch) | |
tree | 5160f6af41d45529e435550879e0c87ea59c09a8 /Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample38_Constructor.cs | |
parent | b1b14c45ce95dcf7b81867d68d6006345d98959e (diff) |
+advanced inspector
Diffstat (limited to 'Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample38_Constructor.cs')
-rw-r--r-- | Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample38_Constructor.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample38_Constructor.cs b/Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample38_Constructor.cs new file mode 100644 index 00000000..27cadeb3 --- /dev/null +++ b/Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample38_Constructor.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using UnityEngine; +using AdvancedInspector; + +public class AIExample38_Constructor : MonoBehaviour +{ + // In some case, you may want a class to have a custom constructor. + // Usually, Unity is unable to invoke that constructor. + [Serializable] + public class CustomConstructor + { + [Inspect] + public string value; + + public CustomConstructor(string text) + { + value = text; + } + } + + // Advanced Inspector allows you to create your own instance using the constructor attribute. + // You may setup your object as you wish before returning it. + [Inspect, Constructor("InvokeConstructor")] + public CustomConstructor[] constructors; + + public CustomConstructor InvokeConstructor() + { + return new CustomConstructor("This was added in a constructor"); + } +} + + |