Skip to content

Commit

Permalink
[unity] Fixed InvalidCastException at version upgrade. Closes #2718.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaraldCsaszar committed Dec 20, 2024
1 parent aade5d6 commit ee55855
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,16 @@ protected bool TargetIsValid {
get {
if (serializedObject.isEditingMultipleObjects) {
foreach (UnityEngine.Object c in targets) {
SkeletonGraphic component = (SkeletonGraphic)c;
SkeletonGraphic component = c as SkeletonGraphic;
if (component == null) continue;
if (!component.IsValid)
return false;
}
return true;
} else {
SkeletonGraphic component = (SkeletonGraphic)target;
SkeletonGraphic component = target as SkeletonGraphic;
if (component == null)
return false;
return component.IsValid;
}
}
Expand Down Expand Up @@ -230,7 +233,8 @@ void OnPlaymodeChanged () {

protected virtual void DisableEditReferenceRectMode () {
foreach (UnityEngine.Object c in targets) {
SkeletonGraphic component = (SkeletonGraphic)c;
SkeletonGraphic component = c as SkeletonGraphic;
if (component == null) continue;
component.EditReferenceRect = false;
}
}
Expand Down Expand Up @@ -279,8 +283,10 @@ public override void OnInspectorGUI () {
EditorGUILayout.PropertyField(material);
if (GUILayout.Button("Detect", EditorStyles.miniButton, GUILayout.Width(67f))) {
Undo.RecordObjects(targets, "Detect Material");
foreach (UnityEngine.Object skeletonGraphic in targets) {
DetectMaterial((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
DetectMaterial(skeletonGraphic);
}
}
}
Expand Down Expand Up @@ -321,8 +327,10 @@ public override void OnInspectorGUI () {
EditorStyles.miniButton, GUILayout.Width(100f))) {

Undo.RecordObjects(targets, "Trim Renderers");
foreach (UnityEngine.Object skeletonGraphic in targets) {
((SkeletonGraphic)skeletonGraphic).TrimRenderers();
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
skeletonGraphic.TrimRenderers();
}
}
EditorGUILayout.EndHorizontal();
Expand All @@ -337,8 +345,10 @@ public override void OnInspectorGUI () {
EditorStyles.miniButton, GUILayout.Width(100f))) {

Undo.RecordObjects(targets, "Detect Blend Mode Materials");
foreach (UnityEngine.Object skeletonGraphic in targets) {
DetectBlendModeMaterials((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
DetectBlendModeMaterials(skeletonGraphic);
}
}
EditorGUILayout.EndHorizontal();
Expand Down Expand Up @@ -445,8 +455,10 @@ public override void OnInspectorGUI () {
EditorGUILayout.BeginHorizontal(GUILayout.Height(EditorGUIUtility.singleLineHeight + 5));
EditorGUILayout.PrefixLabel("Match RectTransform with Mesh");
if (GUILayout.Button("Match", EditorStyles.miniButton, GUILayout.Width(65f))) {
foreach (UnityEngine.Object skeletonGraphic in targets) {
MatchRectTransformWithBounds((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
MatchRectTransformWithBounds(skeletonGraphic);
}
}
EditorGUILayout.EndHorizontal();
Expand All @@ -471,7 +483,8 @@ public override void OnInspectorGUI () {

if (slotsReapplyRequired && UnityEngine.Event.current.type == EventType.Repaint) {
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = (SkeletonGraphic)target;
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
skeletonGraphic.ReapplySeparatorSlotNames();
skeletonGraphic.LateUpdate();
SceneView.RepaintAll();
Expand All @@ -494,43 +507,53 @@ protected void DrawMeshSettings () {
EditorGUILayout.PropertyField(tintBlack, TintBlackLabel);
if (GUILayout.Button("Detect", EditorStyles.miniButton, GUILayout.Width(65f))) {
Undo.RecordObjects(targets, "Detect Tint Black");
foreach (UnityEngine.Object skeletonGraphic in targets) {
DetectTintBlack((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
DetectTintBlack(skeletonGraphic);
}
}
}
using (new EditorGUILayout.HorizontalScope()) {
EditorGUILayout.PropertyField(canvasGroupCompatible, CanvasGroupCompatibleLabel);
if (GUILayout.Button("Detect", EditorStyles.miniButton, GUILayout.Width(65f))) {
Undo.RecordObjects(targets, "Detect CanvasGroup Compatible");
foreach (UnityEngine.Object skeletonGraphic in targets) {
DetectCanvasGroupCompatible((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
DetectCanvasGroupCompatible(skeletonGraphic);
}
}
}
using (new EditorGUILayout.HorizontalScope()) {
EditorGUILayout.PropertyField(pmaVertexColors, PMAVertexColorsLabel);
if (GUILayout.Button("Detect", EditorStyles.miniButton, GUILayout.Width(65f))) {
Undo.RecordObjects(targets, "Detect PMA Vertex Colors");
foreach (UnityEngine.Object skeletonGraphic in targets) {
DetectPMAVertexColors((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
DetectPMAVertexColors(skeletonGraphic);
}
}
}
using (new EditorGUILayout.HorizontalScope()) {
GUILayout.FlexibleSpace();
if (GUILayout.Button("Detect Settings", EditorStyles.miniButton, GUILayout.Width(100f))) {
Undo.RecordObjects(targets, "Detect Settings");
foreach (UnityEngine.Object skeletonGraphic in targets) {
DetectTintBlack((SkeletonGraphic)skeletonGraphic);
DetectCanvasGroupCompatible((SkeletonGraphic)skeletonGraphic);
DetectPMAVertexColors((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object targets in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
DetectTintBlack(skeletonGraphic);
DetectCanvasGroupCompatible(skeletonGraphic);
DetectPMAVertexColors(skeletonGraphic);
}
}
if (GUILayout.Button("Detect Material", EditorStyles.miniButton, GUILayout.Width(100f))) {
Undo.RecordObjects(targets, "Detect Material");
foreach (UnityEngine.Object skeletonGraphic in targets) {
DetectMaterial((SkeletonGraphic)skeletonGraphic);
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
DetectMaterial(skeletonGraphic);
}
}
}
Expand All @@ -543,7 +566,8 @@ protected void DrawMeshSettings () {

protected bool SkeletonHasMultipleSubmeshes () {
foreach (UnityEngine.Object target in targets) {
SkeletonGraphic skeletonGraphic = (SkeletonGraphic)target;
SkeletonGraphic skeletonGraphic = target as SkeletonGraphic;
if (skeletonGraphic == null) continue;
if (skeletonGraphic.HasMultipleSubmeshInstructions())
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion spine-unity/Assets/Spine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core.",
"version": "4.2.93",
"version": "4.2.94",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",
Expand Down

0 comments on commit ee55855

Please sign in to comment.