Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 LeeDoSeon · Sep 22, 2017 at 05:31 AM · ipad2uvanimation

Texture SetTextureOffset not working in only ipad2. how to solve it?

I tested it in PC, Android, IPad2 Air, and very well working.

But, only IPad is not working...

So, How to solve this Problem?

Shader :

 Shader "Custom/UVScrolling" {
     Properties {
         _Color ("Color", Color) = (1,1,1,1)
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _ScrollXSpeed ("X Scroll Speed", float) = 0
         _ScrollYSpeed ("Y Scroll Speed", float) = 0
     }
     SubShader {
             Tags
         {
             "Queue" = "Transparent"
             "IgnoreProjector" = "True"
             "RenderType" = "Transparent"
             "DisableBatching" = "True"
         }
             Pass
         {
 
             Cull Off
             Offset -1, -1
             Blend SrcAlpha OneMinusSrcAlpha
 
             CGPROGRAM
 #pragma vertex vert
 #pragma fragment frag            
 #include "UnityCG.cginc"
 
             sampler2D _MainTex;
         float4 _MainTex_ST;
         fixed _ScrollXSpeed;
         fixed _ScrollYSpeed;
         fixed4 _Color;
         float _IsUseSetOffset;
 
         struct appdata_t
         {
             float4 vertex : POSITION;
             float2 texcoord : TEXCOORD0;
             fixed4 color : COLOR;
             UNITY_VERTEX_INPUT_INSTANCE_ID
         };
 
         struct v2f
         {
             float4 vertex : SV_POSITION;
             half2 texcoord : TEXCOORD0;
             fixed4 color : COLOR;
             UNITY_VERTEX_OUTPUT_STEREO
         };
 
         v2f o;
 
         v2f vert(appdata_t v)
         {
             UNITY_SETUP_INSTANCE_ID(v);
             UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
             o.vertex = UnityObjectToClipPos(v.vertex);
             o.texcoord = v.texcoord * _MainTex_ST.xy + _MainTex_ST.zw;
 
             //o.color = v.color;
             o.color = _Color;
             return o;
         }
 
         fixed4 frag(v2f IN) : SV_Target
         {
             fixed2 uv_Tex = IN.texcoord;
             /*fixed varX = _ScrollXSpeed * _Time;
             fixed varY = _ScrollYSpeed * _Time;
             uv_Tex = IN.texcoord + fixed2(varX, varY);*/
 
             fixed4 col = tex2D(_MainTex, uv_Tex) * IN.color;
         return col;
         }
         ENDCG
         }
 }
         
         
     FallBack "Diffuse"
 }
 

Script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class UVAnimationEffect : MonoBehaviour
 {
     UITexture tex;
     UI2DSprite sp;
     UISprite sp2;
     public bool isUseDirectSetOffset;
     public float animSpeed = 0.2f;
     public float scrollSpeed = 5.0f;
     // Use this for initialization
     void Start () {
         tex = GetComponent<UITexture>();
         sp = GetComponent<UI2DSprite>();
         if(isUseDirectSetOffset)
         {
             scrollSpeed = 0;
         }
         
         sp.onRender = (Material mat) =>
         {
             mat.SetFloat("_ScrollXSpeed", scrollSpeed);
         };
     }
     
     // Update is called once per frame
     void Update () {
         if(isUseDirectSetOffset)       
         {
             float offsetX = Time.time * animSpeed;
             sp.onRender = (Material mat) =>
             {
                 mat.SetTextureOffset("_MainTex", new Vector2(offsetX % 1, 0));
                 //mat.SetTextureScale("_MainTex", new Vector2(offsetX % 1, 1.0f));
             };
             //Debug.Log(offsetX % 1);
         }
     }
 }
 



Please Help me .. TT

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

0 Replies

· Add your reply
  • Sort: 

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

68 People are following this question.

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

Related Questions

UV animations on particles systems through script 1 Answer

moving spot light change floor 0 Answers

Bone to uv 0 Answers

Ipad 2 lag 0 Answers

Can I use unity 3d as a component of UI in ipad app? 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