• 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
1
Question by TheCheatsrichter · Jun 01, 2016 at 02:41 PM · materialtexture2dlinerenderertextureingchange variable

Repeatable 2D Texture on Linerenderer

I try to create a Linerenderer (Positions update every Frame) which uses a texture that is repeated depending on the needed length.

Therefore I tried the following:

1) Creating a reapeatable texture

Texturepic

2) Creating a Material (Sprite/Default Shader) which uses this texture.

Matpic

3) Changing the texture's scale when needed:

 //Update Linderenderer
             linerenderer.SetPosition(0, transform.position);
             linerenderer.material.SetTextureScale("_MainTex", new Vector2(hook_joint.distance,1));
             Debug.Log(linerenderer.material.GetTextureScale("_MainTex"));

The Debug Log shows that the texture scale changes over time, the change is however not visible? Do i change the wrong texture on the material or is this kind of approach totaly wrong?

I allready found several answers to this question , which range from using special shaders to chaining linerenderers together (multiple linerenderers with fixed length) . Most of these answers however do not cover the use of a transparent key in the texture (my chain has holes ) or do only work in 3D.

unbenannt2.png (6.9 kB)
unbenannt.png (20.1 kB)
Comment
Add comment · Show 2
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 JoshDangIt · Jun 01, 2016 at 04:09 PM 0
Share

Have you seen this?: http://answers.unity3d.com/questions/548846/repeat-texture-ins$$anonymous$$d-of-stretching-it-all-over.html

avatar image alarm656 · Aug 30, 2017 at 03:06 PM 0
Share

What is "hook_joint.distance"?

2 Replies

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

Answer by TheCheatsrichter · Jun 02, 2016 at 11:05 AM

The shader Sprites/Default does not use any of he Texture Scale functions! I changed the material shader to standart and used the Cutout rendering mode to achieve the transparancy in the chain. After that the code from above works perfectly and the line renderer displays in the correct scale at each frame.

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

Answer by anil4029 · Jan 07, 2017 at 08:27 PM

change material shader to standard and then click on emission and choose same texture.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

UI LineRenderer Antialaing/masking issue 0 Answers

Why does applying a material to a object break batching? 2 Answers

Merging Textures At Runtime - Not Correct? 1 Answer

rallenty scroll main texture 0 Answers

Material doesn't have a color property '_Color' 4 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges