Search Unity

Anyway to get animated textures in Unity Indie?

Discussion in 'Editor & General Support' started by techmage, Oct 31, 2009.

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    So I saw that unity indie does not support video playback at all.

    Does this mean it won't be possible to make an animated texture on something?

    Or display some sort of cutscene fmv?

    Would there be anyway to put this functionality back in yourself?
     
  2. melmonkey

    melmonkey

    Joined:
    Mar 31, 2009
    Posts:
    373
  3. sybixsus2

    sybixsus2

    Joined:
    Feb 16, 2009
    Posts:
    943
    There wouldn't be any way to put it back in yourself, because (at the very least) you would need a C++ plugin and those are Pro only too. (They've thought these things through.)

    If you really can't (or don't want to) buy Pro, I would suggest that your best bet for cutscenes is to do them in-engine. This is becoming more and more popular in games these days. But you should be aware that it is by no means a trivial task.
     
  4. P_Diesel

    P_Diesel

    Joined:
    Dec 6, 2010
    Posts:
    2
    Dude you're a life saver, thanks man :)
     
  5. Dhruv

    Dhruv

    Joined:
    Sep 18, 2009
    Posts:
    1
  6. sendel76

    sendel76

    Joined:
    Mar 17, 2010
    Posts:
    36
    use SpriteManager2 (Unity Plugin) or use Atlas Texture Generators like Zwoptex.
     
  7. U7Games

    U7Games

    Joined:
    May 21, 2011
    Posts:
    943
    why don't just to use a "for" loop . changing texture to a plane or guiTexture fastly?

    Code (csharp):
    1.  
    2. var movieSpeed : float = 0.1;
    3. var movieFrame : Texture[];
    4.  
    5.  
    6. function PlayThisMovie(){
    7. for (var y = 1;  y < movieFrame.length ;  y++){
    8.         renderer.material.SetTexture("_MainTex", movieFrame[y]);
    9.         yield WaitForSeconds(movieSpeed);
    10.         }
    11. }
    12.  
     
  8. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    Hi guys,

    I tried the scripts above and they work, but I can't seem to stop it from looping... any ideas?
     
  9. meustrus

    meustrus

    Joined:
    Aug 5, 2011
    Posts:
    1
    First, add a new variable:

    Code (csharp):
    1.  
    2. private var startIndex = -1;
    3.  
    Then find this line:

    Code (csharp):
    1.  
    2. index = index % totalCells;
    3.  
    Replace it with this:

    Code (csharp):
    1.  
    2. if (startIndex == -1) startIndex = index;
    3. index -= startIndex;
    4. if (index > totalCells) return;
    5.  
    That will cause the script to:
    • Always start on the first frame of animation, and
    • Stop operating once the animation has played through once.
     
  10. swonderland

    swonderland

    Joined:
    Oct 31, 2011
    Posts:
    3
    guys I need some help with this script

    I've got an object with two materials assigned (and two texture) but assigning the script only makes one texture animate.. How can I get the second material to animate with this script as well?

    Thx in advance
     
  11. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Make a public variable of type int an change it like this.

    Code (csharp):
    1.  
    2.     renderer.materials[Material_id].SetTextureOffset ("_MainTex", offset);
    3.     renderer.materials[Material_id].SetTextureScale ("_MainTex", size);
    4.  
    Assign one scrip for every material you like to animate. an set the the material id (starting from 0) in the script.
     
  12. swonderland

    swonderland

    Joined:
    Oct 31, 2011
    Posts:
    3
    Hi Vitamalz aeeh malzbier,

    I don't quite follow: you can set an ID inside the script as your bit of code demonstrated, but where do you rename the material (to material_0 for example)? Is that something I do when importing?

    If I was to create a new material, set the correct texture to it, rename it to material_0 and another one called material_1 then I wouldn't know how to apply these materials to the object (more importantly to the correct UV set inside the object)

    also the animated_texture script only works on game objects and not materials......

    thanks a lot for your help - I feel like I'm almost there ^^
     
  13. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Sorry for this misunderstanding...

    The materials are assigned in a array in the render component.

    With renderer.materials[material_number] you can access the material in the array that in the index material_number.

    renderer.materials[0] for the first renderer.materials[1] for the second and so on.
     
  14. swonderland

    swonderland

    Joined:
    Oct 31, 2011
    Posts:
    3
    ah ! so every material applied to an object is automatically listed in an array, right? : D

    I'm gonna try it out first things when I'm home.

    Thanks a bunch!
     
  15. Yousician_unity_assets

    Yousician_unity_assets

    Joined:
    Dec 9, 2011
    Posts:
    11
    Thx meustrus! I was wondering how would you change the code that every animation would start from frame 1 and and loop it.
    I am using "extended" animation sheet. Now it looks like that animation starts from random frame.

    I am doing sprite character with this. I need this cause when I use "jump" it should start jumping frame 1 and loop it all the way and return back to idle loop.
     
  16. TheZoran

    TheZoran

    Joined:
    Mar 6, 2012
    Posts:
    17
    My Solution for animations:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TextureAnimationScript : MonoBehaviour
    5. {
    6.     public int TilesX;
    7.     public int TilesY;
    8.     public float AnimationCyclesPerSecond;
    9.  
    10.     void Start ()
    11.     {
    12.         renderer.material.mainTextureScale = new Vector2(1.0f / TilesX, 1.0f / TilesY);
    13.         StartCoroutine(ChangeOffSet());
    14.     }
    15.    
    16.     IEnumerator ChangeOffSet ()
    17.     {
    18.         for(int i = TilesY - 1; i > -1; i--)
    19.         {
    20.             for(int j = 0; j < TilesX; j++)
    21.             {
    22.                 renderer.material.mainTextureOffset = new Vector2(1.0f / TilesX * j, 1.0f / TilesY * i);
    23.                 yield return new WaitForSeconds(1.0f / (TilesX * TilesY * AnimationCyclesPerSecond));
    24.                 if(i == 0  j == TilesX - 1)
    25.                 {
    26.                     i = TilesY;
    27.                 }
    28.             }
    29.         }
    30.     }
    31. }