Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
1
Question by ruimtebever44 · Oct 08, 2019 at 12:28 PM · scripting problemrenderinghowhow to

How do I SetTextureOffset in LWRP?

Hello. I'm trying to offset the texture and I'm using the example script from here : https://docs.unity3d.com/ScriptReference/Material.SetTextureOffset.html I'm using the light weight render pipeline / universal render pipeline. It doesn't work. I get no errors, but nothing happens at all. I just want to know what I need to type to offset the texture instead.

     using UnityEngine;
     
     public class Example : MonoBehaviour
     {
         // Scroll main texture based on time
     
         float scrollSpeed = 0.5f;
         Renderer rend;
     
         void Start()
         {
             rend = GetComponent<Renderer> ();
         }
     
         void Update()
         {
             float offset = Time.time * scrollSpeed;
             rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
         }
     }

EDIT: It doesn't seem to work with any of the shaders that are listed in the folder "Lightweight Render Pipeline". However, if I pick another folder "Unlit > Textured" it works fine. All the other shaders I can select display a purple colour (because I guess they don't work with the LWRP). alt text

Comment
Add comment · Show 4
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 lgarczyn · Oct 08, 2019 at 03:14 PM 0
Share

Does your material shader actually have an offset property?

avatar image ruimtebever44 lgarczyn · Oct 08, 2019 at 05:19 PM 0
Share

Yes. I'm using the default LWRP unlit one (but I've tried a handful of different LWRP shaders). If I change the offset in the inspector, it works perfectly. I just have no clue how to figure out how to do it in code.

Just for clarity, I'm basically starting from a fresh project with LWRP Template and have no code that could be intefering. Which is why I'm so confused the official example script doesn't work.

avatar image lgarczyn ruimtebever44 · Oct 08, 2019 at 05:59 PM 0
Share

It's possible that unity optimizes away the offset part of the shader if you leave the default offset values. Have you tried setting them to any other value than 0?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by marcozakaria · Nov 26, 2019 at 10:00 AM

use : material.SetTextureOffset("_BaseMap", newOffset);

"_MainTex" will not work instead "_BaseMap".

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 chiragms · Feb 17, 2020 at 12:51 PM 0
Share

Absolutely worked like a charm! Thanks @marcozakaria.

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

207 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 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 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 avatar image avatar image avatar image

Related Questions

error CS0246 1 Answer

Light not instantiate after a time 0 Answers

LWRP Changing Shadow Resolution in Scripting 0 Answers

how do i take whats on one UI canvas and make it apear on another in real time(for a card game) 0 Answers

How to delay render one camera for X ms? 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