- تم التحرير
How to change Skin at runtime?
Hi Harald
I can't seem to fetch the Skeleton Mecanims at Start(). Any idea why this is happening for me?
void Start()
{
_SkeletonMecanim = GameObject.Find("Dialogue").GetComponent<SkeletonMecanim>();
//THIS DOES NOT WORK IN START() FOR SOME REASON.
//I NEED TO RUN INSIDE UPDATE() FOR UNITY TO PROPERLY FETCH IT
}
private void Update()
{
if(_SkeletonMecanim == null)
{
_SkeletonMecanim = GameObject.Find("Dialogue").GetComponent<SkeletonMecanim>();
}
}
Also are there some manuals explaining the Skeleton Mecanim tools and APIs? I couldn't find them on google. :think:
Thanks for the help!
Hi!
IndieDoroid wroteI can't seem to fetch the Skeleton Mecanims at Start(). Any idea why this is happening for me?
This is strange. Do you receive an error message / null reference exception? Or does it assign null to your _SkeletonMecanim
attribute?
IndieDoroid wroteAlso are there some manuals explaining the Skeleton Mecanim tools and APIs? I couldn't find them on google. :think:
The normal Spine Runtime API applies to SkeletonMecanim
as well (as it is a SkeletonRenderer
subclass) when settings skins, attachments, etc via SkeletonMecanim.Skeleton
. It is only the animation part which is different (it does not have an AnimationState attribute for calling e.g. SetAnimation()
). Animation will be driven by Unity's Mecanim system, I assume you already know Mecanim and Unity's documentation.
Anyway thanks for the input, the new re-written documentation pages will contain an entry for SpineMecanim
, mentioning similar information.
Harald wroteThis is strange. Do you receive an error message / null reference exception? Or does it assign null to your _SkeletonMecanim attribute?
It's just null. ... I can try to do a delayed coroutine call on Start() when I got time.. but for now just running it in Update() forces SkeletonMecanim to be found. I wonder if it has to do with the Unity ver? 2018.4.0f1
Harald wroteThe normal Spine Runtime API applies to SkeletonMecanim as well (as it is a SkeletonRenderer subclass) when settings skins, attachments, etc via SkeletonMecanim.Skeleton. It is only the animation part which is different (it does not have an AnimationState attribute for calling e.g. SetAnimation()). Animation will be driven by Unity's Mecanim system, I assume you already know Mecanim and Unity's documentation.
Anyway thanks for the input, the new re-written documentation pages will contain an entry for SpineMecanim, mentioning similar information.
Ok good to know. Yea I just kind of randomly plugged into characters until some stuff made sense..
This was discovered by totally mashing keys until stuff came out. :grinteeth:
_skeletonMecanim.Initialize(true);
IndieDoroid wroteIt's just null.
... I can try to do a delayed coroutine call on Start() when I got time.. but for now just running it in Update() forces SkeletonMecanim to be found. I wonder if it has to do with the Unity ver? 2018.4.0f1
If the _SkeletonMecanim
attribute is set to null (because GetComponent<SkeletonMecanim>()
returns null
) I guess that your game logic is enabling things later and upon Start this GameObject or any of its parents is disabled. Could you check that?
Harald wroteIndieDoroid wroteIt's just null.
... I can try to do a delayed coroutine call on Start() when I got time.. but for now just running it in Update() forces SkeletonMecanim to be found. I wonder if it has to do with the Unity ver? 2018.4.0f1
If the
_SkeletonMecanim
attribute is set to null (becauseGetComponent<SkeletonMecanim>()
returnsnull
) I guess that your game logic is enabling things later and upon Start this GameObject or any of its parents is disabled. Could you check that?
Yea you're right, I tried on a new scene and I could get the skeletonMecanim from Start. Must be something I'm doing with the parent game object.
Thanks! 8)
Glad to be of help 8)