コード例 #1
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = Use.GetFingers(true);

            for (var i = 0; i < fingers.Count; i++)
            {
                var finger = fingers[i];

                if (LeanFingerData.Exists(fingerDatas, finger) == false)
                {
                    // Too many active links?
                    if (MaxTrails >= 0 && LeanFingerData.Count(fingerDatas) >= MaxTrails)
                    {
                        continue;
                    }

                    if (Prefab != null)
                    {
                        // Spawn and activate
                        var clone = Instantiate(Prefab);

                        clone.gameObject.SetActive(true);

                        // Register with FingerData
                        var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

                        fingerData.Line  = clone;
                        fingerData.Age   = 0.0f;
                        fingerData.Width = Prefab.widthMultiplier;
                    }
                }
            }

            // Update all FingerData
            for (var i = fingerDatas.Count - 1; i >= 0; i--)
            {
                var fingerData = fingerDatas[i];

                if (fingerData.Line != null)
                {
                    UpdateLine(fingerData, fingerData.Finger, fingerData.Line);

                    if (fingerData.Age >= FadeTime)
                    {
                        Destroy(fingerData.Line.gameObject);

                        fingerDatas.RemoveAt(i);
                    }
                }
                else
                {
                    fingerDatas.RemoveAt(i);
                }
            }
        }