Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 93d7e13f62 | |||
| f522e0f285 | |||
| d061f748b8 | |||
| afb3089943 | |||
| d2d5c8ed52 | |||
| 2455229944 | |||
| 6ae47efa1d | |||
| 343d930155 | |||
| 1e52b89dd2 | |||
| ba83546f0a | |||
| 15a627bd48 | |||
| e6f57ed763 | |||
| 59da3868b1 | |||
| 65b0076c95 | |||
| 360c800b25 | |||
| cdbc2daf21 | |||
| 5d43ced8cc |
@@ -28,9 +28,13 @@ jobs:
|
|||||||
|
|
||||||
# Build
|
# Build
|
||||||
- name: Build .unitypackage
|
- name: Build .unitypackage
|
||||||
uses: game-ci/unity-builder@v2
|
uses: game-ci/unity-builder@v4
|
||||||
|
env:
|
||||||
|
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||||
|
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||||
|
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||||
with:
|
with:
|
||||||
unityVersion: 2020.3.8f1
|
unityVersion: 2021.3.29f1
|
||||||
buildMethod: MackySoft.PackageTools.Editor.UnityPackageExporter.Export
|
buildMethod: MackySoft.PackageTools.Editor.UnityPackageExporter.Export
|
||||||
|
|
||||||
# Upload
|
# Upload
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ jobs:
|
|||||||
needs: [update-packagejson]
|
needs: [update-packagejson]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
unity: ["2020.3.8f1"]
|
unity: ["2021.3.29f1"]
|
||||||
include:
|
include:
|
||||||
- unityVersion: 2020.3.8f1
|
- unityVersion: 2021.3.29f1
|
||||||
license: UNITY_LICENSE_2020
|
license: UNITY_LICENSE
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
@@ -74,9 +74,11 @@ jobs:
|
|||||||
ref: ${{ needs.update-packagejson.outputs.sha }}
|
ref: ${{ needs.update-packagejson.outputs.sha }}
|
||||||
|
|
||||||
- name: Export unitypackage
|
- name: Export unitypackage
|
||||||
uses: game-ci/unity-builder@v2
|
uses: game-ci/unity-builder@v4
|
||||||
env:
|
env:
|
||||||
UNITY_LICENSE: ${{ secrets[matrix.license] }}
|
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||||
|
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||||
|
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||||
with:
|
with:
|
||||||
projectPath: .
|
projectPath: .
|
||||||
unityVersion: ${{ matrix.unityVersion }}
|
unityVersion: ${{ matrix.unityVersion }}
|
||||||
|
|||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
|
||||||
|
#if UNITY_2021_3_OR_NEWER
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace MackySoft.SerializeReferenceExtensions.Editor
|
||||||
|
{
|
||||||
|
public static class CopyAndPasteProperty
|
||||||
|
{
|
||||||
|
|
||||||
|
const string kCopiedPropertyPathKey = "SerializeReferenceExtensions.CopiedPropertyPath";
|
||||||
|
const string kClipboardKey = "SerializeReferenceExtensions.CopyAndPasteProperty";
|
||||||
|
|
||||||
|
static readonly GUIContent kPasteContent = new GUIContent("Paste Property");
|
||||||
|
|
||||||
|
[InitializeOnLoadMethod]
|
||||||
|
static void Initialize ()
|
||||||
|
{
|
||||||
|
EditorApplication.contextualPropertyMenu += OnContextualPropertyMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnContextualPropertyMenu (GenericMenu menu, SerializedProperty property)
|
||||||
|
{
|
||||||
|
if (property.propertyType == SerializedPropertyType.ManagedReference)
|
||||||
|
{
|
||||||
|
// NOTE: When the callback function is called, the SerializedProperty is rewritten to the property that was being moused over at the time,
|
||||||
|
// so a new SerializedProperty instance must be created.
|
||||||
|
SerializedProperty clonedProperty = property.Copy();
|
||||||
|
|
||||||
|
menu.AddItem(new GUIContent($"Copy \"{property.propertyPath}\" property"), false, Copy, clonedProperty);
|
||||||
|
|
||||||
|
string copiedPropertyPath = SessionState.GetString(kCopiedPropertyPathKey, string.Empty);
|
||||||
|
if (!string.IsNullOrEmpty(copiedPropertyPath))
|
||||||
|
{
|
||||||
|
menu.AddItem(new GUIContent($"Paste \"{copiedPropertyPath}\" property"), false, Paste, clonedProperty);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.AddDisabledItem(kPasteContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Copy (object customData)
|
||||||
|
{
|
||||||
|
SerializedProperty property = (SerializedProperty)customData;
|
||||||
|
string json = JsonUtility.ToJson(property.managedReferenceValue);
|
||||||
|
SessionState.SetString(kCopiedPropertyPathKey, property.propertyPath);
|
||||||
|
SessionState.SetString(kClipboardKey, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Paste (object customData)
|
||||||
|
{
|
||||||
|
SerializedProperty property = (SerializedProperty)customData;
|
||||||
|
string json = SessionState.GetString(kClipboardKey, string.Empty);
|
||||||
|
if (string.IsNullOrEmpty(json))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Undo.RecordObject(property.serializedObject.targetObject, "Paste Property");
|
||||||
|
JsonUtility.FromJsonOverwrite(json, property.managedReferenceValue);
|
||||||
|
property.serializedObject.ApplyModifiedProperties();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 734d3eb8da4785b49919aea6db62d877
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+21
-3
@@ -2,14 +2,32 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MackySoft.SerializeReferenceExtensions.Editor {
|
namespace MackySoft.SerializeReferenceExtensions.Editor {
|
||||||
public static class ManagedReferenceUtility {
|
public static class ManagedReferenceUtility {
|
||||||
|
|
||||||
public static object SetManagedReference (this SerializedProperty property,Type type) {
|
public static object SetManagedReference (this SerializedProperty property,Type type) {
|
||||||
object obj = (type != null) ? Activator.CreateInstance(type) : null;
|
object result = null;
|
||||||
property.managedReferenceValue = obj;
|
|
||||||
return obj;
|
#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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
result = (type != null) ? Activator.CreateInstance(type) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
property.managedReferenceValue = result;
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type GetType (string typeName) {
|
public static Type GetType (string typeName) {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "com.mackysoft.serializereference-extensions",
|
"name": "com.mackysoft.serializereference-extensions",
|
||||||
"displayName": "SerializeReference Extensions",
|
"displayName": "SerializeReference Extensions",
|
||||||
"version": "1.1.9",
|
"author": { "name": "MackySoft", "url": "https://github.com/mackysoft" },
|
||||||
"unity": "2019.4",
|
"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.",
|
"description": "Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector.",
|
||||||
"keywords": [ "SerializeReference", "Editor" ],
|
"keywords": [ "SerializeReference", "Editor" ],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ The `SubclassSelector` attribute allows you to easily set subclasses of those ab
|
|||||||
- Easily set subclass by popup.
|
- Easily set subclass by popup.
|
||||||
- **[New]** Type finding by fuzzy finder.
|
- **[New]** Type finding by fuzzy finder.
|
||||||
- **[New]** Override the type name and path by the `AddTypeMenu` attribute.
|
- **[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
|
## 📥 Installation
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user