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
0
Question by dansav · Nov 26, 2011 at 08:01 AM · texturejpgmaintexture

apply jpg texture to game object

I want to create a primitive and apply a pict.jpg that I have dragged into the assets folder. All the examples I've seen want you to do
myprimitive.renderer.material.mainTexture=Resources.Load("pict");//this works.

According to the docs though you can assign a texture like this
var texture : Texture;
renderer.material.mainTexture = texture;

When I load a jpg into assets it looks like it's a texture in the inspector, but
renderer.material.mainTexture="pict"; //does not work

Does resources load have to be used to apply a texture?

Thanks, Dan

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 syclamoth · Nov 26, 2011 at 08:07 AM 0
Share

Have you tried dragging it from the project view into the 'texture' slot that 'var texture : Texture' exposes in the inspector?

avatar image dansav · Nov 26, 2011 at 08:10 AM 0
Share

I have to do it dynamically as the primitives are created on the fly in the script.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by BerggreenDK · Nov 26, 2011 at 12:26 PM

I think you need to load the texture into a texture object if you want to assign it later.

So create a texture variable like the docs states, then load the texture into that. Later on, when you need it, assign the variable to the mainTexture property.

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 dansav · Nov 26, 2011 at 04:35 PM 0
Share

how do you load pict into the texture variable? texture="pict"; ?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

into which folder can i import my jpeg files so i can put some texture on a wall obj? 0 Answers

is it possible to use JPG compression on iOS export for non PVRTC textures? 0 Answers

Video texture problem? 2 Answers

Texture format for 2D Android Game 1 Answer

Is there a way to make a jpeg texture transparent for black? 2 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