Skip to content

Commit

Permalink
Update: README.md, CHANGELOG.md; minor fixes and refactor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arimger committed Aug 29, 2024
1 parent 37e7ea1 commit a071103
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Assets/Editor Toolbox/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
### Added:
- Warning information if currently serialized type in TypeField-based drawers (SerializedType, [ReferencerPicker]) is not available in the filtered types collection
- Context menu operations for [SerializeReference] properties (Copy, Paste, Duplicate), all operations are based on a deep copy of the source reference
- Basic support for generic references while using [SerializeReference] & [ReferencePicker], can be utilized in Unity 2023+
- Basic support for generic references while using [SerializeReference] & [ReferencePicker], can be utilized in Unity 2023.2.x+
- More unit tests (PropertyUtility, filtering generic types)
- Validation of assigned assets in the SerializedDirectory class

### Changed:
- Fix duplicated initialization process forced by the OnValidate call
- Better support for generic types for the SerializedType & associated drawer
- Hierarchy: For now 'Script' label displays maximum 5 scripts
- Improved types label generation for TypeField-based drawers (SerializedType, [ReferencerPicker])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Toolbox.Editor.ContextMenu.Operations
{
internal class CopySerializedRererenceCache
internal class CopySerializeReferenceCache
{
public CopySerializedRererenceCache(Type referenceType, string data)
public CopySerializeReferenceCache(Type referenceType, string data)
{
ReferenceType = referenceType;
Data = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Toolbox.Editor.ContextMenu.Operations
{
internal class CopySerializeReferenceOperation : IContextMenuOperation
{
internal static CopySerializedRererenceCache Cache { get; private set; }
internal static CopySerializeReferenceCache Cache { get; private set; }

[InitializeOnLoadMethod]
private static void Initialize()
Expand Down Expand Up @@ -35,11 +35,11 @@ public void Perform(SerializedProperty property)
{
var referenceType = value.GetType();
var data = JsonUtility.ToJson(value);
Cache = new CopySerializedRererenceCache(referenceType, data);
Cache = new CopySerializeReferenceCache(referenceType, data);
return;
}

Cache = new CopySerializedRererenceCache(null, null);
Cache = new CopySerializeReferenceCache(null, null);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public TypeConstraintStandard(Type targetType, TypeSettings settings, bool allow
AllowObsolete = allowObsolete;
}


public override bool IsSatisfied(Type type)
{
return base.IsSatisfied(type) &&
Expand Down Expand Up @@ -46,7 +45,6 @@ public override int GetHashCode()
return hashCode;
}


public TypeSettings Settings { get; set; }
public bool AllowAbstract { get; set; }
public bool AllowObsolete { get; set; }
Expand Down
8 changes: 8 additions & 0 deletions Assets/Editor Toolbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Unity 2018.x or newer
- Enable/disable Toolbox drawers or/and assign custom drawers
- Enable/disable Toolbox Scene View and assign hotkeys

---
> [!IMPORTANT]
> This package is fully IMGUI-based, which means it may conflict with pure UI Toolkit features in your project. Additionally, Toolbox overwrites the 'base' custom Editor for all `UnityEngine.Objects`, it's a common solution but means that you can't combine other Inspector extensions/plugins.
## Table Of Contents

- [Attributes & Drawers](#drawers)
Expand Down Expand Up @@ -76,6 +80,10 @@ If you want to keep your custom settings between UET versions, create your own s
Create/Editor Toolbox/Settings
```

---
> [!IMPORTANT]
> If you are getting warnings related to the current settings state, it most likely means that some features are not present in your Unity version. I suggest creating your own settings file and adjusting potential issues. Generally, it's always better to use a custom settings file rather than the default one. I'm planning to replace the ScriptableObject-based solution in the future, so it won't be a problem anymore.
## Attributes & Drawers <a name="drawers"></a>

### Regular Drawers <a name="regulardrawers"></a>
Expand Down
22 changes: 17 additions & 5 deletions Assets/Editor Toolbox/Tests/Editor/TypesFilteringTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#pragma warning disable CS0612

using NUnit.Framework;

using System;

using NUnit.Framework;
using UnityEngine;

namespace Toolbox.Editor.Tests
Expand All @@ -21,6 +19,8 @@ public interface Interface4<T> : Interface3 { }
public interface Interface5 : Interface4<int> { }
public interface Interface6 : Interface4<string> { }
public interface Interface7<T> : Interface4<T> { }
public interface Interface8<T1, T2> : Interface4<T1> { }
public interface Interface9 : Interface8<int, int> { }

public abstract class ClassBase : Interface1 { }

Expand All @@ -32,6 +32,8 @@ public class ClassWithInterface4<T> : ClassBase, Interface4<T> { }
public class ClassWithInterface5 : ClassWithInterface4<int> { }
public class ClassWithInterface6 : ClassWithInterface4<string> { }
public class ClassWithInterface7<T> : ClassWithInterface4<T> { }
public class ClassWithInterface8<T1, T2> : ClassWithInterface4<T1> { }
public class ClassWithInterface9 : ClassWithInterface8<int, int> { }

[TestCase(typeof(ClassBase), 3)]
[TestCase(typeof(Interface1), 6)]
Expand Down Expand Up @@ -148,6 +150,12 @@ public void TestStandardConstraintWithGenericPass()
Assert.IsTrue(collection.Contains(typeof(Interface5)));
Assert.IsFalse(collection.Contains(typeof(Interface6)));
Assert.IsTrue(collection.Contains(typeof(Interface7<int>)));
Assert.IsFalse(collection.Contains(typeof(Interface8<string, string>)));
Assert.IsTrue(collection.Contains(typeof(Interface9)));

//NOTE: not supported since the 2nd argument should be "picked", we don't want to generate all available options
Assert.IsFalse(collection.Contains(typeof(Interface8<int, int>)));
Assert.IsFalse(collection.Contains(typeof(Interface8<int, string>)));
}

[Test]
Expand Down Expand Up @@ -199,13 +207,17 @@ public void TestSerializeReferenceConstraintWithGenericPass()
Assert.IsTrue(collection.Contains(typeof(ClassWithInterface5)));
Assert.IsFalse(collection.Contains(typeof(ClassWithInterface6)));
Assert.IsFalse(collection.Contains(typeof(ClassWithInterface7<string>)));
Assert.IsTrue(collection.Contains(typeof(ClassWithInterface9)));
#if UNITY_2023_2_OR_NEWER
Assert.IsTrue(collection.Contains(typeof(ClassWithInterface7<int>)));
Assert.IsTrue(collection.Contains(typeof(ClassWithInterface4<int>)));
Assert.IsTrue(collection.Contains(typeof(ClassWithInterface7<int>)));
#else
Assert.IsFalse(collection.Contains(typeof(ClassWithInterface7<int>)));
Assert.IsFalse(collection.Contains(typeof(ClassWithInterface4<int>)));
Assert.IsFalse(collection.Contains(typeof(ClassWithInterface7<int>)));
#endif

//NOTE: not supported since the 2nd argument should be "picked", we don't want to generate all available options
Assert.IsFalse(collection.Contains(typeof(ClassWithInterface8<int, int>)));
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Unity 2018.x or newer
- Enable/disable Toolbox drawers or/and assign custom drawers
- Enable/disable Toolbox Scene View and assign hotkeys

---
> [!IMPORTANT]
> This package is fully IMGUI-based, which means it may conflict with pure UI Toolkit features in your project. Additionally, Toolbox overwrites the 'base' custom Editor for all `UnityEngine.Objects`, it's a common solution but means that you can't combine other Inspector extensions/plugins.
## Table Of Contents

- [Attributes & Drawers](#drawers)
Expand Down Expand Up @@ -76,6 +80,10 @@ If you want to keep your custom settings between UET versions, create your own s
Create/Editor Toolbox/Settings
```

---
> [!IMPORTANT]
> If you are getting warnings related to the current settings state, it most likely means that some features are not present in your Unity version. I suggest creating your own settings file and adjusting potential issues. Generally, it's always better to use a custom settings file rather than the default one. I'm planning to replace the ScriptableObject-based solution in the future, so it won't be a problem anymore.
## Attributes & Drawers <a name="drawers"></a>

### Regular Drawers <a name="regulardrawers"></a>
Expand Down

0 comments on commit a071103

Please sign in to comment.