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 mandude · Feb 15, 2012 at 02:41 AM · textureimage

How do I assign a Texture to a variable?

I've declared a Texture2D variable in JS, and I was wondering how I'm meant to assign it inside the script (not in the inspector) while it's exposed? All of the solutions I've read so only explain the Resources.Load method, but this does not work for an exposed variable.

Thanks in advance.

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
0

Answer by Berenger · Feb 15, 2012 at 03:54 AM

I'm not sure what you means by exposed, but as far as I know, Resources.Load works for every variables. It does require the asset to be in the resources folder though, because the load being in the script, Unity can't know if it's used and won't pack it in the build. I don't think it's possible to access assets otherwise. I think there is something with asset bundles, but I'm not sure what that creature is.

Comment
Add comment · Show 3 · 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 mandude · Feb 15, 2012 at 02:10 PM 1
Share

An exposed variable is just a variable outside of the function. I can get Resources.Load to work, just not outside of one. Thanks for your time, though.

avatar image Tseng · Feb 15, 2012 at 02:32 PM 1
Share

You should learn some program$$anonymous$$g terms, before starting to programm ;)

There are three kind of variables: local variables, member variables, static variables.

Local variables are only accessible within a certain code block (an if/while block, an function/method, etc.).

$$anonymous$$ember variables are accessible withing the class and are bound to an instance of that class. They are only accessible within the class or if you have an instance for the class (if they have public accessibility)

Static variables are similar to member variables, but they are not bound to a certain instance and can be accessed without having an reference to the instance.

And then, there are also access levels for variables (only for member and static ones), which can be: Private, Protected, Public (depending on language there may be some more, but this are the three most important):

public: can be accessed from outside of the class protected: can only be accessed from within the class and it's derived classes private: can only be accessed by the class they were declared in (they can NOT be accessed by derived classes).

And then if you ask questions, keep in $$anonymous$$d to use this ter$$anonymous$$ology to make sure other people understand what you're trying to ask

avatar image mandude · Feb 15, 2012 at 03:19 PM 1
Share

I'm not sure if you're just trying to be condescending, but I am fairly familiar with the ter$$anonymous$$ology you've given. It was a variable of type Texture2D, and I'm fairly sure no one was worse off for my use of the phrase.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you crop a Texture2d 1 Answer

Repeating Material texture 0 Answers

How To Apply A Texture Atlas For UI Image Objects? 0 Answers

Image is not loading into Texture 0 Answers

What is the best way to implement videos in 2D unity game? 0 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