Skip to main content
added 130 characters in body
Source Link
Big T Larrity
  • 1.4k
  • 4
  • 31
  • 61

Take a look at this. I'm not sure 100% but if you create a 'Color' in code, that is taken the same as your original color, then changeset the curve value to that color each frame, and finally set this as the color for "_Color".a So perhaps change from using SetCurve to 0.1f (or 0 or whatever). Then you assign that color in your 'SetCurve' callSetColor.

(Note: This doesn't answer your question exactly, but i still think it demonstrates a way to fix the problem):

ALSO: I expect you already have it set, but ensure the Material's Rendering Mode (in Inspector) is set to "Transparent" (it defaults as Opaque I think)

 Color transparentColor;

void Start(){
    Material mat = GetComponent<Renderer>().material;
    Color transparentColor = mat.color;
  }

void Update(){
 transparentColor.a = 0.1f; // or... inyour update,code changeto thisset valuecorrect dynamicallyvalue to equal 'curve' in your codehere
   transparentColor.a 

}

void= Update(){curve;
   if (iWantItTransparentNow){
       mat.SetColor("_Color", transparentColor);
   }
}

Take a look at this. I'm not sure 100% but if you create a 'Color' in code, that is taken the same as your original color, then change that color.a to 0.1f (or 0 or whatever). Then you assign that color in your 'SetCurve' call.

(Note: This doesn't answer your question exactly, but i still think it demonstrates a way to fix the problem):

 Color transparentColor;

void Start(){
    Material mat = GetComponent<Renderer>().material;
    Color transparentColor = mat.color;
    transparentColor.a = 0.1f; // or in update, change this value dynamically to equal 'curve' in your code
    

}

void Update(){
   if (iWantItTransparentNow){
       mat.SetColor("_Color", transparentColor);
   }
}

Take a look at this. I'm not sure 100% but if you create a 'Color' in code, that is taken the same as your original color, then set the curve value to that color each frame, and finally set this as the color for "_Color". So perhaps change from using SetCurve to SetColor.

(Note: This doesn't answer your question exactly, but i still think it demonstrates a way to fix the problem):

ALSO: I expect you already have it set, but ensure the Material's Rendering Mode (in Inspector) is set to "Transparent" (it defaults as Opaque I think)

 Color transparentColor;

void Start(){
    Material mat = GetComponent<Renderer>().material;
    Color transparentColor = mat.color;
}

void Update(){
   // ... your code to set correct value to 'curve' here
   transparentColor.a = curve;

   mat.SetColor("_Color", transparentColor);
   
}
added 114 characters in body
Source Link
Big T Larrity
  • 1.4k
  • 4
  • 31
  • 61

Take a look at this. I'm not sure 100% but if you create a 'Color' in code, that is taken the same as your original color, then change that color.a to 0.1f (or 0 or whatever). Then you assign that color in your 'SetCurve' call.

(Note: This doesn't answer your question exactly, but i still think it demonstrates a way to fix the problem):

 Color transparentColor;

void Start(){
    Material mat = GetComponent<Renderer>().material;
    Color transparentColor = mat.color;
    transparentColor.a = 0.1f; // or in update, change this value dynamically to equal 'curve' in your code
    

}

void Update(){
   if (iWantItTransparentNow){
       mat.SetColor("_Color", transparentColor);
   }
}

Take a look at this. I'm not sure 100% but if you create a 'Color' in code, that is taken the same as your original color, then change that color.a to 0.1f (or 0 or whatever). Then you assign that color in your 'SetCurve' call.

 Color transparentColor;

void Start(){
    Material mat = GetComponent<Renderer>().material;
    Color transparentColor = mat.color;
    transparentColor.a = 0.1f; // or in update, change this value dynamically to equal 'curve' in your code
    

}

void Update(){
   if (iWantItTransparentNow){
       mat.SetColor("_Color", transparentColor);
   }
}

Take a look at this. I'm not sure 100% but if you create a 'Color' in code, that is taken the same as your original color, then change that color.a to 0.1f (or 0 or whatever). Then you assign that color in your 'SetCurve' call.

(Note: This doesn't answer your question exactly, but i still think it demonstrates a way to fix the problem):

 Color transparentColor;

void Start(){
    Material mat = GetComponent<Renderer>().material;
    Color transparentColor = mat.color;
    transparentColor.a = 0.1f; // or in update, change this value dynamically to equal 'curve' in your code
    

}

void Update(){
   if (iWantItTransparentNow){
       mat.SetColor("_Color", transparentColor);
   }
}
Source Link
Big T Larrity
  • 1.4k
  • 4
  • 31
  • 61

Take a look at this. I'm not sure 100% but if you create a 'Color' in code, that is taken the same as your original color, then change that color.a to 0.1f (or 0 or whatever). Then you assign that color in your 'SetCurve' call.

 Color transparentColor;

void Start(){
    Material mat = GetComponent<Renderer>().material;
    Color transparentColor = mat.color;
    transparentColor.a = 0.1f; // or in update, change this value dynamically to equal 'curve' in your code
    

}

void Update(){
   if (iWantItTransparentNow){
       mat.SetColor("_Color", transparentColor);
   }
}