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)
- [ts][pixi] Adding a child Pixi object in a Slot that follows its transform HOT 23
- [unity] BlendModeMaterials badly supported in runtime instantiation from files
- [unity] RenderExistingMesh causing unnecessary allocation
- [unity] SkeletonDataAsset with 0 atlas assets throws confusing exception in build
- Port: Improved clipping stability for colinear points.
- Port: Added TrackEntry#isNextReady().
- [ts][phaser] Bug on build with webpack "You may need an appropriate loader to handle this file type." HOT 2
- [ts][pixi] Spine Tint Black alpha not working HOT 4
- [c][cpp] Inherit transform timelines not working as intended
- [unity] Incorrect display of additive blend mode with slot alpha in Linear color space HOT 2
- Can not build spine_flutter in release HOT 3
- [godot] v4.2.2 runtime rendering issues (PRO) HOT 3
- [ios] TODO
- [unity] Bone Name selector only displays root bone on Unity 2023.2
- [ue] Crash accessing deleted UTrackEntry as renderer object HOT 3
- [unity] Costly Vector3 *= operator on 2019.4- in MeshGenerator.ScaleVertexData
- [unity] Material in separate directory deleted upon reimport
- [ts] After upgrade to pixi v4.2.47 we got an issue there is a shadow in the animation HOT 8
- [spine-flutter] error run with spine_flutter HOT 2
- [cpp] Did a memory leak occur? HOT 1
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.