Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by vvvey · Nov 13, 2016 at 07:37 AM · spritetexture2dimagehudbug report

Generating a texture and using as Source Image

I've written a method to generate a texture for my minimap. All non-obstacle tiles are blue, and the obstacles are white. This is very easy, and I've saved the texture to a file to make sure this part is working.

However, when I want to add this as a source image in my gui image, all I get is a grey square. See code below.

 Texture2D minimapBackdrop;
 public void Init( bool[,] obstacleMap ){

     this.obstacleMap = obstacleMap;
     minimapBackdrop = GenerateMinimapTexture ( obstacleMap );
     Rect rect = new Rect (-40f, -240f, minimapBackdrop.width, minimapBackdrop.height);

     Sprite s = Sprite.Create (minimapBackdrop, rect, Vector2.zero );
     s.name = "Minimap Sprite";
     Image im = gameObject.GetComponent<Image> ();

     im.sprite = s;
     im.overrideSprite = s;
     initialised = true;

 }




Based on my googling on the topic, I have to create a sprite and assign this to the Image element, which is what I'm trying to do here.

It works if I save the texture as a .png and, via the editor, drop it on the image, so maybe the issue is with the created sprite, but I can't find what it is.. The name of the Source Image changes to "Minimap Sprite".

I found this question where someone seems to have the same problem, but it's not answerred. http://answers.unity3d.com/questions/942758/problems-with-spritecreate-in-current-version.html

Thanks!

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 UNDERHILL · Nov 15, 2016 at 06:45 AM 0
Share

You should categorize this as "bug" I've seen this around a few times now

avatar image vvvey UNDERHILL · Dec 06, 2016 at 08:39 PM 0
Share

Thanks for your comment and excuse the late answer - how exactly do I categorize it as a bug? Does adding the "bug-report" topic suffice?

0 Replies

· Add your reply
  • Sort: 

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

97 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 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 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 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

Unity display image from assets folder 0 Answers

Trouble getting created sprite to set. 0 Answers

Display downloaded image as new Sprite 0 Answers

Switch Texture Type To Sprite. 0 Answers

problem with arrays and image replacment 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