• 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 mohhad · Aug 19, 2014 at 12:36 PM · texturepaintingplanes

How to place a sprite above a GUI.DrawTexture

I am creating a unity 2D app that includes a feature where you color an image.

I set up a painting functionality where I draw the textures needed on a plane. Currently everything is working fine when i draw the actual image as texture and paint it. The problem is that when i paint, the colors are covering the black lines of the image. Imagine coloring an white background with black outlines.

I am attempting to place the same image as a sprite on top of the GUI.DrawTexture with no luck. No matter what I do the Drawn texture is always on top of the sprite object.

I need the outlines to be over the painting panel. Any ideas?

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
2

Answer by Scribe · Aug 19, 2014 at 12:59 PM

You can do this by using two cameras and two layers. You have one camera that renders your gui and set its culling mask to everything except your new layer and set its depth to -1 or something. Then with your second camera remove the gui layer component (and probably audio listener) and set its culling mask to nothing except your new layer and set its depth to 0 and set its clear flags to 'Depth only'.

Then you put the sprite that you want to render on the new layer you created and it should be rendered only by the new camera, above everything else!

Scribe

EDIT:

You are correct, this doesn't work with OnGUI sorry about that. To make it work keeping the same setup as you have with the foreground and background cams, attach this script to your background camera and disable your foreground cam

 var foregroundCam : Camera;
 
 function OnGUI(){
     // [all your other gui stuff]

     if (Event.current.type == EventType.Repaint){
         foregroundCam.Render();
     }
 }

That should work! sorry for my first incorrect answer :o

Comment
Add comment · Show 4 · 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 mohhad · Aug 19, 2014 at 01:07 PM 0
Share

Thank you for the quick answer, i will try that and let you know.

avatar image mohhad · Aug 20, 2014 at 07:03 AM 0
Share

This is Not working. I tried all you said, but the Drawn Texture is always on top of the sprite. Any other Ideas?

avatar image Scribe · Aug 20, 2014 at 10:43 AM 0
Share

Check my edit! hopefully that works for you

avatar image mkobi · Apr 06, 2015 at 09:09 PM 0
Share

Scribe. You are a genius ! That WOR$$anonymous$$S !!! Background image is UNDER the sprites !!!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Understanding Texture Atlasing 0 Answers

Is there a way to paint a texture onto a mesh like in UE4? 1 Answer

reversing object scale is ruining the texture coordinates ? 0 Answers

Coloring textures in Unity3d 1 Answer

Improve terrain texture painting 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