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
1
Question by eliascanaza · Mar 14, 2013 at 09:21 PM · textureplane

Change Texture of Plane with script

Hi everyone, i need change texture of plane with script, i have a empty plane and i want add an image as texture, this will be dynamically ... thanks

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

5 Replies

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

Answer by Seth-Bergman · Mar 14, 2013 at 09:23 PM

simply use:

  var myTexture : Texture;  

then in your script:

  renderer.material.mainTexture = myTexture;

this script would be attached to the plane itself.. to access the plane from another object, you would need to create a var for that:

  var thePlane : GameObject;

then use in the code:

  thePlane.renderer.material.mainTexture = myTexture;
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 eliascanaza · Mar 18, 2013 at 05:36 PM 0
Share

this is the solution ...!!! now this work :) http://answers.unity3d.com/questions/14748/c-resourcesload-problem.html

avatar image
1

Answer by eliascanaza · Mar 15, 2013 at 03:33 PM

I ... thnsk but this not work... so i tested with this code .... not work..

     private Texture _texture;
     
     void Start () {
     
             _texture = Resources.Load("3-photo") as Texture;
             renderer.material.mainTexture = _texture;
     }

i have an image them i want load into plane

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 robertbu · Mar 15, 2013 at 03:36 PM 0
Share

This code will work. $$anonymous$$ake sure the texture is in Assets/Resources. @Seth Bergman's original code will also work. You must drag and drop the texture you want onto the myTexture variable in the inspector for it to work.

avatar image eliascanaza · Mar 15, 2013 at 04:20 PM 0
Share

not work, i have 5 images (texture) and a plane, when i clicked on button this plane will change an other texture

avatar image
-2

Answer by absolutegames · Mar 15, 2013 at 06:01 PM

visit http://absolute-games.blogspot.com !

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 eliascanaza · Mar 15, 2013 at 10:39 PM 0
Share

the code above is i worked now

avatar image thejox · Jan 18, 2021 at 01:12 AM 0
Share

Why is an answer with -2 votes above the answers with 0 votes?

avatar image
0

Answer by zgamesoft · Jul 15, 2014 at 02:08 PM

Check this video https://www.youtube.com/watch?v=baFr-6Tafuc

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
0

Answer by akash_virodhia · Jun 17, 2017 at 12:52 PM

Simple C# code :

public Texture yourTexture ;

// then in the update function

GetComponent ().material.mainTexture = yourTexture;

Also, in higher version of unity 'renderer.material' is obsolete have to use 'GetComponent ().material' instead.

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

15 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

Related Questions

Change Texture of Plane with script 0 Answers

360 degree plane rotation & texture change 1 Answer

GUI Texture on Button Swap 3 Answers

Creating a component from a button click 1 Answer

Creating a 2D game using planes with textures 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