Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question ProBuilder: Get Vertex Color at UV coord

Discussion in 'World Building' started by CaseyHofland, Sep 24, 2022.

  1. CaseyHofland


    Mar 18, 2016
    We're making our game out of materials using vertex colors and now we want to add footsteps sounds. Normally that would be texture-based, but in this case we need it color-based.

    Code (CSharp):
    1.     // Step() is called from an animation event
    2. private void Step()
    3.     {
    4.         if (!Physics.Raycast(transform.position, -transform.up, out var hit, 0.25f, ExtraPhysics.GetLayerCollisionMask(gameObject.layer), QueryTriggerInteraction.Ignore)
    5.             || !hit.transform.TryGetComponent(out Renderer renderer)
    6.             || !renderer.sharedMaterial)
    7.         {
    8.             return;
    9.         }
    11.         var material = renderer.sharedMaterial;
    12.         var textureCoord = hit.textureCoord;
    13.         // Get Vertex Color
    14.     }
    How do we do that though? The Standard Vertex Color shader (from the URP Sample) doesn't have a texture where this information is stored, which is probably not how vertex colors work but I'm noob and need help :|