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 reptilebeats · Oct 17, 2014 at 11:11 AM · renderer

Shader forge Toggle

Hey guys i was wandering if anyone knew how to access the toggle or bool of a shader that was created in shader forge.

C Sharp fireBaseObj.renderer.material.??("_crafted", true);

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 habsi70 · Oct 17, 2014 at 11:21 AM 0
Share

Interesting, I thought material would have a SetBool function. $$anonymous$$ust look into it further

avatar image habsi70 · Oct 17, 2014 at 01:39 PM 0
Share

Wisearns answers is the way to go, because there is no boolean Set/Get. See this forum entry

It would be interesting to see the shader code made by Shaderforge ...

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Wisearn · Oct 17, 2014 at 01:47 PM

The material properties does at least have a GetInt and SetInt that you can expose as 0, 1 and convert to/use as a bool.

http://docs.unity3d.com/ScriptReference/Material.GetInt.html (see GetFloat)

So in the properties of the shader something like

 Properties {
     Crafted ("_Crafted", Range (0, 1)) = 0;
 }

and then something like

 bool myBool = (renderer.material.GetInt("_Crafted") == 1 ? true : false)

and

 renderer.material.SetInt("_Crafted", 1);


(someone might have to correct my code, I haven't actually tried this myself)

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 reptilebeats · Oct 17, 2014 at 04:15 PM 0
Share

Yh i pretty much have done that for now, ins$$anonymous$$d though i changed the toggle inside the shader to a visible value for now. I will send a message to him and see if i can get a solid solution to it. However im guessing it will be what you wrote above. Thanks

avatar image reptilebeats · Oct 17, 2014 at 04:18 PM 0
Share

Oh and i will check the code when i get home im a bit rusty in csharp, switching from java/uniscript so everything's a bit different for me

avatar image
0

Answer by taecg · Aug 13, 2016 at 07:54 AM

[Toggle(keyword)]name(“display name”,float)=number

Comment
Add comment · 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
0

Answer by kjustynski · Dec 13, 2016 at 05:14 PM

Toggle node is just nice UI wrapper for Float value. If you want to change its value from script, simply use SetFloat function.

material.SetFloat("_ParamName", 0);

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

32 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

Related Questions

A node in a childnode? 1 Answer

'Sticky' cursor 1 Answer

How to make it so enemies only move towards the player when the player is colliding with an object 1 Answer

input key named : KeyCode.Escape is unkown 2 Answers

Changing material on prefab 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