回不去的记忆126 2021-10-25 14:00 采纳率: 75%
浏览 26

有没有博主翻译一下这些代码,我只明白一点

using UnityEngine;

public class UpdateProps : MonoBehaviour
{
private static int nHash;
private static int pHash;

public GameObject obj;
public GameObject plane;

private Material objMat;

// Start is called before the first frame update
void Start()
{
    objMat = obj.GetComponent<MeshRenderer>().sharedMaterial;
    nHash = Shader.PropertyToID("n");
    pHash = Shader.PropertyToID("p");
}

// Update is called once per frame
void Update()
{
    // n==normal of plane
    // p==position of plane
    var n = plane.transform.up;
    var p = plane.transform.position;

    objMat.SetVector(nHash, n);
    objMat.SetVector(pHash, p);
}

}

  • 写回答

1条回答 默认 最新

  • xuzuning 2021-10-25 15:21
    关注

    最基本的向着色器变量赋值

    评论

报告相同问题?

问题事件

  • 创建了问题 10月25日