Access properties through scripts

Node-based Shader Editor

Access properties through scripts

Postby Mr_jigs » Mon Jun 19, 2017 6:54 am

How would I go about accessing various shader properties through C# scripts? Say I wanted to animate the value Distortion which is a float in your SimpleRefraction sample shader by controlling its value through a C# script.
Mr_jigs
 
Posts: 2
Joined: Sun Jun 18, 2017 1:28 pm

Re: Access properties through scripts

Postby Ricardo Teixeira » Mon Jun 19, 2017 9:06 am

Hello,

Thank you for using ASE, we really appreciate it. Check the Smear sample included in the package, it demonstrates a simple way to alter those types of values via script.

Be sure to let us know if you have any follow up questions, we would be happy to elaborate.

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Access properties through scripts

Postby Mr_jigs » Tue Jun 20, 2017 5:27 pm

Hello Ricardo,

I must be pretty dense at the moment. I have had a look at the code you suggested but I can't see an example of getting access to the values of a particular node. I can see getting access to properties of the material class but not to any of the amplify nodes.

Fortunately, after searching through the other samples I came across another example called HighlightAnimated which had a script by the same name that did show how to access a node value. I managed to get my testcase working.

For those looking for the same information:
check out highlightAnimated.cs, pay attention to the namespace.
check out the shader code properties section to find out what is available to you.

Cheers
Mr_jigs
 
Posts: 2
Joined: Sun Jun 18, 2017 1:28 pm

Re: Access properties through scripts

Postby Ricardo Teixeira » Tue Jun 20, 2017 6:17 pm

Mr_jigs wrote:Hello Ricardo,

I must be pretty dense at the moment. I have had a look at the code you suggested but I can't see an example of getting access to the values of a particular node. I can see getting access to properties of the material class but not to any of the amplify nodes.

Fortunately, after searching through the other samples I came across another example called HighlightAnimated which had a script by the same name that did show how to access a node value. I managed to get my testcase working.

For those looking for the same information:
check out highlightAnimated.cs, pay attention to the namespace.
check out the shader code properties section to find out what is available to you.

Cheers



Hello,

No problem, we would be happy to elaborate. Notice the variables set to Global in the shader, inside the comment box "Fed by a script", they are updated by the Smear.cs script.

Your example is also good reference on how to alter material properties.

Be sure to let us know if you have any additional questions.

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests

cron