Author Topic: EyeAdvanced Help  (Read 1617 times)

finn

  • Newbie
  • *
  • Posts: 4
    • View Profile
EyeAdvanced Help
« on: July 11, 2016, 09:15:19 AM »
Hey is there any way to access and change the material attributes of EyeAdvanced (iris color, limbal ring amount, etc.) with scripts?

Great Product and Thank you
« Last Edit: July 11, 2016, 09:44:04 AM by finn »

finn

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: EyeAdvanced Help
« Reply #1 on: July 11, 2016, 09:57:21 AM »
nvmd think i got how from autodilate

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: EyeAdvanced Help
« Reply #2 on: July 11, 2016, 07:04:19 PM »
Glad you got it working :)  Let me know if you run into any further trouble.

finn

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: EyeAdvanced Help
« Reply #3 on: July 12, 2016, 08:01:52 AM »
public class SetRandomIris : MonoBehaviour {
    Renderer lre;
    Renderer rre;
    public Texture[] Textures = new Texture[60];
    // Use this for initialization
    void Start () {
        Renderer lre= GameObject.Find("LeftEye").GetComponent<Renderer>();
        lre.enabled = true;
        Renderer lrre = GameObject.Find("RightEye").GetComponent<Renderer>();
        rre.enabled = true;
       
        int tran = Random.Range(18, 29 );
        int gran = Random.Range(180, 255);
        int rran = Random.Range(180, 255);
        int bran = Random.Range(180, 255);
        Color crandom = new Color(rran, gran, bran);
        lre.sharedMaterial.SetColor("_irisColor",crandom);
        rre.sharedMaterial.SetColor("_irisColor", crandom);
        lre.sharedMaterial.SetTexture(tran, Textures[tran]);

The texture change aspect doesn't actually seem to be working, could you possibly tell me what is wrong with my code? I imagine it's in the Set call.
« Last Edit: July 12, 2016, 08:57:32 AM by finn »

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: EyeAdvanced Help
« Reply #4 on: July 12, 2016, 10:14:59 AM »
Your set texture call isn't accessing a texture name on the shader.  you need to give it the name of the texture you want to set in the first attribute.  So instead of this...
lre.sharedMaterial.SetTexture(tran, Textures[tran]);

you should use this...
lre.sharedMaterial.SetTexture("_IrisColorTex", Textures[tran]);

This is a list of the different texture names used in the shader.  the "_IrisColorTex" is the most common texture to be changed, unless you're doing something very specific.
_IrisColorTex
_IrisTex
_CorneaBump
_EyeBump
_IrisBump
_MainTex

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: EyeAdvanced Help
« Reply #5 on: July 12, 2016, 10:18:09 AM »
Also, I split these questions into their own new topic, in case others reading this board have similar issues :)

finn

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: EyeAdvanced Help
« Reply #6 on: July 13, 2016, 02:37:54 AM »
Oh thanks so much, man. That was a perfectly thorough answer.