• 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
Question by giosto · Oct 01, 2018 at 06:09 AM · shadergraph

Make shader for UI

hey guys

just a little question

I'm making material using shadergraph and I want to attach it on mu UI element. how is it possible?

Comment

People who like this

0 Show 0
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

5 Replies

· Add your reply
  • Sort: 
avatar image

Answer by cnczcraft · Oct 01, 2018 at 06:26 AM

No make a sprite in a paint program shader graph is 3d only. Out of curiosity, why do you want to do this?

Comment
giosto
LW
Xtro

People who like this

-1 Show 5 · 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 giosto · Oct 01, 2018 at 06:44 AM 0
Share

I'm going to make dynamic health bar shader :/

avatar image giosto · Oct 01, 2018 at 06:46 AM 0
Share

any other advice?

avatar image cnczcraft · Oct 01, 2018 at 06:49 AM 0
Share

Make a sprite for the different colors of bar and move the bar with your health. Then either mask the end of the bar that sticks out or hide it at the edge of the screen.

avatar image giosto · Oct 01, 2018 at 07:04 AM 0
Share

the goal, I want to achieve is something different. I've already made shader. all I have to do is attach it on UI element. or maybe can I make 'fake' UI image?

avatar image cnczcraft · Oct 01, 2018 at 07:35 AM 0
Share

You can't UI elements don't take materials I think

avatar image

Answer by ValakhP · Oct 03, 2018 at 10:47 AM

Hello giosto,



I don't use shader graph, but in general, there is no a lot of difference between shaders for UI and world objects.



If it's possible, take a look on built-in UI shaders and compare it with the shader that shader graph gives you.



Simple shaders should work both on UI elements and 3D objects. It it's not - find differences between your resulting shader and built-in one.



You can download build-in shaders from here: https://unity3d.com/ru/get-unity/download/archive

Comment

People who like this

0 Show 0 · 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

Answer by Dankey_Kang · Oct 03, 2018 at 01:24 PM

I havent used shadergraph so forgive my ignorance but I believe you can add a material to UI components, for example if you look at Image components you'll notice an object field named material. You set it there.

UI materials are handled a little differently then normal 3D materials and there are some special considerations.

An example of special considerations is how _MainTex is handled in shaders designed for the Text component, _MainTex is passed a texture by the Text component itself and it is an image of the relevant letter I think.

It will depend on the UI element you are using, sounds like this will be an Image component if it is a health bar.

Comment

People who like this

0 Show 0 · 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

Answer by metalouis · Oct 29, 2018 at 04:42 PM

You can make shaders for the UI, though mine only seem to work in editor and not play mode unless I set the canvas to use screen space-camera, otherwise its just black for me. FYI if you want to get the colour of the UI element add a vertex colour node.

Comment

People who like this

0 Show 0 · 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

Answer by leshemamit · May 24, 2019 at 07:16 AM

I've used shader graph for UI Image (also works for RawImage) and made a tutorial about it! hope you will find it useful:

https://www.youtube.com/watch?v=Nbvqi8cfnrc&list=PLhQGsXIRIGQ3Z99Z60tIGsK3kmpRRuvbj∈dex=2

Comment

People who like this

0 Show 0 · 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

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

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

How to use a displacement map to create a ripple effect on a texture? 0 Answers

Shader graph causing weird glitching only in Build 1 Answer

Is it worth keeping the built-in render pipeline? 0 Answers

Set color with matrix4x4 in shader graph makes color exploding with light in scene 0 Answers

Vertex Displacement Shader Graph With The Camera Moving Issue 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