diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..49ddb5e
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+ ko_fi: thundernerd
\ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index c8a3874..e9f2a85 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -8,17 +8,13 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- - name: Checkout
- uses: actions/checkout@v3
- with:
- token: ${{ secrets.GH_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Install dependencies
- run: >
- npm install
+ run: >
+ npm install -g --save false
semantic-release
@semantic-release/changelog
@semantic-release/commit-analyzer
@@ -27,8 +23,13 @@ jobs:
@semantic-release/npm
@semantic-release/release-notes-generator
conventional-changelog-conventionalcommits
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ token: ${{ secrets.GH_TOKEN }}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npx semantic-release
+ NPM_CONFIG_REGISTRY: 'https://npm.pkg.github.com/@Thundernerd'
+ run: npx semantic-release
\ No newline at end of file
diff --git a/.releaserc b/.releaserc
new file mode 100644
index 0000000..4a637a1
--- /dev/null
+++ b/.releaserc
@@ -0,0 +1,112 @@
+{
+ "branches":
+ [
+ "main"
+ ],
+ "plugins":
+ [
+ [
+ "@semantic-release/commit-analyzer",
+ {
+ "preset": "conventionalcommits",
+ "releaseRules":
+ [
+ {
+ "breaking": true,
+ "release": "major"
+ },
+ {
+ "type": "docs",
+ "scope": "README",
+ "release": "patch"
+ },
+ {
+ "type": "refactor",
+ "release": "patch"
+ },
+ {
+ "scope": "no-release",
+ "release": false
+ }
+ ],
+ "parserOpts":
+ {
+ "noteKeywords":
+ [
+ "BREAKING CHANGE",
+ "BREAKING CHANGES"
+ ]
+ }
+ }
+ ],
+ [
+ "@semantic-release/npm",
+ {
+ "npmPublish": true
+ }
+ ],
+ "@semantic-release/github",
+ [
+ "@semantic-release/release-notes-generator",
+ {
+ "preset": "conventionalcommits",
+ "presetConfig":
+ {
+ "types":
+ [
+ {
+ "type": "feat",
+ "section": "Features"
+ },
+ {
+ "type": "fix",
+ "section": "Bug Fixes"
+ },
+ {
+ "type": "chore",
+ "hidden": true
+ },
+ {
+ "type": "docs",
+ "section": "Documentation"
+ },
+ {
+ "type": "style",
+ "hidden": true
+ },
+ {
+ "type": "refactor",
+ "section": "Refactors"
+ },
+ {
+ "type": "perf",
+ "section": "Performance Improvements"
+ },
+ {
+ "type": "test",
+ "section": "Tests"
+ }
+ ]
+ }
+ }
+ ],
+ [
+ "@semantic-release/changelog",
+ {
+ "changelogFile": "CHANGELOG.md"
+ }
+ ],
+ [
+ "@semantic-release/git",
+ {
+ "assets":
+ [
+ "package.json",
+ "!package-lock.json.meta",
+ "CHANGELOG.md"
+ ],
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
+ }
+ ]
+ ]
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6533c43..5ed747d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+## [2.0.0](https://github.com/Thundernerd/Unity3D-SerializableInterface/compare/v1.12.1...v2.0.0) (2023-11-07)
+
+
+### ⚠ BREAKING CHANGES
+
+* add source generation sample
+
+### Features
+
+* add source generation sample ([d5a6da3](https://github.com/Thundernerd/Unity3D-SerializableInterface/commit/d5a6da3b59b02e507ee796782765a07ef7d9c004))
+
### [1.12.1](https://github.com/Thundernerd/Unity3D-SerializableInterface/compare/v1.12.0...v1.12.1) (2022-09-10)
diff --git a/Editor/Drawers/CustomObjectDrawer.cs b/Editor/Drawers/CustomObjectDrawer.cs
index 95ac69d..d253881 100644
--- a/Editor/Drawers/CustomObjectDrawer.cs
+++ b/Editor/Drawers/CustomObjectDrawer.cs
@@ -89,7 +89,10 @@ private void HandleMouseDown(Rect position, Rect positionWithoutThumb, Serialize
{
isSelected = positionWithoutThumb.Contains(Event.mousePosition);
ForceRepaintEditors();
- Clicked?.Invoke(property);
+ if (isSelected)
+ {
+ Clicked?.Invoke(property);
+ }
}
else if (Event.button == 1 && positionWithoutThumb.Contains(Event.mousePosition))
{
diff --git a/Runtime/Extensions.cs b/Runtime/Extensions.cs
index d89b03f..f832c89 100644
--- a/Runtime/Extensions.cs
+++ b/Runtime/Extensions.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
namespace TNRD
{
@@ -41,5 +42,21 @@ out TInterface value
{
return IsDefined(serializableInterface, out value);
}
+
+ ///
+ /// Convert a IEnumerable of Interfaces to a List of SerializableInterfaces
+ ///
+ public static List> ToSerializableInterfaceList(this IEnumerable list) where T : class
+ {
+ return list.Select(e => new SerializableInterface(e)).ToList();
+ }
+
+ ///
+ /// Convert a IEnumerable of Interfaces to an Array of SerializableInterfaces
+ ///
+ public static SerializableInterface[] ToSerializableInterfaceArray(this IEnumerable list) where T : class
+ {
+ return list.Select(e => new SerializableInterface(e)).ToArray();
+ }
}
}
diff --git a/Runtime/SerializableInterface.cs b/Runtime/SerializableInterface.cs
index a5a9224..2376d77 100644
--- a/Runtime/SerializableInterface.cs
+++ b/Runtime/SerializableInterface.cs
@@ -15,6 +15,15 @@ public class SerializableInterface : ISerializableInterface where TI
[HideInInspector, SerializeField] private UnityEngine.Object unityReference;
[SerializeReference, UsedImplicitly] private object rawReference;
+ public SerializableInterface()
+ {
+ }
+
+ public SerializableInterface(TInterface value)
+ {
+ Value = value;
+ }
+
public TInterface Value
{
get
diff --git a/Samples~/SourceGeneration/SerializableInterfaceSourceGeneration.dll b/Samples~/SourceGeneration/SerializableInterfaceSourceGeneration.dll
new file mode 100644
index 0000000..4c647b7
Binary files /dev/null and b/Samples~/SourceGeneration/SerializableInterfaceSourceGeneration.dll differ
diff --git a/Samples~/SourceGeneration/SerializableInterfaceSourceGeneration.dll.meta b/Samples~/SourceGeneration/SerializableInterfaceSourceGeneration.dll.meta
new file mode 100644
index 0000000..6bdbc11
--- /dev/null
+++ b/Samples~/SourceGeneration/SerializableInterfaceSourceGeneration.dll.meta
@@ -0,0 +1,73 @@
+fileFormatVersion: 2
+guid: 4ac13508a171e574ca523db3ef4cde8c
+labels:
+- RoslynAnalyzer
+- RunOnlyOnAssembliesWithReference
+- SourceGenerator
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ : Any
+ second:
+ enabled: 0
+ settings:
+ Exclude Editor: 1
+ Exclude Linux64: 1
+ Exclude OSXUniversal: 1
+ Exclude Win: 1
+ Exclude Win64: 1
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ DefaultValueInitialized: true
+ OS: AnyOS
+ - first:
+ Standalone: Linux64
+ second:
+ enabled: 0
+ settings:
+ CPU: None
+ - first:
+ Standalone: OSXUniversal
+ second:
+ enabled: 0
+ settings:
+ CPU: None
+ - first:
+ Standalone: Win
+ second:
+ enabled: 0
+ settings:
+ CPU: None
+ - first:
+ Standalone: Win64
+ second:
+ enabled: 0
+ settings:
+ CPU: None
+ - first:
+ Windows Store Apps: WindowsStoreApps
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/package.json b/package.json
index 55ec8f7..46c6272 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
{
"name": "net.tnrd.serializableinterface",
- "version": "1.12.1",
+ "version": "2.0.0",
"displayName": "Serializable Interface",
- "unity": "2020.1",
+ "unity": "2021.1",
"description": "A wrapper that allows serialization of interfaces that supports both UnityEngine.Object and regular object types",
"keywords": [
"serialize",
@@ -14,124 +14,11 @@
"name": "TNRD",
"url": "https://www.tnrd.net"
},
- "scripts": {
- "semantic-release": "semantic-release"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/Thundernerd/Unity3D-SerializableInterface.git"
- },
- "publishConfig": {
- "registry": "https://npm.pkg.github.com/@Thundernerd"
- },
- "devDependencies": {
- "@semantic-release/changelog": "^6.0.1",
- "@semantic-release/commit-analyzer": "^9.0.2",
- "@semantic-release/git": "^10.0.1",
- "@semantic-release/github": "^8.0.6",
- "@semantic-release/npm": "^9.0.1",
- "@semantic-release/release-notes-generator": "^10.0.3",
- "conventional-changelog-conventionalcommits": "^4.6.3",
- "semantic-release": "^19.0.5"
- },
- "release": {
- "branches": [
- "main"
- ],
- "plugins": [
- [
- "@semantic-release/commit-analyzer",
- {
- "preset": "conventionalcommits",
- "releaseRules": [
- {
- "type": "docs",
- "scope": "README",
- "release": "patch"
- },
- {
- "type": "refactor",
- "release": "patch"
- },
- {
- "scope": "no-release",
- "release": false
- }
- ],
- "parserOpts": {
- "noteKeywords": [
- "BREAKING CHANGE",
- "BREAKING CHANGES"
- ]
- }
- }
- ],
- [
- "@semantic-release/npm",
- {
- "npmPublish": true
- }
- ],
- "@semantic-release/github",
- [
- "@semantic-release/release-notes-generator",
- {
- "preset": "conventionalcommits",
- "presetConfig": {
- "types": [
- {
- "type": "feat",
- "section": "Features"
- },
- {
- "type": "fix",
- "section": "Bug Fixes"
- },
- {
- "type": "chore",
- "hidden": true
- },
- {
- "type": "docs",
- "section": "Documentation"
- },
- {
- "type": "style",
- "hidden": true
- },
- {
- "type": "refactor",
- "section": "Refactors"
- },
- {
- "type": "perf",
- "section": "Performance Improvements"
- },
- {
- "type": "test",
- "section": "Tests"
- }
- ]
- }
- }
- ],
- [
- "@semantic-release/changelog",
- {
- "changelogFile": "CHANGELOG.md"
- }
- ],
- [
- "@semantic-release/git",
- {
- "assets": [
- "package.json",
- "!package-lock.json.meta",
- "CHANGELOG.md"
- ],
- "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
- }
- ]
- ]
- }
+ "samples": [
+ {
+ "displayName": "Source Generation",
+ "description": "Contains a dll that will allow you to use source generation",
+ "path": "Samples~/SourceGeneration"
+ }
+ ]
}