| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public class InterpolatorControl : MonoBehaviour |
| | 7 | | { |
| | 8 | |
|
| | 9 | | [SerializeField] private Color fogColor; |
| | 10 | |
|
| | 11 | | [SerializeField] private Color[] infiniteFloorFogColors; |
| | 12 | | [SerializeField] private Color infiniteFloorFogColor; |
| | 13 | |
|
| | 14 | | [SerializeField] private Material roundEdgesInterpolatorMat; |
| | 15 | |
|
| | 16 | | [SerializeField] private GameObject infiniteFloor; |
| | 17 | |
|
| | 18 | | private void Awake() |
| | 19 | | { |
| 0 | 20 | | roundEdgesInterpolatorMat = transform.GetComponent<SkinnedMeshRenderer>().material; |
| 0 | 21 | | } |
| | 22 | | // Start is called before the first frame update |
| | 23 | | void Start() |
| | 24 | | { |
| | 25 | |
|
| 0 | 26 | | } |
| | 27 | |
|
| | 28 | | // Update is called once per frame |
| | 29 | | void Update() |
| | 30 | | { |
| 0 | 31 | | GetFogColor(); |
| | 32 | | //SetFogColor(); |
| | 33 | |
|
| | 34 | | //infiniteFloorFogColor = GetVertexColor(1); |
| | 35 | | //infiniteFloorFogColors = GetInfiniteFloorColors(); |
| | 36 | |
|
| | 37 | | //infiniteFloorFogColor = infiniteFloorFogColors[1]; |
| | 38 | |
|
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | private void GetFogColor() |
| | 42 | | { |
| 0 | 43 | | fogColor = RenderSettings.fogColor; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | private void SetFogColor() |
| | 47 | | { |
| 0 | 48 | | roundEdgesInterpolatorMat.SetColor("_FogColor", fogColor); |
| 0 | 49 | | } |
| | 50 | |
|
| | 51 | | // get color from an objects vertex |
| | 52 | | private Color GetVertexColor(int vertexIndex) |
| | 53 | | { |
| 0 | 54 | | Color[] colors = new Color[transform.GetComponent<SkinnedMeshRenderer>().sharedMesh.vertexCount]; |
| | 55 | | //transform.GetComponent<SkinnedMeshRenderer>().sharedMesh.colors = colors; |
| | 56 | | //return colors[vertexIndex]; |
| | 57 | |
|
| | 58 | | // get mesh colors from infiniteFloor |
| 0 | 59 | | Color[] infiniteFloorColors = infiniteFloor.GetComponent<MeshRenderer>().sharedMaterial.GetColorArray("_Colors") |
| | 60 | |
|
| | 61 | | // return |
| 0 | 62 | | return infiniteFloorColors[vertexIndex]; |
| | 63 | |
|
| | 64 | | } |
| | 65 | |
|
| | 66 | | // get colors of infinite floor |
| | 67 | | private Color[] GetInfiniteFloorColors() |
| | 68 | | { |
| 0 | 69 | | Color[] infiniteFloorColors = infiniteFloor.GetComponent<MeshRenderer>().sharedMaterial.GetColorArray("_Colors") |
| 0 | 70 | | Debug.Log("infiniteFloorColors: " + infiniteFloorColors); |
| 0 | 71 | | return infiniteFloorColors; |
| | 72 | | } |
| | 73 | | } |