Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Assets/Editor Toolbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 0.14.3 [29.12.2025]

### Added:
- Ability to specify 'ValueStep' in the ProgressBar attribute

### Changed:
- Toolbar support for Unity 6.3+
- Material Drawers support for Unity 6.3+
- Serialized Scene support for Unity 6.3+
- Fix issues with copy/past operations for the [SerializeReference]-based arrays
- Ability to display parent objects in the SceneView tool
- Ability to display managed reference values while using LabelByChild attribute

## 0.14.2 [10.08.2025]

### Added:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ namespace Toolbox.Editor.ContextMenu.Operations
/// </summary>
internal class CopySerializeReferenceCache
{
public CopySerializeReferenceCache(Type referenceType, IReadOnlyList<CopySerializeReferenceEntry> entires)
public CopySerializeReferenceCache(Type referenceType, IReadOnlyList<CopySerializeReferenceEntry> entires, bool isArrayCopy)
{
ReferenceType = referenceType;
Entries = entires;
IsArrayCopy = isArrayCopy;
}

/// <summary>
/// Base managed reference type of the source <see cref="UnityEditor.SerializedProperty"/>.
/// </summary>
public Type ReferenceType { get; }
public IReadOnlyList<CopySerializeReferenceEntry> Entries { get; }
public bool IsArrayCopy => Entries != null && Entries.Count > 1;
public bool IsArrayCopy { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public bool IsEnabled(SerializedProperty property)

public void Perform(SerializedProperty property)
{
var isArrayCopy = false;
var entries = new List<CopySerializeReferenceEntry>();
if (property.propertyType == SerializedPropertyType.ManagedReference)
{
Expand All @@ -59,6 +60,7 @@ public void Perform(SerializedProperty property)
}
else if (property.isArray)
{
isArrayCopy = true;
var propertiesCount = property.arraySize;
for (var i = 0; i < propertiesCount; i++)
{
Expand All @@ -69,7 +71,7 @@ public void Perform(SerializedProperty property)
}

PropertyUtility.TryGetSerializeReferenceType(property, out var referenceType);
Cache = new CopySerializeReferenceCache(referenceType, entries);
Cache = new CopySerializeReferenceCache(referenceType, entries, isArrayCopy);
}

public GUIContent Label => new GUIContent("Copy Serialized References");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private bool IsAssignmentValid(Type targetType, CopySerializeReferenceEntry entr
return true;
}

return TypeUtility.IsTypeAssignableFrom(targetType, entry.ReferenceType);
return TypeUtility.IsTypeAssignableFrom(targetType, entryType);
}

private bool IsOperationSupported(SerializedProperty targetProperty, CopySerializeReferenceCache cache)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ protected override void OnGUISafe(Rect position, MaterialProperty prop, string l

protected override bool IsPropertyValid(MaterialProperty prop)
{
#if UNITY_6000_3_OR_NEWER
return prop.propertyType == UnityEngine.Rendering.ShaderPropertyType.Texture;
#else
return prop.type == MaterialProperty.PropType.Texture;
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ protected MaterialConditionalDrawer(string togglePropertyName)
this.togglePropertyName = togglePropertyName;
}

private bool IsValidToggleType(MaterialProperty toggleProp)
{
#if UNITY_6000_3_OR_NEWER
return toggleProp.propertyType == UnityEngine.Rendering.ShaderPropertyType.Float ||
toggleProp.propertyType == UnityEngine.Rendering.ShaderPropertyType.Range;
#else
return toggleProp.type == MaterialProperty.PropType.Float ||
toggleProp.type == MaterialProperty.PropType.Range;
#endif
}

protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
{
if (!HasToggle(prop))
Expand Down Expand Up @@ -48,7 +59,7 @@ protected virtual bool HasToggle(MaterialProperty prop)
{
var targets = prop.targets;
var toggle = MaterialEditor.GetMaterialProperty(targets, togglePropertyName);
return toggle != null && toggle.type == MaterialProperty.PropType.Float || toggle.type == MaterialProperty.PropType.Range;
return toggle != null && IsValidToggleType(toggle);
}

protected virtual bool? GetValue(MaterialProperty prop)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ protected override void OnGUISafe(Rect position, MaterialProperty prop, string l

protected override bool IsPropertyValid(MaterialProperty prop)
{
#if UNITY_6000_3_OR_NEWER
return prop.propertyType == UnityEngine.Rendering.ShaderPropertyType.Vector;
#else
return prop.type == MaterialProperty.PropType.Vector;
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ protected override void OnGUISafe(Rect position, MaterialProperty prop, string l

protected override bool IsPropertyValid(MaterialProperty prop)
{
#if UNITY_6000_3_OR_NEWER
return prop.propertyType == UnityEngine.Rendering.ShaderPropertyType.Vector;
#else
return prop.type == MaterialProperty.PropType.Vector;
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ protected override void OnGUISafe(Rect position, MaterialProperty prop, string l

protected override bool IsPropertyValid(MaterialProperty prop)
{
#if UNITY_6000_3_OR_NEWER
return prop.propertyType == UnityEngine.Rendering.ShaderPropertyType.Vector;
#else
return prop.type == MaterialProperty.PropType.Vector;
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ private void SetProgressValue(SerializedProperty property, Rect progressBarRect,
{
var minValue = Attribute.MinValue;
var maxValue = Attribute.MaxValue;
var valueStep = Attribute.ValueStep;

var range = progressBarRect.xMax - progressBarRect.xMin;
xPosition = Mathf.Clamp(xPosition - progressBarRect.xMin, 0, range);

var fill = Mathf.Clamp01(xPosition / range);
var newValue = (maxValue - minValue) * fill + minValue;
if (!Mathf.Approximately(valueStep, 0.0f))
{
newValue = Mathf.Round(newValue / valueStep) * valueStep;
newValue = Mathf.Clamp(newValue, minValue, maxValue);
}

switch (property.propertyType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class ToolboxEditorSceneViewObjectSelector : EditorWindow
{
private static readonly Color selectionColor = new Color(0.50f, 0.70f, 1.00f);
private static readonly Color highlightWireColor = Color.yellow;
private const float outlineFillOpacity = 1f;

private const float sizeXPadding = 2f;
private const float sizeYPadding = 2f;
Expand All @@ -17,10 +16,10 @@ public class ToolboxEditorSceneViewObjectSelector : EditorWindow
private const float sizeXOffset = -30f;
private const float indentWidth = 12f;

private List<DisplayEntry> displayEntries;
private readonly List<Renderer> highlightedRenderers = new List<Renderer>();

private List<DisplayEntry> displayEntries;
private GameObject highlightedObject;
private readonly List<Renderer> highlightedRenderers = new List<Renderer>();
private Vector2 size;
private Vector2 buttonSize;

Expand All @@ -42,12 +41,16 @@ public static void Show(List<GameObject> gameObjects, Vector2 position)

private void OnEnable()
{
UnityEditor.SceneView.duringSceneGui += OnSceneViewDuringSceneGui;
#if UNITY_2019_1_OR_NEWER
UnityEditor.SceneView.duringSceneGui += OnSceneViewGui;
#endif
}

private void OnDisable()
{
UnityEditor.SceneView.duringSceneGui -= OnSceneViewDuringSceneGui;
#if UNITY_2019_1_OR_NEWER
UnityEditor.SceneView.duringSceneGui -= OnSceneViewGui;
#endif
highlightedRenderers.Clear();
highlightedObject = null;
}
Expand Down Expand Up @@ -325,7 +328,10 @@ private void SelectObject(int id, bool control, bool shift)
}
else
{
Selection.objects = new Object[] { gameObject };
Selection.objects = new Object[]
{
gameObject
};
}
}

Expand Down Expand Up @@ -377,27 +383,6 @@ private void RemoveSelectedObject(GameObject gameObject)
Selection.objects = newSelection;
}

private GameObject HighlightedObject
{
set
{
if (highlightedObject == value)
{
return;
}

highlightedObject = value;
UnityEditor.SceneView.RepaintAll();

if (highlightedObject != null)
{
EditorGUIUtility.PingObject(highlightedObject);
}

UpdateHighlightedRenderers();
}
}

private void UpdateHighlightedRenderers()
{
highlightedRenderers.Clear();
Expand All @@ -410,7 +395,8 @@ private void UpdateHighlightedRenderers()
highlightedRenderers.AddRange(highlightedObject.GetComponentsInChildren<Renderer>(true));
}

private void OnSceneViewDuringSceneGui(UnityEditor.SceneView sceneView)
#if UNITY_2019_1_OR_NEWER
private void OnSceneViewGui(UnityEditor.SceneView sceneView)
{
if (highlightedRenderers.Count == 0 ||
Event.current.type != EventType.Repaint)
Expand All @@ -420,7 +406,7 @@ private void OnSceneViewDuringSceneGui(UnityEditor.SceneView sceneView)

// Unity 6.1+ provides Handles.DrawOutline which also highlights children in one call.
#if UNITY_6000_1_OR_NEWER
Handles.DrawOutline(highlightedRenderers.ToArray(), highlightWireColor, highlightWireColor, outlineFillOpacity);
Handles.DrawOutline(highlightedRenderers.ToArray(), highlightWireColor, highlightWireColor, 0.5f);
#else
using (new Handles.DrawingScope(highlightWireColor))
{
Expand All @@ -437,6 +423,28 @@ private void OnSceneViewDuringSceneGui(UnityEditor.SceneView sceneView)
}
#endif
}
#endif

private GameObject HighlightedObject
{
set
{
if (highlightedObject == value)
{
return;
}

highlightedObject = value;
UnityEditor.SceneView.RepaintAll();

if (highlightedObject != null)
{
EditorGUIUtility.PingObject(highlightedObject);
}

UpdateHighlightedRenderers();
}
}

private readonly struct DisplayEntry
{
Expand Down
6 changes: 5 additions & 1 deletion Assets/Editor Toolbox/Editor/ToolboxEditorHierarchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ private static void OnItemCallback(int instanceId, Rect rect)
}

//use Unity's internal method to determinate the proper GameObject instance
#if UNITY_6000_3_OR_NEWER
var gameObject = EditorUtility.EntityIdToObject(instanceId) as GameObject;
#else
var gameObject = EditorUtility.InstanceIDToObject(instanceId) as GameObject;
if (gameObject)
#endif
if (gameObject != null)
{
var type = GetLabelType(gameObject, out var label);
//draw label using one of the possible forms
Expand Down
Loading