12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using UnityEngine;
- using System.Collections;
- using RootMotion.FinalIK;
- namespace RootMotion.FinalIK
- {
-
-
-
- public class VRIKLODController : MonoBehaviour
- {
- public Renderer LODRenderer;
- public float LODDistance = 15f;
- public bool allowCulled = true;
- private VRIK ik;
- void Start()
- {
- ik = GetComponent<VRIK>();
- }
- void Update()
- {
- ik.solver.LOD = GetLODLevel();
- }
-
- private int GetLODLevel()
- {
- if (allowCulled)
- {
- if (LODRenderer == null) return 0;
- if (!LODRenderer.isVisible) return 2;
- }
-
- float sqrMag = (ik.transform.position - Camera.main.transform.position).sqrMagnitude;
- if (sqrMag > LODDistance * LODDistance) return 1;
- return 0;
- }
- }
- }
|