PlayAreaMono.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayAreaMono : MonoBehaviour
  5. {
  6. private Transform headTransform;
  7. private MeshFilter meshFilter;
  8. private MeshRenderer meshRenderer;
  9. private Mesh edgeMesh;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. if (headTransform == null)
  14. {
  15. headTransform = API_GSXR_Slam.SlamManager.head;
  16. }
  17. meshFilter = this.gameObject.AddComponent<MeshFilter>();
  18. meshRenderer = this.gameObject.AddComponent<MeshRenderer>();
  19. meshRenderer.material = Resources.Load<Material>("Material/SafetyEdgeMat");
  20. if(edgeMesh == null)
  21. {
  22. Debug.LogError("EdgeMesh is Null");
  23. return;
  24. }
  25. meshFilter.mesh = edgeMesh;
  26. }
  27. // Update is called once per frame
  28. void Update()
  29. {
  30. meshRenderer.sharedMaterial.SetVector("headPosition", new Vector4(headTransform.position.x, headTransform.position.y, headTransform.position.z, 1f));
  31. }
  32. public void SetMesh(Mesh mesh)
  33. {
  34. this.edgeMesh = mesh;
  35. }
  36. }