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 karthees · Sep 30, 2014 at 05:52 AM · textureimage

How to load image

I have image to load in the scene and i have used texture2d to load the image.But the image is not loading in the screen. I have another button called but the button is loading.

  void OnGUI() {
         
         
         Texture2D texture = Resources.Load("spino2") as Texture2D;
         GUI.skin.button = startbtnstyle;
         if(GUILayout.Button("Start", startbtnstyle)){
             
             
              Application.LoadLevel("25Nov1");
             
         }
         
         
     }
      
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Quaker_SDR · Sep 30, 2014 at 05:58 AM

I wonder why you store that in "texture" and not using it at all. Since you use the guistyle to draw the button.

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 karthees · Sep 30, 2014 at 06:01 AM 0
Share

button is different and the background image is diff..The spino2 is the name of the image

avatar image karthees · Sep 30, 2014 at 06:04 AM 0
Share

ok...how to load the image in the scene

avatar image
0

Answer by robertbu · Sep 30, 2014 at 06:13 AM

Assuming you got the name right, you are loading the image, but you are going to have to select a method of displaying the image. Partial list:

  • Use OnGUI() and GUI.DrawTexture()

  • Put a material on a Quad, then assign the texture you loaded to renderer.material.mainTexture.

  • Create a game object with a GUITexture component and assign the texture to guiTexture.texture.

So from where you are now, the first is the easiest. I suggest you do it this way:

 Texture2D texture;
 
 void Start() {
     texture = Resources.Load("spino2") as Texture2D;
 }

 void OnGUI() {
 
     GUI.DrawTexture(new Rect(100,100,500,500), texture); 
     
     GUI.skin.button = startbtnstyle;
     if(GUILayout.Button("Start", startbtnstyle)){
          Application.LoadLevel("25Nov1");
     }
 }
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 karthees · Sep 30, 2014 at 06:46 AM 0
Share

it's loading the image but it showing too small..I used 768x1024 for iPad..It's not showing proper

avatar image Quaker_SDR · Sep 30, 2014 at 11:32 AM 0
Share

I belive you are aware about the rect.

Portrait: GUI.DrawTexture(new Rect(0,0,768,1024), texture);

Landscape:

GUI.DrawTexture(new Rect(0,0,1024,768), texture);

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

26 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

Related Questions

Image Effects on MovieTexture 0 Answers

load all png files as resource but NOT from resource folder 2 Answers

Images not importing when platform is ios? 0 Answers

How can I add a distance cap to this script? 3 Answers

32 bit color in texture file 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