VRChat
Hypersonic Mar 9, 2020 @ 10:01pm
Need help altering my code to lerp an emission texture
I'm trying to slowly change colors on a decal on my avatar.

I know how to lerp the base texture on several items. I'm having trouble finding the right commands to do the same with the emmissive texture/mask within unity using a script.

here is my script so far.

-----------------------------------------------------------------------------------------------------------------
using UnityEngine;

public class LerpColor : MonoBehaviour {
SkinnedMeshRenderer BodyMeshRenderer;
[SerializeField] [Range(0f, 1f)] float lerpTime;

[SerializeField] Color[] myColors;

int colorIndex = 0;

float t = 0f;

int len;
// Use this for initialization
void Start () {
BodyMeshRenderer = GetComponent <SkinnedMeshRenderer>();
len = myColors.Length;
}

// Update is called once per frame
void Update() {
BodyMeshRenderer.material.color = Color.Lerp (BodyMeshRenderer.material.color, myColors[colorIndex], lerpTime * Time.deltaTime);

t = Mathf.Lerp (t, 1f, lerpTime * Time.deltaTime);
if (t>.9f){
t = 0f;
colorIndex++;
colorIndex = (colorIndex >= len) ? 0 : colorIndex;

}
}
}

-------------------------------------------------------------------------------------------------

any help would be greatly appreciated. I know i'm pretty close I just can't see where I need to define and place the final commands

apparently it involves "_Color"?

Thanks in advance.
< >
Showing 1-2 of 2 comments
Squid  [developer] Mar 10, 2020 @ 6:44am 
Hi, just so you're aware, VRChat does not support custom scripting using C# and .Net. The script will be omitted from the avatar when it is uploaded.

I would recomend looking into Udon though, which is VRChat's new custom scripting pipeline currently in open beta. Udon does not however support use on Avatars.

To do what you would like, I would recomend looking into how to achieve it using only shaders.
Last edited by Squid; Mar 10, 2020 @ 8:08am
Guh~hey~hey~♫ Mar 16, 2020 @ 4:34am 
You can do it trough animations.

Put an animator at the root of the object you want to change the color of in the hierarchy (create an empty object and put it at the root of the object - only at the root of objects containing a mesh renderer in that case - if there's nothing else with room), create an animation controller with an animation that will change the color/alpha/material properties/you name it....

Kinda the same as making wagging tails or twitching ears, but at the root of the meshes renderers instead of the armature.

Optionally you can also disable the animator and make a gesture/emote to toggle it on only when needed.
Last edited by Guh~hey~hey~♫; Mar 16, 2020 @ 4:36am
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Mar 9, 2020 @ 10:01pm
Posts: 2