using System.Collections; using System.Collections.Generic; using UnityEngine; public class MemoryPredictionLine : MonoBehaviour { [SerializeField] float p_y = 11f; [SerializeField] int vertexCount = 100; [SerializeField] float startWidthMultiplier = 0.5f; [SerializeField] float width = 2f; LineRenderer lineRenderer; public void Init() { lineRenderer = GetComponent(); this.gameObject.SetActive(false); } public void SetMemoryPredictionLine(MemoryTab currentMemoryTab, MemoryTab nextMemoryTab) { if(lineRenderer == null || currentMemoryTab == null || nextMemoryTab == null) { return; } if(currentMemoryTab == nextMemoryTab) { this.gameObject.SetActive(false); return; } if(vertexCount <= 0) { return; } if(p_y == 0) { return; } this.gameObject.SetActive(true); lineRenderer.positionCount = vertexCount; Vector3 memoryTabPos(MemoryTab memoryTab) { Vector3 position = new Vector3(); int index = GManager.instance.memoryObject.memoryTabs.IndexOf(memoryTab) - 10; position = new Vector3(9f * index, 0, 3); return position; } float alpha = Mathf.Abs(memoryTabPos(nextMemoryTab).x - memoryTabPos(currentMemoryTab).x) / 2f; float p_x = (memoryTabPos(nextMemoryTab).x + memoryTabPos(currentMemoryTab).x) / 2f; float a = (p_y - memoryTabPos(nextMemoryTab).z) / Mathf.Pow(alpha, 2); Vector3[] positions = new Vector3[vertexCount]; for(int i=0;i