Skip to content

Commit

Permalink
Merge pull request #115 from arimger/develop
Browse files Browse the repository at this point in the history
Develop - 0.13.0
  • Loading branch information
arimger authored Aug 30, 2024
2 parents 6e0f089 + d7afe76 commit 8942b99
Show file tree
Hide file tree
Showing 94 changed files with 2,155 additions and 678 deletions.
47 changes: 31 additions & 16 deletions Assets/Editor Toolbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
## 0.13.0 [28.08.2024]

### 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.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])

## 0.12.13 [22.08.2024]

### Added:
- DisableInEditModeAttribute

### Changed:
- Hierarchy: Added Tree List renderer, which improves visual identification of parent and child gameobjects
- Hierarchy: For now 'Script' label will display all available components linked to a GameObject/Prefabs
- Hierarchy: For now 'Layer' label will display full layer name instead of the layer mask value
- Fix SceneView settings change events firing when they shouldn't
- Fix issue when trying to find private fields/properties from parent classes (e.g. while using conditional attributes)

### Added:
- DisableInEditModeAttribute

## 0.12.12 [17.06.2024]

### Added:
- NotPrefabObjectOnlyAttribute

### Changed:
- LabelWidthAttribute is now part of the Toolbox decorator attributes (can be mixed with other attributes)
- Hierarchy: Script, Tag, and Layer columns are now excluded from the default settings
- Possibility to change style for groups ([BeginGroup] and [BeginHorizontalGroup] attributes)
- ScriptableObject Creation Wizard now accepts only ScriptableObjects marked with the [CreateInWizard] or [CreateAssetMenu] attributes

### Added:
- NotPrefabObjectOnlyAttribute

## 0.12.11 [05.04.2024]

### Changed:
Expand Down Expand Up @@ -53,13 +68,13 @@

## 0.12.7 [10.12.2023]

### Added:
- 'Revert Prefab Name' option for prefabs in the GameObject/Prefabs context menu

### Changed:
- Possibility to interact with ProgressBarDrawer (added IsInteractable property to the ProgressBarAttribute)
- MinMaxAttribute now supports Vector2Int

### Added:
- 'Revert Prefab Name' option for prefabs in the GameObject/Prefabs context menu

## 0.12.6 [19.10.2023]

### Changed:
Expand All @@ -68,12 +83,12 @@

## 0.12.5 [11.09.2023]

### Changed:
- Make ToolboxEditorHandler public

### Added:
- Add public OnCacheRefreshed event to the SceneSerializationUtility

### Changed:
- Make ToolboxEditorHandler public

## 0.12.4 [31.07.2023]

### Changed:
Expand All @@ -85,16 +100,16 @@

## 0.12.3 [17.06.2023]

### Added:
- SceneView extension: better way to select raycasted objects in the Scene view
- LabelWidthAttribute

### Changed:
- Fix updating SerializedScene index after deleting Scene
- Fix SerializedScene index calculation
- Fix NRE when deleted Scene was still included in Build Settings
- Fix compilation errors in Unity 2018.x

### Added:
- SceneView extension: better way to select raycasted objects in the Scene view
- LabelWidthAttribute

## 0.12.1 [12.04.2023]

### Changed:
Expand Down
8 changes: 8 additions & 0 deletions Assets/Editor Toolbox/Editor/ContextMenu.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Assets/Editor Toolbox/Editor/ContextMenu/IContextMenuOperation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using UnityEditor;
using UnityEngine;

namespace Toolbox.Editor.ContextMenu
{
internal interface IContextMenuOperation
{
bool IsVisible(SerializedProperty property);
bool IsEnabled(SerializedProperty property);
void Perform(SerializedProperty property);

GUIContent Label { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Editor Toolbox/Editor/ContextMenu/Management.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System.Collections.Generic;

using UnityEditor;

namespace Toolbox.Editor.ContextMenu.Management
{
using Toolbox.Editor.ContextMenu.Operations;

[InitializeOnLoad]
internal static class ToolboxContextMenuManager
{
private static readonly List<IContextMenuOperation> registeredOperations;

static ToolboxContextMenuManager()
{
registeredOperations = new List<IContextMenuOperation>()
{
new CopySerializeReferenceOperation(),
new PasteSerializeReferenceOperation(),
new DuplicateSerializeReferenceArrayElementOperation()
};

EditorApplication.contextualPropertyMenu -= OnContextMenuOpening;
EditorApplication.contextualPropertyMenu += OnContextMenuOpening;
}

public static void AppendOpertation(IContextMenuOperation operation)
{
registeredOperations.Add(operation);
}

public static bool RemoveOperation(IContextMenuOperation operation)
{
return registeredOperations.Remove(operation);
}

private static void OnContextMenuOpening(GenericMenu menu, SerializedProperty property)
{
foreach (var operation in registeredOperations)
{
if (!operation.IsVisible(property))
{
continue;
}

var label = operation.Label;
if (!operation.IsEnabled(property))
{
menu.AddDisabledItem(label);
continue;
}

menu.AddItem(label, false, () =>
{
operation.Perform(property);
});
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Editor Toolbox/Editor/ContextMenu/Operations.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace Toolbox.Editor.ContextMenu.Operations
{
internal class CopySerializeReferenceCache
{
public CopySerializeReferenceCache(Type referenceType, string data)
{
ReferenceType = referenceType;
Data = data;
}

public Type ReferenceType { get; }
public string Data { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using UnityEditor;
using UnityEngine;

namespace Toolbox.Editor.ContextMenu.Operations
{
internal class CopySerializeReferenceOperation : IContextMenuOperation
{
internal static CopySerializeReferenceCache Cache { get; private set; }

[InitializeOnLoadMethod]
private static void Initialize()
{
Cache = null;
}

public bool IsVisible(SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
return property != null && property.propertyType == SerializedPropertyType.ManagedReference;
#else
return false;
#endif
}

public bool IsEnabled(SerializedProperty property)
{
return true;
}

public void Perform(SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
var value = property.managedReferenceValue;
if (value != null)
{
var referenceType = value.GetType();
var data = JsonUtility.ToJson(value);
Cache = new CopySerializeReferenceCache(referenceType, data);
return;
}

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

public GUIContent Label => new GUIContent("Copy Serialize Reference");
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using UnityEditor;
using UnityEngine;

namespace Toolbox.Editor.ContextMenu.Operations
{
internal class DuplicateSerializeReferenceArrayElementOperation : IContextMenuOperation
{
public bool IsVisible(SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
return property != null && property.propertyType == SerializedPropertyType.ManagedReference &&
PropertyUtility.IsSerializableArrayElement(property);
#else
return false;
#endif
}

public bool IsEnabled(SerializedProperty property)
{
return true;
}

public void Perform(SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
var sourceProperty = property.Copy();
sourceProperty.serializedObject.Update();
var sourceValue = sourceProperty.managedReferenceValue;

var arrayProperty = PropertyUtility.GetArray(sourceProperty);
var newElementIndex = arrayProperty.arraySize;
arrayProperty.arraySize = newElementIndex + 1;
//NOTE: there will be null by default anyway
if (sourceValue != null)
{
var targetData = JsonUtility.ToJson(sourceValue);
var targetValue = JsonUtility.FromJson(targetData, sourceValue.GetType());
var targetProperty = arrayProperty.GetArrayElementAtIndex(newElementIndex);
targetProperty.managedReferenceValue = targetValue;
}

sourceProperty.serializedObject.ApplyModifiedProperties();
#endif
}

public GUIContent Label => new GUIContent("Duplicate Serialize Reference Array Element");
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8942b99

Please sign in to comment.