Comments (13)
How do you reproduce this? Seems to work fine if I change the SpineboyComponent to:
public void OnMouseDown () {
SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>();
skeletonAnimation.enabled = !skeletonAnimation.enabled; // <- added this
skeletonAnimation.state.SetAnimation("jump", false);
skeletonAnimation.state.AddAnimation("walk", true);
}
from spine-runtimes.
Did some more snooping.
I added these lines right before the colors and uvs get submitted to the mesh:
if(vertices == null)
Debug.Log ("vertices was null");
if(vertices.Length != colors.Length)
Debug.Log (vertices.Length.ToString() + " " + colors.Length.ToString());
and... for some reason, I get this:
NullReferenceException: Object reference not set to an instance of an object
SkeletonComponent.Update () (at Assets/Plugins/Spine/SkeletonComponent.cs:166)
line 166 is the first if-check.
I also get the error at 168.
Could it have something to do with the fact that my skeleton has a setup pose that has all its slots set to have no image/attachments?
from spine-runtimes.
Hard to say. Set a breakpoint?
from spine-runtimes.
found the prob. Not sure what the best solution is:
// Count quads.
int quadCount = 0;
List<Slot> drawOrder = skeleton.DrawOrder;
for (int i = 0, n = drawOrder.Count; i < n; i++) {
Slot slot = drawOrder[i];
Attachment attachment = slot.Attachment;
if (attachment is RegionAttachment)
quadCount++;
}
// Ensure mesh data is the right size.
Vector3[] vertices = this.vertices;
bool newTriangles = quadCount > vertices.Length / 4;
if (newTriangles) {
this.vertices = vertices = new Vector3[quadCount * 4];
colors = new Color[quadCount * 4];
uvs = new Vector2[quadCount * 4];
triangles = new int[quadCount * 6];
mesh.Clear();
If none of the slots had an image attachment when it begins, quadCount stays 0.
And if it's 0, newTriangles evaluates to false;
therefore, colors, uvs and vertices never get allocated for and assigned.
from spine-runtimes.
just off the top of my head
if (quadCount == 0) return;
? xD
from spine-runtimes.
Yea that sounds good.
from spine-runtimes.
actually, it might be
if(quadCount == 0) {
mesh.Clear();
return;
}
I'll have to test this thoroughly to see if it works well in other cases.
from spine-runtimes.
public virtual void OnDisable () {
if (Application.isEditor)
Clear();
}
The OnDisable code seems to cause it to behave differently when testing the game in Unity and when testing the game as a standalone.
More weird things started to happen (which gets fixed when I comment this out).
I'll have to look into this further.
from spine-runtimes.
Any updates on the weirdness? :)
from spine-runtimes.
Haven't been able to get a hold of hippocoder.
Anyway, turns out
if(quadCount == 0) {
mesh.Clear();
return;
}
is kind of unnecessary if I just make sure the stuff that were instantiated in Initialize() don't get obliterated by Clear() with OnDisable() either while testing the game or in an actual build.
I kinda get the logic behind clearing these things in the editor while editing, but the current code unfortunately has the effect of also making SkeletonComponents go crazy while testing the game in the editor under those conditions: imageless setup pose + enabling and disabling Unity GameObjects as part of game logicβ a common setup for me for effects animations.
What I just did was just comment out OnDisable() and it works fine. Pretty sure that removes something useful you were trying to do with it in the first place though, so I'm not sure what to recommend.
from spine-runtimes.
TBH, I don't really remember WTH I was doing. Unity's lifecycle stuff isn't super clear. Probably it is there to reset the state when things change in the editor...
from spine-runtimes.
I guess we'll close this one for now. Can always reopen if needed.
from spine-runtimes.
Just for the record.
#if UNITY_EDITOR
public virtual void OnDisable () {
Clear();
}
#endif
This still caused the same problem. Commenting it out still fixes it.
from spine-runtimes.
Related Issues (20)
- MeshGenerator.ScaleVertexData have Vector3.op_Multiply() Vector3..ctor() HOT 5
- [cocos2dx] Two-color tinted skeletons do not render on the first frame HOT 8
- [phaser] texture flicker when creating new SpineGameObject HOT 1
- [ts][threejs] Blending mode not working properly
- [cocos2dx] Double free warning in Spine Examples HOT 2
- [player] Allow loading different data files. HOT 1
- [sfml] Multiply blend mode + non-PMA doesn't look correct on Celestial Circus HOT 1
- [ts] WebGPU support and Spine-Pixi runtime HOT 2
- [c] Scale Problem after 4.2 Upgrade HOT 4
- [ue] The cast shadow is slightly off the skeleton's boundary when using `SpineLitNormalMaterial`. HOT 1
- [runtimes] Copy constructor for Constraints reference bones and slots of the original skeleton HOT 2
- [spine-csharp] Skeleton.PhysicsRotate references the field r instead of the parameter x HOT 1
- [unity] SkeletonGraphicRenderTexture example component RenderTexture distorted
- [godot] Crash in SpineSlotNode if SpineSprite parent does not have skeleton data set HOT 5
- [runtimes] Skeleton.getBounds() should apply clipping
- [godot] Leak in editor when scene with multiple SpineSpriteNodes is open
- [spine-csharp] MathUtils.Atan2Deg isn't defined when USE_FAST_SIN_COS_ATAN2_APPROXIMATIONS is defined HOT 1
- [TS] MixDuration setter issues HOT 3
- [unity] UpdateWhenInvisible incorrect when using SkeletonRenderSeparator
- [unity] SkeletonGraphicRenderTexture incorrect alpha blending
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spine-runtimes.