Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 bridged · Jul 25, 2012 at 10:50 AM · texturespritematerialoffset

Texture / Material offset doesn't work

Hey,

I want to make a 2D Sprite animation, buy changing the offset of the material depending on the rotation. So I made a material with the shader transparent/cutout/diffuse and the texture is a png image which has every step inside to "roll" with offset

There is an empty gameobject without a renderer. In this empty game object is a 3D text with Mesh renderer and the font material. in the empty game object there is also a plane with a mesh renderer, which has the material I want to "scroll" with offset.

Here is the script on the empty gameobject (reduced to the problem):

 using UnityEngine;
 using System.Collections;
 
 public class Player : MonoBehaviour {
 
  public Renderer mat1;
  public float i;
 
  // Use this for initialization
  void Start () 
  {
  mat1 = transform.FindChild ("playerPlane").renderer;
  }
  
  // Update is called once per frame
  void Update () 
  {
  i++;
  if(Input.GetKey (KeyCode.W))
  {
  mat1.material.mainTextureOffset = new Vector2(i,20f);
  Debug.Log(mat1.material.GetTextureOffset("_MainTex") + " - " + i);
  }
  }
 }

the print function works correctly, but the image doesnt change, I see something on the edges like black pixels that appear and dissappear, maybe something is moving, but not the image itself.

Anyone an idea?

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

1 Reply

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

Answer by ScroodgeM · Jul 25, 2012 at 10:53 AM

texture offset is scaled 1:1 to texture's size. so if you want to shift half texture you should offset it by 0.5

you can very many times shift it by natural numbers (1,2,3...) and you will not see any effect.

Comment
Add comment · Show 1 · 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 bridged · Jul 25, 2012 at 11:06 AM 0
Share

lol ye I just got it by myself right before you answered, but thx for the answer!

I couldn't believe I didn't find such a simple information by myself when I searched on google and the manuals. Just checked the manual again, nothing about 0-1 there...

thx!

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

Changing button texture by setting a texture offset of a sprite sheet?(SOLVED) 1 Answer

How can I use atlas sprite as texture for a material? 2 Answers

Offset texture ONCE on key press 1 Answer

How to render a sprite to a quad? 1 Answer

How would you go about creating a material that allows you to add fully tiling textures to a 2D sprite? 1 Answer


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