zepht

  • 13 авг
  • Регистрация: 2 мар

    I have modified the relevant scripts and implemented the functionality myself. The case has been resolved.

    In BoneFollower I made such adjustment

    		} else { // For special cases: Use transform world properties if transform relationship is complicated
    			if (!skeletonTransform) return;
    
    			Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY, SkeletonRenderer.GetBoneDepth(bone) )); // Added "SkeletonRenderer.GetBoneDepth(bone)" replacing "0f"
    			if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
    			if (!followXYPosition) {
    				targetWorldPosition.x = thisTransform.position.x;
    				targetWorldPosition.y = thisTransform.position.y;
    			}

    And at the end of SkeletonRenderer I simply added the function

    	public float GetBoneDepth(Bone bone)
    	{
    		return zSpacing * skeleton.DrawOrder.FindIndex( x => x.Bone == bone);
    	}
    • Изменено

    Problem statement

    Due to the context of my project, I am running a spine skeleton rig with an opaque shader, therefore I have added Z spacing to my rig to prevent z-fighting. The character in my project wears a necklace with a bone to which a pendant is supposed to be slotted into, therefore I have created an object with a bone follower to attach a visual to the pendant.

    This can work as intended with following the intended bone on XY and rotation, but doesnt work for when the player turns around, which has the bone behind the torso, but the pendant does not care and renders in front anyways. This is not a rendering issue, for the pendant can be obscured by the body, but rather an issue because the Z depth of the pendant is not affected by the depth of the associated bone.

    My diagnosis arises with the fact that despite "Follow Z Position" being checked on the BoneFollower, it ignores the Z position created by the "Z Spacing" on the SkeletonAnimator.

    The Z spacing has been exaggerated in the screenshots for demonstration purposes

    Intended:
    Facing Forwards: (note how the selected object should be sandwiched between the head and necklace layers)
    {Intended Forwards}

    Facing Backwards:
    {Intended Back}

    Resultant:
    Facing Forwards: (notice how the depth coordinate remains entirely unchanged)
    {Result Forwards}

    Facing Backwards:
    {Result Back}

    Editor information

    Spine Unity 4.2 - Just updated trying to fix this issue
    Unity 6000.0.32f1

    Harald Thanks for the quick resolution! I've updated my files and it appears to function as intended now!

    Hello, apologies for the delay, things have been busy.

    I have updated my project via downloading the latest version from the attached link, and then by dragging it into unity and hitting apply on the import, then proceeded to close and reopen the project just in case.

    Unfortunately this did not resolve the issue.


    All of the relevant files are in this same folder together and are as follows:

    • Mat Custom - my custom shader graph material
    • Mat Lit - A default unity URP lit material
    • [name].json
    • [name].png
    • [name].atlas.txt
    • [name]_Atlas.asset
    • [name]_Material.mat
    • [name]_SkeletonData.asset

    I've checked and the issue persists equally for both a custom and a lit shader, changing any setting on the png deletes the material if it is assigned within the Materials collection on the Atlas.

    In terms of reproduction steps:
    I import the files by dragging the .atlas.txt , .png and .json (exports received from our spine artist), into the unity folder seen above. The remaining [name] assets get automatically generated and then i create new materials to test with. I then assign the relevant texture to the material and assign the material to the Materials collection on the atlas as seen above. Making ANY change to the .png settings and hitting Apply then deletes that material entirely and replaces the material in the Materials collection on the atlas with the default generated material.

    When i refer to the settings on the texture, I mean it on this window.

    So far I am getting the exact same results between two separately constructed projects. If you would like me to provide further information, or deem that it would be better if i share a minimal project after all then do please let me know.

    I'm using Unity with spine assets, in URP. The characters use a designated material made with shadergraph and the material is applied within the designated Spine Atlas Asset.

    This material functionality works perfectly fine in terms of functionality. I can edit the parameters such as specific colours perfectly fine, and I can adjust which graphic it uses too. However, if I were to change a setting on, or fully reimport, the mainTex art asset, the custom material gets fully deleted, and the Spine Atlas Asset switches to using the default generated material instead.

    When the custom material doesn't have an asset with the correct name in the mainTex slot, it throws a few errors, so perhaps that has something to do with it. Maybe when the material is being refreshed due to the asset updating, some check doesn't see the asset as existing and thus hits an eject button. That's my current theory for the situation at least.

    I am working in unity 6000.0.32f1
    and using spine installed with the package called: spine-unity-4.2-2024-09-12

    Changing settings on the art asset throws logs in the chat:

    Player Character Purple_Final_Atlas :: Imported with 1 material
    UnityEngine.Debug:Log (object,UnityEngine.Object)
    Spine.Unity.Editor.AssetUtility:IngestSpineAtlas (UnityEngine.TextAsset,System.Collections.Generic.List`1<string>) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:733)
    Spine.Unity.Editor.AssetUtility:ImportSpineContent (string[],System.Collections.Generic.List`1<string>,bool) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:403)
    Spine.Unity.Editor.AssetUtility:HandleOnPostprocessAllAssets (string[],System.Collections.Generic.List`1<string>) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:118)
    Spine.Unity.Editor.SpineEditorUtilities:OnPostprocessAllAssets (string[],string[],string[],string[]) (at Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:102)
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

    and also:

    Changes to 'Assets/Characters/Player1/Player Character Purple_Final.json' or atlas detected. Clearing SkeletonDataAsset: Assets/Characters/Player1/Player Character Purple_Final_SkeletonData.asset
    UnityEngine.Debug:LogFormat (string,object[])
    Spine.Unity.Editor.AssetUtility:ReloadSkeletonData (string,Spine.Unity.SkeletonDataCompatibility/CompatibilityProblemInfo) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:578)
    Spine.Unity.Editor.AssetUtility:ImportSpineContent (string[],System.Collections.Generic.List`1<string>,bool) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:419)
    Spine.Unity.Editor.AssetUtility:HandleOnPostprocessAllAssets (string[],System.Collections.Generic.List`1<string>) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:118)
    Spine.Unity.Editor.SpineEditorUtilities:OnPostprocessAllAssets (string[],string[],string[],string[]) (at Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:102)
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    • Harald ответили на это сообщение.