Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

SM2 - 2D made easy and efficient!

Discussion in 'iOS and tvOS' started by Brady, Nov 4, 2009.

  1. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    Assets/Plugins/Sprite Scripts/Sprite.cs(818,30): error CS0115: `Sprite.DoMirror()' is marked as an override but no suitable method found to override
     
  2. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    That sounds like a version mismatch. If you are using EZ GUI with SM2, make sure you are using the latest versions of both. Or if you are using the beta of one, you will need to use the beta of the other. This is because both libraries use a few of the same base classes.
     
  3. blacksmithgames

    blacksmithgames

    Joined:
    Aug 30, 2009
    Posts:
    24
    Hi,

    sometimes when we build a new Atlas with a new material, the atlas doesn't update the new UV coordinates and our packed Sprites are looking weird ;-) Can you help out?
     
  4. Disaster

    Disaster

    Joined:
    Oct 31, 2009
    Posts:
    43
    Brady,

    Is there a way to transfer our SM2 purchases to Unity Asset store purchases? I'd really like the convenience of managing my download and any updates through the asset store but obviously this product was released before it was available.
     
  5. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    sm2 texture to tile it?
    Used to design the level terrain
     
  6. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @blacksmithgames
    Check the topic "Sprites are messed up after atlas build" in the troubleshooting section of the docs.


    @Disaster
    Unfortunately, no, Unity doesn't have a way to do this. However, it's just as well for now since updates appear sooner via the site compared to the Asset Store due to the screening time required for Asset Store submissions.


    @hxx2010
    If you mean being able to tile a texture in SM2, for that you would probably want to use the "Sprite" component, and then specify a width/height that was the desired multiple of the actual size. So if it's a 32x32 texture, and you want to tile it 4 times horizontally, then specify a width (in your pixel dimensions setting) of 128.
     
  7. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    as of late, we're getting issues with SpriteText objects. I dont have time to post anything now, but here's a quick run through, hopefully someone has run into this issue, and can offer insight.

    if I DUPLICATE a gameobject with a spriteText component, that was already setup and functioning BEFORE the duplication(done in the hierarchy menu), I then have the spritetext (visually)disappear(on the duplicated gameobject) as soon as I press play in the editor; before hand though(before pressing play), the text is still displaying properly in the editor. From there on, the text doesn't display at all, even after changing the text-to-be-displayed in the component, or after tweaking any other setting in the component.

    I then have to completely remove the spriteText component from that newly duplicated gameobject, and replace it with a new SpriteText component, to then be able to see the SpriteText visually display in the editor after pressing play; thus having to completely recreate every spriteText object.

    OR, and this is VERY odd IMO: I can duplicate that initial gameobject exactly 3 times, and then, before I tweak any options on any of their individual SpriteText components, I can press play, then only 2 of the 3 newly duplicated SpriteText gameobjects disappear(visually) permanently, with 1 remaining and properly functioning, LOL. At least 1 now works properly. Don't ask me how much bug-hunting it too to find that solution ;-). At least its a solution, but its redundant after the hundredth time I have to perform it.

    Does anyone have any insight into this issue, without me needing to post scene files to assist(would be a headache, given how much NDA content I'd need to strip out first). Thanks for any help that can be offered.
     
  8. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    That's very strange. I did some tests here and am unable to reproduce the problem. Does this only happen in your project, or would it be something you could put together in a simple bare-bones project? If so, if you could e-mail it to me privately, I'd be happy to check it out.
     
  9. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hey Brady, I never asked this about SM2 before, but does it help reduce fill rate issues? I would assume it does correct?
     
  10. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    If you mean, does SM2 reduce fillrate issues, I'm not sure how to answer that. On the one hand, my first reaction to that is, "no, since if you need to draw certain pixels on the screen, then they'll still eat the same amount of fillrate regardless of what you use to draw them." But then again, I think about the blurb I have on the SM2 page regarding the particle effects middleware that works with SM2, and in that sense, it CAN help to reduce fillrate, if your alternative was drawing several particles over the same region of the screen over and over. So insofar as sprite-based animation reduces fillrate usage in comparison to achieving similar effects by other means, yes, that saves fillrate.

    And then another thing occurs to me: SM2's automatic trimming feature which trims away "empty" regions of a sprite graphic will also save fillrate, and in some extreme cases, possibly TONS of fillrate, by only rendering the visible portion of the image, rather than alpha blending tons of 100% transparent pixels needlessly.

    So contrary to my initial gut reaction, after thinking about it, yes, there are definitely ways in which SM2 can help save fillrate. And on top of that, it also saves texture memory (from trimming), etc.
     
  11. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    That's what I thought, since it trims away the extra alpha around the sprite. So in essence I dont' have much fillrate issues on iPhone 4.

    I've been going around optimizing stuff, and one thing hit me, some of my sprites that share the same material still does its own draw. For example this sprite text in the pic. The "Reap Version" one doesnt seem to be batching at all...

    Edit: So I had to delete the "Reap versions" spritetext and create a new one for it to batch correctly?...I have similar problems with actual sprite buttons in my scene for some reaons...
     

    Attached Files:

    Last edited: Jun 15, 2011
  12. liquidgraph

    liquidgraph

    Joined:
    Feb 26, 2009
    Posts:
    324
    I wanted to share this with you guys.

    One of the biggest headaches when working with lots of sprites or GUI elements is to reapply the same settings over and over again to newly imported textures. The following little script will handle all that for you in 4 clicks. Simply select all the textures you'd like to set up and then go to Custom >> Textures >> Apply Sprite Settings. Viola!

    If you don't like my default settings, you can easily change them to whatever suits your project's needs. To install this script, just import into your project or drop the script into the Editor folder (must be in that folder or it won't work).

    View attachment $Batch Texture Sprite Setup.unitypackage
     
  13. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @jrricky
    Did you check the Troubleshooting docs under the topic "More draw calls than expected"? That explains some of the various situations where sprites won't batch and work-arounds for these situations.
     
  14. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Brady, it seems to have returned. I wouldnt expect something like this to be happening to similar material items. I am using the SpriteText option of SM@ too...I tried all 3 steps of troubleshooting but nothing works...

    Edit: it seems making all elements use same render camera helps batching?..
     
    Last edited: Jun 16, 2011
  15. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Yes, since cameras are rendered separately, if you have something rendering for camera 1, and something else rendering for camera 2, even though the two things may share a material, the cameras themselves are rendered in separate passes, so you will get two draw calls.
     
  16. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Also, Ive noticed that disabling 'cast shadows' and 'receive shadows' in the mesh renderer helps too?
     
  17. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    OK, I seem to have gotten my game HUD draw calls taken care of. What I need to understand is the internal profiler, and reading it to know if I have a fillrate problem. The render part of the profiler is averaging around 5 which is good I guess. If I had a fillrate problem, would my render be higher?
     
  18. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I don't think changing the cast and receive shadows options will have any affect if you don't have any shadow-casting lights in the scene. Same goes for mobile since realtime shadows aren't enabled.

    Regarding fillrate, actually, enable the Overdraw visualization mode in the scene view by changing it from "RGB" to "Overdraw". This will visually show you how much overdraw there is.

    Regarding reading the profile output, if you mean it is currently showing 5ms, yes, I would say that it would be higher if fillrate was a problem.
     
  19. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    I just bought sprite manager 2 and I dont see static texture or frames in the packed sprite like in the tutorial video on your website. Do I have to write that code myself?
     
  20. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    No, you may be looking at one of the videos under the "Older videos" heading, which show the old inspector interface. Since several versions ago, in order to keep your final builds clean and not include source textures, you now do all the setup using the Sprite Timeline window. See the newer videos on the site for illustrations on using this, as well as the docs. See the "Getting Started" section in the SM2 docs, which is the first page.
     
  21. smithlim

    smithlim

    Joined:
    Nov 18, 2009
    Posts:
    21
    Hello~

    How to destory the gameobject made of SM2?
    I just made a prefab using SM2. and then I loaded the prefab and Object.Instantiate().
    after using these sprite objects, I destroyed the gameObject using GameObject.Destory().
    but the system memeory was not released. I tested it on the Windows StandAlone Mode.
    please help me.^^
    ex)

    loading code:

    List<GameObject> spriteList = new List<GameObject>;
    GameObject GO = (GameObject)Resources.Load(prefabPath, typeof(GameObject));
    if (GO != null)
    {
    for (int i = 0, i < 10, i++)
    {
    GameObject spriteGO = (GameObject)Object.Instantiate(GO); // clone 10 spriteObject. increase system Memory
    spriteList.Add(spriteGO);
    }
    }

    destory code:
    for (int i = 0, i < 10 , i)
    {
    GameObject.Destory(spriteList); // never decrease the SystemMemory. but, disappear on the screen.
    }
     
  22. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    If you're expecting the memory from the texture atlas the sprites use to be automatically freed, that won't happen. Unity doesn't even have a way I know of to explicitly free it on-demand. The issue of how to explicitly free texture memory comes up all the time on the Unity forums.

    On the other hand, if you're referring to the memory from the sprites themselves, excluding the texture memory, remember that the garbage collector has to run before the memory will actually be freed, which doesn't happen immediately unless you call GC.Collect(). Also make sure you don't keep any references to those objects.
     
  23. lbjorseth

    lbjorseth

    Joined:
    Oct 23, 2008
    Posts:
    26
    Hi, I have a problem using the supersprite. I try to combine 3 animations into 1 animation with the supersprite. But when I try to play it, it looks like its skipping/missing a frame between each of the 3 sprite anims. So it looks like its flickring/blinking. You can easily see that the animation consist of three separate animations. it is three 1024x1024 packed sprite animations.
    I have set my supersprite to Deactivate Non Playing. Also have a static frame on each of the animations.

    Anyone having an idea of how I can fix this?
    Thanks
     
  24. lbjorseth

    lbjorseth

    Joined:
    Oct 23, 2008
    Posts:
    26
    Sorry, my fault :-( I had a corrupt frame in there. (A bit tired) :)
     
  25. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    Ok so I recently got the sprite manager 2 but I get a error when i import the demo. It says

    assets/sm2, demo/scripting demo/sm2_demo_js.js(2,30): BCE0018: the name 'packedsprite' does not denote a valid type ('not found').

    assets/sm2, demo/scripting demo/sm2_demo_js.js(4,27): BCE0018: the name 'packedsprite' does not denote a valid type ('not found').

    assets/sm2, demo/scripting demo/sm2_demo_js.js(1,27): BCE0018: the name 'packedsprite' does not denote a valid type ('not found').

    assets/sm2, demo/scripting demo/sm2_demo_js.js(45,77): BCE0018: the name 'SpriteBase' does not denote a valid type ('not found').

    When i import the package is it suppose to run and compile everything automatically or am i suppose to fix this error on my own? I imported by reading Brady's instruction on one of the forum I opened a new project and imported just only the sample demo package it didnt work so I imported the entire sprite manager 2 package and imported the sample project inside the project it still didnt work. I clicked assets -> import package -> custom -> sprite sample demo and I also tried to import the sprite manager 2 package first as well and then import the sample package that didnt work as well
     
  26. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @dkeem
    This problem only happens for Asset Store users and is because the Unity Asset Store reviewers restructured the folder structure of both SM2 and EZ GUI after I submitted it and didn't say anything to me about it first. They restructured them by moving the "Editor" and "Plugins" folders into "EZ GUI" and "SpriteManager 2" subfolders for each product. The problem is, this won't work in Unity. The Plugins folder has to be off the root in order to compile properly so that C# classes are accessible to JS scripts. So you just need to drag the "Plugins" and "Editor" folders into the root of the project folder. I've spoken to the Asset Store team about this and they assure me that my next submission will not be altered in this way, so this shouldn't be an issue after the next release. But for some reason they can't fix the existing package on the Asset Store.
     
  27. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    Ok got it thanks a bunch!
     
  28. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    ok now when I click run scene it says nullreferenceexception: object reference not set to an instance of an object. The way I imported the sprite sample was assets->import package-> custom package-> imported the sample sprite package then I dragged the editor and plugins in to the root folder like you said it got rid of the other problem I was having. Now I got the object reference error. Am I suppose to import the main sprite manager 2 package first to my project then import the sample project within the same project? Cause I tried that too and I still got a error.
     
  29. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Hmmm, that should definitely not be happening. You might try once more from a blank project, then import the core package, then import the sample package. If you still get an error, please paste the full error message here, including line numbers, etc, so I can get an idea of what it might be. Thanks!
     
  30. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    NullReferenceException: Object reference not set to an instance of an object
    SM2_Demo_CS.ChangePose () (at Assets/SM2, Demo/Scripting demo/SM2_Demo_CS.cs:71).

    Then it also says The referenced script on this Behaviour is missing!

    thats what i get when i try to run the demo
     
  31. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    ok so I got another quick question for ya brady thanks for the help also really appreciate how your helping everyone out :). So I was just learning the super sprite manager 2 on my own with out the demo got pretty far. But having difficulty with the super sprite a bit. Ok so this is how I am coding it right now. I want my character to play the walkright animation when user press D or right arrow key. But when I press D or right arrow key it sort of plays both the idle animation and walkright animation. Not sure how to delete or remove sprite when i press the right key or D. Is there a way to delete the sprite cause it says i cant use reverttostatic with supersprite class sayin its not a member of that class. This is my code:

    if ((Input.GetKey ("right")) || (Input.GetKey("d"))){ //|| (Input.GetAxis("Horizontal"))){
    //supsprite.RemoveSprite("idle");
    supsprite.DoAnim("walkright");
    }
    else {
    supsprite.DoAnim("idle");
    }

    Like if i press d or right key i just want the walkright animation to show so i tried to remove it but I dont know the command for it because most of it says its not a member of the supersprite class. Thanks a bunch!!
     
  32. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Regarding the null ref, that sounds like somehow you got the older SM2 demo package that had a broken prefab due to the asset GUID getting changed somehow. Try re-downloading the package, and if that doesn't work, e-mail me directly and I'll see to it you get the latest demo package.

    Regarding your second question, if the SuperSprite is setup correctly, it should automatically hide the previous sprite when you tell it to play an animation that is on a different sprite. Also, on the animation itself, in the inspector, try checking "Deactivate Non Playing".
     
  33. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    Ok thanks everything is working now!! oh yea one more quick question i am trying to make a Ai that follows the character but the enemy ai is also a sprite so he can only be shown on one side like a plane. if he spins he becomes invisible. So I was wondering how would I make a Ai for 2d sprite game that has a 2d rpg type of setting where the character can move in 3d dimension up down left right. But I want the enemy Ai to chase the player by chasing them looking at one direction only like if im on the left side it will play the leftwalk animation for the zombie and chase the player moving up and down while moving left. and then if i go right side of the screen the object will make a quick rotate right and play the rightwalk animation scene for the sprite and chase me coming towards the right side while moving up or down. Not sure if I asked my question properly if it is a bit confusing i can make a video. But right now my ai rotates and then move forward at the player and he is not coming out at some of the angle. so i just wanted to show either the front side or the back side like front side being walkingleft animation and right side being walkingright.
     
  34. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I think I know what you're referring to, and that's because the shader you are using has backface culling enabled. If you use one of the shaders included with SM2, those all have backface culling disabled, so turning the sprite the other way will work just fine.
     
  35. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    Ok so i just found the two shaders that were included in with the sprite manager. sprite cutout and transparent vertex colored.shader. But i dont know how to put this in sorry im a newb. Like when i click on zombie character on the inspector i see shader and i can select from the list of shaders but i cant find the shader that came with the sm2 package. How can i put these 2 shaders into the list?
     
  36. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    NVM I FOUND IT!! IT WORKS!!! TY SOOO MUCH!! WEEEEE kudos to youuu BRADY!!
     
  37. dkeem

    dkeem

    Joined:
    Jun 23, 2011
    Posts:
    15
    Ok got 1 more question. I was wondering how can I play different animation based on where the Ai enemy zombie is located.

    For example if the enemy zombie is on the right side of my main character how can i get him to play the walk left animation so it can seem like hes chasing after him and then if he is on the left side of my main character i can use walk right animation sequence. Not sure how to approach this. After I did the shader it looks good when the zombie is coming from one side but doesn't look to good when my player goes to the opposite side.
     
  38. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Just call DoAnim() to start a different animation. So assuming your other animation is the 2nd animation on the sprite, you would call DoAnim(1) (since the animation indices are 0-based). Then just add whatever appropriate logic you need to decide when to run which animation.
     
  39. deadfire52

    deadfire52

    Joined:
    Jun 15, 2011
    Posts:
    101
    Hey Brady, question about sizing my sprites. When I created my sprites, I didn't pay attention to sizing between my animations, (I figured that I could resize/crop them later) So I had images that have gigantic spacing between my images. I used GIMP's autocrop feature which totally removed the white from each image but when I put that sequence into SM2, the image was extremely shaky from left to right. I tried all the anchor and pixel perfect settings.

    I used the original images (with the large white borders) and it is perfectly fine. So any recommendations on how I should crop down my images?

     
  40. kariwm

    kariwm

    Joined:
    Jun 10, 2011
    Posts:
    3
    Hi There!

    I was just wondering, with your shader 'Sprite Cutout' -- should I use this on Iphone/Ipad, or is the fact it's alpha-testing going to make performance slower?? (I have a hard time understanding the performance issues behind alpha/fill rate issues on iOS)

    Thanks!
     
  41. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @deadfire55
    Yes, for an animation of that sort, pre-trimmed images will be very difficult to make smooth (the best approach might be Middle_Center). So it is definitely recommended to use the original padded images, and then rely on image trimming to remove the excess. Keep the anchor set to the default of TEXTURE_OFFSET and it should move very smoothly and imposes no additional work on you.


    @kariwm
    Alpha tested shaders are definitely slower on iOS devices, but whether it makes sense in your particular situation is something you'll really have to decide after some testing. But unless there's some specific reason to use a cut-out shader (such as needing Z-testing), I'd stick with the regular blended shaders.
     
  42. Broccoli

    Broccoli

    Joined:
    Sep 2, 2010
    Posts:
    28
    Hey I have some question about create an animation clip at runtime,

    I use SM 2 1.83 and I see some of my problem post in page 50-51

    I do as you suggest and this is my code

    Code (csharp):
    1.  
    2. Sprite sr = (Sprite)spriteMan.CreateSprite(prefab);
    3. UVAnimation_Multi anim = sr.GetAnim("idleTest");
    4. anim.clips = new UVAnimation_Auto[2];
    5. anim.clips[0] = new UVAnimation_Auto();
    6. anim.clips[1] = new UVAnimation_Auto();
    7. anim.SetAnim(0, anim.clips[0].BuildUVAnim(new Vector2(327,665),new Vector2(63,78),1,1,1));
    8. anim.SetAnim(1, anim.clips[1].BuildUVAnim(new Vector2(390,665),new Vector2(57,77),1,1,1));
    9. sr.PlayAnim("idleTest");       
    10.  
    and the sprite are show and play but It seem width and height (or may be Start offset too) are wrong

    I had test those value(like 327,665,63,78,1,1,1) with inspector setting It work fine but in-code It was wrong. My sprite become 10 time larger(almost not crop but it was a "multiple" of my full texture plane) So I think it maybe because of the value of the width and height?

    Does this have any thing to do with those PixelSpaceToUVSpace and PixelCoordToUVCoord ?


    Another problem is that when I create sprite manager at runtime
    like

    Code (csharp):
    1.  
    2. spriteMan               = new GameObject("_SpriteManager").AddComponent<SpriteManager>();
    3. Renderer matSpriteMan   = spriteMan.GetComponent<Renderer>();
    4. matSpriteMan.material   = (Material)getBaseResource("Materials/PlayerAtlas");
    5.  
    and call

    Code (csharp):
    1.  
    2. Debug.Log(spriteMan.PixelSpaceToUVSpace(new Vector2(63,78)) + " : " + spriteMan.PixelCoordToUVCoord(new Vector2(327,665)) );
    3.  
    It will always result in (0,0) and (0,0) but with pre create sprite manager in the scene it will return the correct one.



    - - - - - - EDIT - - - - - -

    I realize that the problem really came from spriteMan.PixelSpaceToUVSpace that created in runtime by my script as above code when I change the spritemanager to pre create in scene view and change the code in BuildUVAnim to UV Vector that output from my spritemanager component everything seem work out fine.

    So, the problem is why my spritemanager(PixelSpaceToUVSpace and PixelCoordToUVCoord) in runtime cannot do this work?

    - - - - - - EDIT 2 - - - - - -

    OK I can solve this by change the Awake() in spritemanager to public and call it once I added the material to the manager. but if you have a better solution for me please let me know : )

    Thank you,
     
    Last edited: Jul 18, 2011
  43. Klausini

    Klausini

    Joined:
    Feb 19, 2010
    Posts:
    37
    Hi, I am having trouble with the animation end delegate:

    Code (csharp):
    1.  
    2. myGO.GetComponent(typeof(PackedSprite)).SetAnimCompleteDelegate(ResortField);
    3. myGO.GetComponent(typeof(PackedSprite)).PlayAnim(0);
    4.  
    5.  
    6. function ResortField (sprt : SpriteBase)
    7. ...
    8.  
    PlayAnim works, but the set delegate gets commented as

    "MissingMethodException: Method not found: 'PackedSprite.SetAnimCompleteDelegate'."

    On the internet I found for the frame delegate I need to uncomment SPRITE_FRAME_DELEGATE in the AutoSpriteBase, but I could not find anything for the AnimComplete. Could you please help?
     
  44. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    That's a weird one. I'm not sure why the one would work but the other would give an error. If you look in SpriteBase.cs, you should definitely find a definition for SetAnimCompleteDelegate(). It's not conditionally compiled like the per-frame delegate, so there's no reason it shouldn't be there.

    Are you able to run the demo project? That uses the same feature.
     
  45. Klausini

    Klausini

    Joined:
    Feb 19, 2010
    Posts:
    37
    Hm, I cannot get the demo to run. I get "The name 'PackedSprite' does not denote a valid type ('not found')." error. I know this means I need to copy some scripts to some place like standard assets or plugins. I played around with it, but were not able to find a solution. I.e. when I move the Sprite Manager 2 folger into a a "Plugins" folder the above error is gone, but alle sprites remain without texture and I get this:
    NullReferenceException: Object reference not set to an instance of an object
    AutoSpriteBase.PlayAnimInReverse (System.String name) (at Assets/Plugins/SpriteManager 2/Plugins/Sprite Scripts/Support/AutoSpriteBase.cs:764)
    SM2_Demo_CS.Start () (at Assets/SM2, Demo/Scripting demo/SM2_Demo_CS.cs:30)

    For the project I am working on I moved all content from the "sprite scripts" folder to a "Standard Assets" folder. By this I was able to get the PlayAnim() to work. I guess I really messed things up. Strangly though, I cannot find much on the topic on the internet (and nothing in the manual). What is the obvious missing part?
    Thanks!
     
  46. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    That sounds very strange. I did, however, suddenly run into a "MissingMethodException" myself today, only on an editor script. I just right-clicked the script in question and chose "Reimport", and Unity recompiled it and it worked. So it seems somehow Unity is sometimes either corrupting the compiled version of some random script (since this was in no way related to the script you're having trouble with), or it's not compiling it correctly the first time.

    Very strange indeed.

    Regarding the plugins folder issue, actually, you want the "Plugins" folder that is initially under "SpriteManager 2" to be off of the root of your project. So the "Sprite Scripts" folder should be at: Assets/Plugins/Sprite Scripts. The intermediary "SpriteManager 2" folder was added by the Unity Asset Store reviewers, and it has the effect of messing up JS support since Unity requires "Plugins" to be in the root of the project to behave properly.
     
  47. deadfire52

    deadfire52

    Joined:
    Jun 15, 2011
    Posts:
    101
    Thanks for the answer Brady, I just redid all my sprites. It didn't take nearly as long as I thought it would.

    Now I'm moving on to the coding part. This might seem a little basic to you but I can't figure out, just trying to make my character move and idle. This is attached to my Left button GUITexture and my sprite is a super sprite

    Edit: Got it:

     
    Last edited: Jul 22, 2011
  48. deadfire52

    deadfire52

    Joined:
    Jun 15, 2011
    Posts:
    101
    This problem is driving me crazy, I have no idea what could be wrong. The problem is that if I call SS2.PlayAnim("Idle"); from the Start function, the animation is about 30% smaller. Any other animations called turn bigger if they are called in the OnMouseDown but when that animation is done and the idle animation is called from OnMouseUp, it goes back to being small.

    I copied the object (SS) and didn't call the function from the Start function but let the Idle come from the OnMouseUp and everything works fine. But obviously there is no animation until the OnMouseDown

    Here's my code attached to my left GUITexture (I know the actions don't match but it's just as an example):
    Here's an image

     
  49. pianpiansq

    pianpiansq

    Joined:
    May 28, 2011
    Posts:
    3
    I have a trouble about “PlayAnim” and “AnimCompleteDelegate”.
    I use “SuperSprite” to control my sprites. I set two animations: anim1 and anim2. And in anim2, I add only one frame (one texture) to the animation in the timeline editor. Then I tell that play anim2 after finish play anim1 using “AnimCompleteDelegate”. When I run the program, Unity crashed after anim1 finished. However, When I add two or more textures to the animation of anim2. The program just works.

    Code (csharp):
    1.  
    2. ...
    3. mySuperSprite.SetAnimCompleteDelegate(OnAnimationComplete);
    4. ...
    5.  
    6. ...
    7. mySuperSprite.PlayAnim(anim1);
    8. ...
    9.  
    10. void OnAnimationComplete (SuperSprite sprt) {
    11.     if(......) {
    12.         sprt.PlayAnim(anim2);
    13.     }
    14. }
    15.  
    16.  
     
  50. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @deadfire55
    Is this using the latest beta? If not, you might try it as I think there may have been some order-of-initialization issues that solved this.

    @pianpiansq
    I think this is an issue addressed in the latest beta. You can find it at the updates page here: www.anbsot.com/updates. If that doesn't help, let me know and I'll see if there's more to it.