Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 93d7e13f62 | |||
| f522e0f285 | |||
| d061f748b8 | |||
| afb3089943 |
+2
-1
@@ -1,4 +1,5 @@
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
+7
-2
@@ -8,14 +8,19 @@ namespace MackySoft.SerializeReferenceExtensions.Editor {
|
||||
public static class ManagedReferenceUtility {
|
||||
|
||||
public static object SetManagedReference (this SerializedProperty property,Type type) {
|
||||
object result;
|
||||
object result = null;
|
||||
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
|
||||
if (property.managedReferenceValue != null)
|
||||
{
|
||||
// Restore an previous values from json.
|
||||
string json = JsonUtility.ToJson(property.managedReferenceValue);
|
||||
result = JsonUtility.FromJson(json, type);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
result = (type != null) ? Activator.CreateInstance(type) : null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "com.mackysoft.serializereference-extensions",
|
||||
"displayName": "SerializeReference Extensions",
|
||||
"author": { "name": "MackySoft", "url": "https://github.com/mackysoft" },
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"unity": "2021.3",
|
||||
"description": "Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector.",
|
||||
"keywords": [ "SerializeReference", "Editor" ],
|
||||
|
||||
@@ -15,6 +15,9 @@ The `SubclassSelector` attribute allows you to easily set subclasses of those ab
|
||||
- Easily set subclass by popup.
|
||||
- **[New]** Type finding by fuzzy finder.
|
||||
- **[New]** Override the type name and path by the `AddTypeMenu` attribute.
|
||||
- **[New]** Restore values of previous object from JSON when subclass is changed.
|
||||
- **[New]** Copy & Paste the subclass properties.
|
||||
- **[New]** Available `CustomPropertyDrawer` for subclasses.
|
||||
|
||||
## 📥 Installation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user