Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by heaversm · Jun 20, 2012 at 02:32 PM · textureanimated-texture

Animated texture on quad

Hi - I'm trying to get an animated texture on a quad imported from blender, but the animation doesn't seem to be working. In the main window, my texture is just grey, but in the preview window for the texture itself it shows the texture animating. I was attempting to follow this tutorial here:

http://www.unifycommunity.com/wiki/index.php?title=Animating_Tiled_texture

I've attached a screenshot of my setup if that helps.alt text

Screen Shot 2012-06-19 at 5.44.11 PM.png (96.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Fattie · Jun 20, 2012 at 02:35 PM

Consider ... if I understand what you are trying to do,

get 2DToolkit and, I believe, your job is instantly finished.

You can go home to dinner!!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image heaversm · Jun 20, 2012 at 04:05 PM 0
Share

I was hoping to do this without a paid plugin but thank you!

avatar image TheRibboninju · Jul 26, 2012 at 09:46 PM 0
Share

Are there options for devs who want to do it all for free? Surely there has to be a decently fast way to do animation using a script right?

I might come back with an alternative answer later, if I find one. I'll be doing some research.

Any idea on where to start guys?

avatar image
1

Answer by heaversm · Jul 26, 2012 at 09:52 PM

You can install this script which will add a menu command to create a quad. Save it as CreatePlane.cs and put it in an Assets > Editor folder.

 using UnityEngine;
 using UnityEditor;
 using System.Collections;
 
 
 public class CreatePlane : ScriptableWizard
 {
     
     public enum Orientation
     {
         Horizontal,
         Vertical
     }
 
     public enum AnchorPoint
     {
         TopLeft,
         TopHalf,
         TopRight,
         RightHalf,
         BottomRight,
         BottomHalf,
         BottomLeft,
         LeftHalf,
         Center
     }
     
     public int widthSegments = 1;
     public int lengthSegments = 1;
     public float width = 1.0f;
     public float length = 1.0f;
     public Orientation orientation = Orientation.Horizontal;
     public AnchorPoint anchor = AnchorPoint.Center;
     public bool addCollider = false;
     public bool createAtOrigin = true;
     public string optionalName;
 
     static Camera cam;
     static Camera lastUsedCam;
 
     
     [MenuItem("GameObject/Create Other/Custom Plane...")]
     static void CreateWizard()
     {
         cam = Camera.current;
         // Hack because camera.current doesn't return editor camera if scene view doesn't have focus
         if (!cam)
             cam = lastUsedCam;
         else
             lastUsedCam = cam;
         ScriptableWizard.DisplayWizard("Create Plane",typeof(CreatePlane));
     }
     
     
     void OnWizardUpdate()
     {
         widthSegments = Mathf.Clamp(widthSegments, 1, 254);
         lengthSegments = Mathf.Clamp(lengthSegments, 1, 254);
     }
     
     
     void OnWizardCreate()
     {
         GameObject plane = new GameObject();
         
         if (!string.IsNullOrEmpty(optionalName))
             plane.name = optionalName;
         else
             plane.name = "Plane";
         
         if (!createAtOrigin && cam)
             plane.transform.position = cam.transform.position + cam.transform.forward*5.0f;
         else
             plane.transform.position = Vector3.zero;
         
         Vector2 anchorOffset;
         string anchorId;
         switch (anchor)
         {
         case AnchorPoint.TopLeft:
             anchorOffset = new Vector2(-width/2.0f,length/2.0f);
             anchorId = "TL";
             break;
         case AnchorPoint.TopHalf:
             anchorOffset = new Vector2(0.0f,length/2.0f);
             anchorId = "TH";
             break;
         case AnchorPoint.TopRight:
             anchorOffset = new Vector2(width/2.0f,length/2.0f);
             anchorId = "TR";
             break;
         case AnchorPoint.RightHalf:
             anchorOffset = new Vector2(width/2.0f,0.0f);
             anchorId = "RH";
             break;
         case AnchorPoint.BottomRight:
             anchorOffset = new Vector2(width/2.0f,-length/2.0f);
             anchorId = "BR";
             break;
         case AnchorPoint.BottomHalf:
             anchorOffset = new Vector2(0.0f,-length/2.0f);
             anchorId = "BH";
             break;
         case AnchorPoint.BottomLeft:
             anchorOffset = new Vector2(-width/2.0f,-length/2.0f);
             anchorId = "BL";
             break;          
         case AnchorPoint.LeftHalf:
             anchorOffset = new Vector2(-width/2.0f,0.0f);
             anchorId = "LH";
             break;          
         case AnchorPoint.Center:
         default:
             anchorOffset = Vector2.zero;
             anchorId = "C";
             break;
         }
                 
         MeshFilter meshFilter = (MeshFilter)plane.AddComponent(typeof(MeshFilter));
         plane.AddComponent(typeof(MeshRenderer));
 
         string planeAssetName = plane.name + widthSegments + "x" + lengthSegments + "W" + width + "L" + length + (orientation == Orientation.Horizontal? "H" : "V") + anchorId + ".asset";
         Mesh m = (Mesh)AssetDatabase.LoadAssetAtPath("Assets/Meshes/" + planeAssetName,typeof(Mesh));
  
         if (m == null)
         {
             m = new Mesh();
             m.name = plane.name;
         
             int hCount2 = widthSegments+1;
             int vCount2 = lengthSegments+1;
             int numTriangles = widthSegments * lengthSegments * 6;
             int numVertices = hCount2 * vCount2;
         
             Vector3[] vertices = new Vector3[numVertices];
             Vector2[] uvs = new Vector2[numVertices];
             int[] triangles = new int[numTriangles];
         
             int index = 0;
             float uvFactorX = 1.0f/widthSegments;
             float uvFactorY = 1.0f/lengthSegments;
             float scaleX = width/widthSegments;
             float scaleY = length/lengthSegments;
             for (float y = 0.0f; y < vCount2; y++)
             {
                 for (float x = 0.0f; x < hCount2; x++)
                 {
                     if (orientation == Orientation.Horizontal)
                     {
                         vertices[index] = new Vector3(x*scaleX - width/2f - anchorOffset.x, 0.0f, y*scaleY - length/2f - anchorOffset.y);
                     }
                     else
                     {
                         vertices[index] = new Vector3(x*scaleX - width/2f - anchorOffset.x, y*scaleY - length/2f - anchorOffset.y, 0.0f);
                     }
                     uvs[index++] = new Vector2(x*uvFactorX, y*uvFactorY);
                 }
             }
             
             index = 0;
             for (int y = 0; y < lengthSegments; y++)
             {
                 for (int x = 0; x < widthSegments; x++)
                 {
                     triangles[index]   = (y     * hCount2) + x;
                     triangles[index+1] = ((y+1) * hCount2) + x;
                     triangles[index+2] = (y     * hCount2) + x + 1;
         
                     triangles[index+3] = ((y+1) * hCount2) + x;
                     triangles[index+4] = ((y+1) * hCount2) + x + 1;
                     triangles[index+5] = (y     * hCount2) + x + 1;
                     index += 6;
                 }
             }
         
             m.vertices = vertices;
             m.uv = uvs;
             m.triangles = triangles;
             m.RecalculateNormals();
             
             AssetDatabase.CreateAsset(m, "Assets/Editor/" + planeAssetName);
             AssetDatabase.SaveAssets();
         }
         
         meshFilter.sharedMesh = m;
         m.RecalculateBounds();
         
         if (addCollider)
             plane.AddComponent(typeof(BoxCollider));
         
         Selection.activeObject = plane;
     }
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Jul 27, 2012 at 04:43 PM 0
Share

This script looks very interesting, I shall be playing with this when I have a spare moment. I'm learning procedural mesh stuff at the moment so stuff like this is great. Thanks for posting (Im $$anonymous$$ $$anonymous$$ay, the other poster!). Here's what I did today : http://www.alucardj.net16.net/unityquestions/IrisHex$$anonymous$$esh.png : info is here : http://answers.unity3d.com/questions/290695/calculate-spline-points-on-complex-geometry-mesh.html

Have you checked out the Unity examples : http://unity3d.com/support/resources/example-projects/procedural-examples

Thanks again for the script, all the best =]

avatar image Fattie · Jul 27, 2012 at 05:45 PM 0
Share

if yer learning about making mech on the fly, consider this

http://answers.unity3d.com/questions/193695/in-unity-is-there-a-fast-way-to-find-nearby-triang.html

it has a huge amount of info, including many downloadable builds, etc!

avatar image AlucardJay · Jul 27, 2012 at 07:00 PM 0
Share

Thanks, interesting read. $$anonymous$$y next exercise is to learn mesh deformation. With the verts configured as you describe (unpredictable and often not shared) my thought for starting was to get the hit-point , then cycle through all the verts checking if within a certain magnitude of the hit-point. I'll grab your spheres =] and check out Aldo's script. A friend of $$anonymous$$e showed me his first go at verlet cloth the other day, now that's some real $$anonymous$$d-blowing stuff !

avatar image
0

Answer by AlucardJay · Jul 26, 2012 at 10:50 PM

This is an example for swapping the UV's of the mesh vertices.

 #pragma strict

 public var scrollSpeed : float = 0.1;

 function Update() 
 {
     SwapUVs();
 }

 function SwapUVs()
 {
     var mesh : Mesh = this.transform.GetComponent(MeshFilter).mesh;
     var uvSwap : Vector2[] = mesh.uv;

     for (var b:int = 0; b < uvSwap.length; b ++)
     {
        uvSwap[b] += Vector2( scrollSpeed * Time.deltaTime, 0 );
     }

     mesh.uv = uvSwap;
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trying to view paper object on button press GUI Texture 3 Answers

how to make high quality textures with low size of downlaod 1 Answer

A node in a childnode? 1 Answer

Load a transparent texture by script 1 Answer

null texture passed to GUI.DrawTexture 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges