Decal.cs 583 B

1234567891011121314151617181920
  1. #if UNITY_EDITOR
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace LuxURPEssentials
  6. {
  7. public class Decal : MonoBehaviour {
  8. LayerMask mask = ~0;
  9. public void AlignDecal() {
  10. Transform trans = GetComponent<Transform>();
  11. RaycastHit hit;
  12. if (Physics.Raycast(trans.position + new Vector3(0f, 1.0f, 0.0f), Vector3.down, out hit, 3.0f, mask.value)) {
  13. Vector3 proj = trans.forward - Vector3.Dot(trans.forward, hit.normal) * hit.normal;
  14. trans.rotation = Quaternion.LookRotation(proj, hit.normal);
  15. }
  16. }
  17. }
  18. }
  19. #endif