Unity Community


Page 14 of 89 FirstFirst ... 412131415162464 ... LastLast
Results 261 to 280 of 1772

  1. Location
    Vancouver, BC, Canada
    Posts
    107
    I'm trying to get my sprites to fade in and out using iTween, but it's not working as expected. If my sprite component's alpha value is equal to 0, the sprite won't appear at all (as expected). However, if the alpha value is anything above 0, it will display at full opacity; there's no gradual fade in or fade out effect.

    Here's my code:

    Code:  
    1. void FadeIn()
    2.     {
    3.         iTween.ValueTo( gameObject, iTween.Hash(
    4.                                                 "from", 0.0f,
    5.                                                 "to", 255.0f,
    6.                                                 "time", time,
    7.                                                 "delay", delay,
    8.                                                 "easetype", iTween.EaseType.easeInOutSine,
    9.                                                 "onupdate", "SetAlpha",
    10.                                                 "oncomplete", "FadeOut" ));
    11.     }
    12.    
    13.     void FadeOut()
    14.     {
    15.         iTween.ValueTo( gameObject, iTween.Hash(
    16.                                                 "from", 255.0f,
    17.                                                 "to", 0.0f,
    18.                                                 "time", time,
    19.                                                 "delay", delay,
    20.                                                 "easetype", iTween.EaseType.easeInOutSine,
    21.                                                 "onupdate", "SetAlpha",
    22.                                                 "oncomplete", "FadeIn" ));
    23.     }
    24.                                                
    25.     void SetAlpha( float newAlpha )
    26.     {
    27.         spriteComponent.color = new Color(spriteComponent.color.r,
    28.                                           spriteComponent.color.g,
    29.                                           spriteComponent.color.b,
    30.                                           newAlpha);
    31.     }

    SetAlpha() is receiving the correct values (newAlpha is interpolating as expected). But I'm not seeing the fade in/out effect.

    Any idea what I'm doing wrong? Thanks for the help


  2. Posts
    704
    Quote Originally Posted by bdjones View Post
    I'm trying to get my sprites to fade in and out using iTween, but it's not working as expected.
    Hi bdjones,

    You need to turn the Use Animation Helper ON (in the sprite Inspector) to make the properties in sprite can work with iTween and Unity's Animation


  3. Posts
    704
    Quote Originally Posted by llavigne View Post
    I am sure it is not trivial but so so so powerful.
    If the complexity comes from the UI (how to display the material), the simplest way is no UI : the code looks up materials, find the textures, looks them up in the atlases and then does the same replacement + UV coordinate work as your script but on generic shaders.

    In fact I think all your code can be generalized and the mesh generation separated. For instance today I wanted to do a manga mouth and I UV mapped the head to hold that texture, same for the eyes. Then I realized what a pain it will be to animate. If your scripts could be used for that purpose, imagine the power (pawa).
    Hi llavigne,

    It is a great idea. However, based on our task and milestone, I'm really don't have time to look deep into this and see if it is possible to use our own material assignment instead of Unity's. So I put this in my backlog list and once I have time, I will seek on it.


  4. Location
    Japan/Tokyo
    Posts
    323
    Hi jwu
    Thanks for replying

    > "08 - demo_sprite_animation_helper.unity"
    yes! exactly. I forgot the sample had blinking.


    Hi, nantas

    >Do you mean you want to have 3 different sets of running animation and each has a different outfit color? Then you want mix them up in a >single running animation when your hero is charging up or has power up?

    Yes. I wanna mix 3 or more animation.
    I will create charging animation.

    >I think you can try the mixing with Play(string_name, int_index) and GetCurFrameInfo ().
    ok I'll try


  5. Location
    Curitiba - PR / Brazil
    Posts
    275
    Quote Originally Posted by nantas View Post
    I've done a tiny tutorial yesterday. About how to do a skill cooldown effect with animated masking technique, check the video here:


    GREAT! I din't see that until now!

    The major problem is create one camera for each necessary item with cooldown effect, but THANKS a lot!


  6. Location
    Curitiba - PR / Brazil
    Posts
    275
    There is some way I can rebuild all my prefabs? without one by one and click in rebuild? I try that but don't work:

    Code:  
    1.     [MenuItem("MonsterJuice/Utils/Rebuild Ex2D Prefabs") ]
    2.     static void Execute()
    3.     {
    4.         foreach ( Object o in Selection.GetFiltered(typeof (Object), SelectionMode.DeepAssets))
    5.         {
    6.             if(o is GameObject)
    7.             {
    8.                 GameObject go = o as GameObject;
    9.                
    10.                 RebuildAllChilds(go);
    11.             }
    12.         }
    13.     }
    14.    
    15.     static void RebuildAllChilds(GameObject pGO)
    16.     {
    17.        
    18.         if(pGO.GetComponent<exSprite>())
    19.         {
    20.             //pGO.GetComponent<exSpriteUtility>.
    21.             pGO.GetComponent<exSprite>().Rebuild();
    22.             Debug.Log("Rebuild "+pGO.name);
    23.         }
    24.         if(pGO.transform.childCount > 0)
    25.         {
    26.             for(int i = 0; i < pGO.transform.childCount; i++)
    27.             {
    28.                 RebuildAllChilds(pGO.transform.GetChild(i).gameObject);
    29.             }
    30.         }
    31.        
    32.     }


  7. Posts
    125
    Hey - just to report a bug ( I think).

    When I instantiate an object that has a sprite object and uses layer2D, it's Z value was often slightly inaccurate compared to what I set it to (when I turned off layer2D, all objects instantiated at exactly the position I set them to). The problem got worse with successive instantiations - for example the undesired z offset of the 5th instantiated object was larger than the 1st instantiated object. Are you aware of this bug? Thanks, great job!

    Note that my layer and bias were all equal.
    Last edited by bishylewis; 09-27-2011 at 12:23 PM. Reason: addition


  8. Posts
    704
    Quote Originally Posted by badawe View Post
    There is some way I can rebuild all my prefabs? without one by one and click in rebuild? I try that but don't work:

    Code:  
    1.     [MenuItem("MonsterJuice/Utils/Rebuild Ex2D Prefabs") ]
    2.     static void Execute()
    3.     {
    4.         foreach ( Object o in Selection.GetFiltered(typeof (Object), SelectionMode.DeepAssets))
    5.         {
    6.             if(o is GameObject)
    7.             {
    8.                 GameObject go = o as GameObject;
    9.                
    10.                 RebuildAllChilds(go);
    11.             }
    12.         }
    13.     }
    14.    
    15.     static void RebuildAllChilds(GameObject pGO)
    16.     {
    17.        
    18.         if(pGO.GetComponent<exSprite>())
    19.         {
    20.             //pGO.GetComponent<exSpriteUtility>.
    21.             pGO.GetComponent<exSprite>().Rebuild();
    22.             Debug.Log("Rebuild "+pGO.name);
    23.         }
    24.         if(pGO.transform.childCount > 0)
    25.         {
    26.             for(int i = 0; i < pGO.transform.childCount; i++)
    27.             {
    28.                 RebuildAllChilds(pGO.transform.GetChild(i).gameObject);
    29.             }
    30.         }
    31.        
    32.     }
    Hello badawe,

    I read your code, it looks like it works for your selecting prefab. The rebuild button currently will not accept changing prefab I doubt. I thinking about change this.

    My purpose to disable prefab rebuilding is because it didn't generate mesh. But looks like this also disable atlas changes and things like that. I will change the code so it only skip rebuild mesh when it is a prefab.


  9. Posts
    704
    Quote Originally Posted by bishylewis View Post
    Hey - just to report a bug ( I think).

    When I instantiate an object that has a sprite object and uses layer2D, it's Z value was often slightly inaccurate compared to what I set it to (when I turned off layer2D, all objects instantiated at exactly the position I set them to). The problem got worse with successive instantiations - for example the undesired z offset of the 5th instantiated object was larger than the 1st instantiated object. Are you aware of this bug? Thanks, great job!

    Note that my layer and bias were all equal.
    Hi bishylewis,

    Is this happend in a running Game or the instantiate you mean is when you editing scene, you drag drop a prefab?

    If this is in a running Game. When you instantiate a sprite (with layer), you need to do the following code:

    Code:  
    1. exSprite sp = prefab.GetComponent<exSprite>();
    2. sp.layer2d.RecursivelyUpdateTransformDepth ();

    Because the instantiate you do will pass a position which will make the game object not set in right depth of layer.

    If you are drag drop in a editor. Please do Alt + Command/Ctrl + l ( or Menu -> Edit -> ex2D -> Update Scene Layers ). Which will adjust all sprite to the right depth position.
    Last edited by jwu; 09-27-2011 at 10:10 PM.


  10. Posts
    704
    ex2D v1.2.0 is now available in the Asset Store!

    check the fixes, changes in the first Page
    Last edited by jwu; 09-27-2011 at 08:35 PM.


  11. Posts
    23
    Wow realease version!! Great!!
    Thank you~


  12. Location
    Curitiba - PR / Brazil
    Posts
    275
    This Unity3.4.1 keep crashing all the time with me, i cant event open the Unity.

    Keep give me some crash, unexpected errors ans stuffs like that, someone know what is going on?



    The only way i can open my project is using this:


    But i can't open my old project!
    Last edited by badawe; 09-28-2011 at 07:06 AM.


  13. Location
    Middlesbrough, United Kingdom
    Posts
    23
    I use Windows 7 and not a mac, but recently I had loads of problems with Unity crashing on start up, and when Unity auto compiles my scripts.

    I've since uninstalled my antivirus program and I cant remember the last time Unity crashed.

    Are you sure this is an ex2D related crash?


  14. Posts
    704
    Quote Originally Posted by badawe View Post
    This Unity3.4.1 keep crashing all the time with me, i cant event open the Unity.

    Keep give me some crash, unexpected errors ans stuffs like that, someone know what is going on?



    The only way i can open my project is using this:


    But i can't open my old project!
    Hi badawe,

    Can you send me a package that crashed in Unity3.4.1 or something? We test v1.2.0 in both u3d 3.4.0 and u3d 3.4.1 but didn't meet crash problem. Is there a way to reproduce it? For example, if you create a new project and ex2D in U3D 3.4.1, will it still get crashing?


  15. Location
    Middlesbrough, United Kingdom
    Posts
    23
    I'm currently using ex2D without using any animation. I'm using a lot of separate images for my gameobjects. What's the best way to optimise this?

    I read above that I should group the same sprites on the same Z axis to reduce draw calls, but I was also wondering would it be beneficial to make a bigger sprite sheet and use sections of that for my sprites? Does ex2D do this automatically already?


  16. Location
    Berlin
    Posts
    122
    Quote Originally Posted by Biggz View Post
    I'm currently using ex2D without using any animation. I'm using a lot of separate images for my gameobjects. What's the best way to optimise this?

    I read above that I should group the same sprites on the same Z axis to reduce draw calls, but I was also wondering would it be beneficial to make a bigger sprite sheet and use sections of that for my sprites? Does ex2D do this automatically already?
    There's two ways to arrange your non-animated sprites:
    1. You can store all images in a single SpriteAnimClip asset, and use exSpriteAnimation.SetFrame to switch the images.
    2. You can create a SpriteAnimClip asset for each individual image, and switch them by calling exSpriteAnimation.Play().

    Of course the 1st way saves you a lot of work but the 2nd way is better organized (you call the animation by asset name instead of magic number), and easier to expand. ( in case in the future you want to add animated frames for each image) So it all depends on what you plan to do and how many different images you plan to have.

    Regarding your second question, yes you can create sprite sheet to contain as many textures as you want (as long as they fit into the size). If all your sprites in the scene shares the same texture there will be only one draw call needed. (as long as there's no non-uniform scale for any of your sprite's transform component.)


  17. Posts
    3
    is ex2D set up for me to create sprites in the script, and then set up all details (which texture/position/size/layer) to use?


  18. Posts
    704
    I read above that I should group the same sprites on the same Z axis to reduce draw calls, but I was also wondering would it be beneficial to make a bigger sprite sheet and use sections of that for my sprites? Does ex2D do this automatically already?
    Hi Biggz,

    Just like Nantas explain to you. And I think what you expect more is a dynamic atlas in the runtime by section isn't it? Doing this is extremely slow in Unity and in Mobile device, I can't find a way to create dynamic buffer in GPU for texture writing in Unity. Plus a big texture sending each frame can still cause performance drop down I doubt.

    Quote Originally Posted by fued View Post
    is ex2D set up for me to create sprites in the script, and then set up all details (which texture/position/size/layer) to use?
    Hi fued,

    Can you explain this with more details? Basically when you create a sprite, you are free to assign texture, scale, layers. And if you make it as a prefab, you can save those value to asset.


  19. Posts
    3
    can i create a sprite object in the editor, pass that through to a script object, then using that script object/sprite object, close it and create multiple sprites in different locations on the screen?

    e.g. i have a button image, i create it as a sprite attached to a gameobject, i then pass that gameobject to the script, and need to populate the screen with 10 different buttons in different locations.


  20. Posts
    704
    Quote Originally Posted by fued View Post
    can i create a sprite object in the editor, pass that through to a script object, then using that script object/sprite object, close it and create multiple sprites in different locations on the screen?

    e.g. i have a button image, i create it as a sprite attached to a gameobject, i then pass that gameobject to the script, and need to populate the screen with 10 different buttons in different locations.
    Hi fued,

    I think what you need is a prefab. So you first create this sprite and gameobject, drag it to the Project Window to create a prefab. Then in the script you reference this prefab then write the code:

    Code:  
    1. public exSprite spritePrefab;
    2.  
    3. void Awake () {
    4.     for ( int i = 0; i < 10; ++i ) {
    5.         GameObject.Instantiate ( spritePrefab, Random.UnitCircle * 100.0f, Quaternion.identity );
    6.     }
    7. }

Page 14 of 89 FirstFirst ... 412131415162464 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •