Пример #1
0
 public ControlPointSettings(ControlPointSettings settings)
 {
     if (settings.Settings != null)
     {
         Settings = settings.Settings.ToDictionary(kvp => kvp.Key, kvp => new ControlPointValue(kvp.Value));
     }
 }
Пример #2
0
        public override void Append(float distance = 0)
        {
            Vector3 position;
            Vector3 tangent;
            ControlPointSettings settings;
            int controlPointsCount = ControlPointCount;

            if (controlPointsCount > 1)
            {
                position = m_controlPoints[m_controlPoints.Length - 1];
                tangent  = position - m_controlPoints[m_controlPoints.Length - 2];
                settings = new ControlPointSettings(m_settings[m_settings.Length - 1]);
            }
            else if (controlPointsCount == 1)
            {
                position = Vector3.forward;
                tangent  = Vector3.forward;
                settings = new ControlPointSettings(m_settings[m_settings.Length - 1]);
            }
            else
            {
                position = Vector3.zero;
                tangent  = Vector3.forward;
                settings = new ControlPointSettings();
            }

            Array.Resize(ref m_controlPoints, m_controlPoints.Length + 1);
            Array.Resize(ref m_settings, m_settings.Length + 1);
            m_controlPoints[m_controlPoints.Length - 1] = position + tangent.normalized * distance;
            m_settings[m_settings.Length - 1]           = settings;

            m_renderer.Refresh(false);
        }
Пример #3
0
        public override int Insert(int segmentIndex, float offset = 0.5f)
        {
            offset = Mathf.Clamp01(offset);
            List <Vector3> controlPoints         = m_controlPoints.ToList();
            List <ControlPointSettings> settings = m_settings.ToList();

            if (IsLooping)
            {
                offset = (segmentIndex + offset) / SegmentsCount;
            }
            else
            {
                if (segmentIndex == ControlPointCount - 2)
                {
                    segmentIndex--;
                }
                offset = (segmentIndex + offset - 1) / SegmentsCount;
            }
            int ctrlPointIndex = segmentIndex + 1;

            controlPoints.Insert(ctrlPointIndex, GetLocalPosition(offset));

            //ControlPointSettings copy = new ControlPointSettings(Settings[segmentIndex]);
            ControlPointSettings defaultSettings = new ControlPointSettings();

            settings.Insert(ctrlPointIndex, defaultSettings);
            m_controlPoints = controlPoints.ToArray();
            m_settings      = settings.ToArray();
            m_renderer.Refresh(false);

            return(ctrlPointIndex);
        }
Пример #4
0
        public override void Prepend(float distance = 0)
        {
            Vector3 position;
            Vector3 tangent;
            ControlPointSettings settings;
            int controlPointsCount = ControlPointCount;

            if (controlPointsCount > 1)
            {
                position = m_controlPoints[0];
                tangent  = position - m_controlPoints[1];
                settings = new ControlPointSettings(m_settings[0]);
            }
            else if (controlPointsCount == 1)
            {
                position = Vector3.back;
                tangent  = Vector3.back;
                settings = new ControlPointSettings(m_settings[0]);
            }
            else
            {
                position = Vector3.zero;
                tangent  = Vector3.back;
                settings = new ControlPointSettings();
            }

            Array.Resize(ref m_controlPoints, m_controlPoints.Length + 1);
            Array.Resize(ref m_settings, m_settings.Length + 1);
            for (int i = m_controlPoints.Length - 1; i > 0; --i)
            {
                m_controlPoints[i] = m_controlPoints[i - 1];
                m_settings[i]      = m_settings[i - 1];
            }
            m_controlPoints[0] = position + tangent.normalized * distance;
            m_settings[0]      = settings;

            m_renderer.Refresh(false);
        }
Пример #5
0
 public override void SetSettings(int index, ControlPointSettings settings)
 {
     m_settings[index] = settings;
 }
Пример #6
0
 public abstract void SetSettings(int index, ControlPointSettings settings);