mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[unity] Added #if guards for Unity 5.x compatibility before Unity added SpriteMasks. See #941.
This commit is contained in:
parent
cac764fa01
commit
b8a208d382
@ -34,6 +34,10 @@
|
||||
#define NO_PREFAB_MESH
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_OR_NEWER
|
||||
#define BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#endif
|
||||
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -215,6 +219,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
if (setMaskNoneMaterialsQueued) {
|
||||
setMaskNoneMaterialsQueued = false;
|
||||
foreach (var c in targets)
|
||||
@ -241,8 +246,9 @@ namespace Spine.Unity.Editor {
|
||||
foreach (var c in targets)
|
||||
EditorDeleteMaskMaterials(c as SkeletonRenderer, SpriteMaskInteraction.VisibleOutsideMask);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NO_PREFAB_MESH
|
||||
#if NO_PREFAB_MESH
|
||||
if (isInspectingPrefab) {
|
||||
if (multi) {
|
||||
foreach (var c in targets) {
|
||||
@ -258,7 +264,7 @@ namespace Spine.Unity.Editor {
|
||||
meshFilter.sharedMesh = null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool valid = TargetIsValid;
|
||||
@ -362,6 +368,7 @@ namespace Spine.Unity.Editor {
|
||||
if (tangents != null) EditorGUILayout.PropertyField(tangents, TangentsLabel);
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
EditorGUILayout.Space();
|
||||
if (maskMaterialsNone.arraySize > 0 || maskMaterialsInside.arraySize > 0 || maskMaterialsOutside.arraySize > 0) {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Mask Interaction Materials", SpineInspectorUtility.UnityIcon<SpriteMask>()), EditorStyles.boldLabel);
|
||||
@ -376,6 +383,7 @@ namespace Spine.Unity.Editor {
|
||||
MaskMaterialsEditingField(ref setOutsideMaskMaterialsQueued, ref deleteOutsideMaskMaterialsQueued, maskMaterialsOutside, MaskMaterialsOutsideLabel,
|
||||
differentMaskModesSelected, allowDelete : true, isActiveMaterial: activeMaskInteractionValue == (int)SpriteMaskInteraction.VisibleOutsideMask);
|
||||
}
|
||||
#endif
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
@ -525,11 +533,20 @@ namespace Spine.Unity.Editor {
|
||||
if (component == null) return;
|
||||
if (!SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return;
|
||||
component.Initialize(true);
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
SpineMaskUtilities.EditorAssignSpriteMaskMaterials(component);
|
||||
#endif
|
||||
|
||||
component.LateUpdate();
|
||||
}
|
||||
|
||||
static bool SkeletonDataAssetIsValid (SkeletonDataAsset asset) {
|
||||
return asset != null && asset.GetSkeletonData(quiet: true) != null;
|
||||
}
|
||||
|
||||
bool AreAnyMaskMaterialsMissing() {
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
foreach (var o in targets) {
|
||||
var component = (SkeletonRenderer)o;
|
||||
if (!component.valid)
|
||||
@ -537,13 +554,11 @@ namespace Spine.Unity.Editor {
|
||||
if (SpineMaskUtilities.AreMaskMaterialsMissing(component))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool SkeletonDataAssetIsValid (SkeletonDataAsset asset) {
|
||||
return asset != null && asset.GetSkeletonData(quiet: true) != null;
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
static void EditorSetMaskMaterials(SkeletonRenderer component, SpriteMaskInteraction maskType)
|
||||
{
|
||||
if (component == null) return;
|
||||
@ -556,5 +571,6 @@ namespace Spine.Unity.Editor {
|
||||
if (!SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return;
|
||||
SpineMaskUtilities.EditorDeleteMaskMaterials(component.maskMaterials, maskType);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,6 +44,12 @@
|
||||
#define NEWHIERARCHYWINDOWCALLBACKS
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_OR_NEWER
|
||||
#define BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#endif
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
@ -241,3 +247,4 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
|
||||
@ -31,6 +31,11 @@
|
||||
#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_OR_NEWER
|
||||
#define BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#endif
|
||||
|
||||
#define SPINE_OPTIONAL_RENDEROVERRIDE
|
||||
#define SPINE_OPTIONAL_MATERIALOVERRIDE
|
||||
|
||||
@ -92,6 +97,7 @@ namespace Spine.Unity {
|
||||
/// <summary>If true, tangents are calculated every frame and added to the Mesh. Enable this when using a shader that uses lighting that requires tangents.</summary>
|
||||
public bool calculateTangents = false;
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
/// <summary>This enum controls the mode under which the sprite will interact with the masking system.</summary>
|
||||
/// <remarks>Interaction modes with <see cref="UnityEngine.SpriteMask"/> components are identical to Unity's <see cref="UnityEngine.SpriteRenderer"/>,
|
||||
/// see https://docs.unity3d.com/ScriptReference/SpriteMaskInteraction.html. </remarks>
|
||||
@ -117,6 +123,7 @@ namespace Spine.Unity {
|
||||
public const UnityEngine.Rendering.CompareFunction STENCIL_COMP_MASKINTERACTION_VISIBLE_INSIDE = UnityEngine.Rendering.CompareFunction.LessEqual;
|
||||
/// <summary>Shader property value used as Stencil comparison function for <see cref="SpriteMaskInteraction.VisibleOutsideMask"/>.</summary>
|
||||
public const UnityEngine.Rendering.CompareFunction STENCIL_COMP_MASKINTERACTION_VISIBLE_OUTSIDE = UnityEngine.Rendering.CompareFunction.Greater;
|
||||
#endif // #if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
@ -400,9 +407,11 @@ namespace Spine.Unity {
|
||||
meshFilter.sharedMesh = currentMesh;
|
||||
currentSmartMesh.instructionUsed.Set(currentInstructions);
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
if (meshRenderer != null) {
|
||||
AssignSpriteMaskMaterials();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void FindAndApplySeparatorSlots (string startsWith, bool clearExistingSeparators = true, bool updateStringArray = false) {
|
||||
@ -465,6 +474,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
private void AssignSpriteMaskMaterials()
|
||||
{
|
||||
if (maskMaterials.materialsMaskDisabled.Length > 0 && maskMaterials.materialsMaskDisabled[0] != null &&
|
||||
@ -514,5 +524,6 @@ namespace Spine.Unity {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif //#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user