Пример #1
0
        // Like Unity's Update(), but only called on active pointers,
        // and called at a well-defined time.
        // Called from our manager.
        public void UpdatePointer()
        {
            UnityEngine.Profiling.Profiler.BeginSample("PointerScript.UpdatePointer");
            if (m_CurrentLine != null)
            {
                // Non-preview mode: Update line with new pointer position
                UpdateLineFromObject();
            }
            else if (m_PreviewLineEnabled && m_CurrentBrush != null)
            {
                // Preview mode: Create a preview line if we need one but don't have one
                if (m_AllowPreviewLine && m_PreviewLine == null)
                {
                    m_AllowPreviewLineTimer -= Time.deltaTime;
                    if (m_AllowPreviewLineTimer <= 0.0f)
                    {
                        CreatePreviewLine();
                    }
                }

                if (m_PreviewLine != null)
                {
                    // For most brushes, we control the rebuilding of the preview brush,
                    // since we have the necessary timing information and the brush doesn't.
                    if (m_PreviewLine.AlwaysRebuildPreviewBrush())
                    {
                        RebuildPreviewLine();
                    }
                    else
                    {
                        m_PreviewLine.DecayBrush();
                        m_PreviewLine.UpdatePosition_LS(GetTransformForLine(m_PreviewLine.transform), 1f);
                    }

                    // Always update preview brush after each frame
                    m_PreviewLine.ApplyChangesToVisuals();
                }
            }

            m_PreviousPosition = transform.position;
            UnityEngine.Profiling.Profiler.EndSample();
        }