Beispiel #1
0
        public void SetColor(string name, Color value)
        {
            curve.FireBeforeChange(BGCurve.EventPointField);

            PrivateValuesForFields.colorValues[curve.IndexOfFieldValue(name)] = value;

            curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this);
        }
Beispiel #2
0
        public void SetField(string name, object value, Type type)
        {
            curve.FireBeforeChange(BGCurve.EventPointField);

            BGCurvePoint.FieldTypes.SetField(curve, type, name, value, PrivateValuesForFields);

            curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this);
        }
Beispiel #3
0
        //set local position
        private void SetPosition(Vector3 value, bool worldSpaceIsUsed = false)
        {
            curve.FireBeforeChange(BGCurve.EventPointPosition);

            //snapping
            if (curve.SnapType != BGCurve.SnapTypeEnum.Off)
            {
                if (worldSpaceIsUsed)
                {
                    curve.ApplySnapping(ref value);
                }
                else
                {
                    //we need to transfer space before applying snapping
                    var pos = curve.transform.TransformPoint(value);
                    if (curve.ApplySnapping(ref pos))
                    {
                        value = curve.transform.InverseTransformPoint(pos);
                    }
                }
            }


            //assign position
            if (pointTransform == null)
            {
                if (worldSpaceIsUsed)
                {
                    var localPos = curve.transform.InverseTransformPoint(value);
                    if (curve.Mode2D != BGCurve.Mode2DEnum.Off)
                    {
                        localPos = curve.Apply2D(localPos);
                    }
                    positionLocal = localPos;
                }
                else
                {
                    if (curve.Mode2D != BGCurve.Mode2DEnum.Off)
                    {
                        value = curve.Apply2D(value);
                    }
                    positionLocal = value;
                }
            }
            else
            {
                //2d mode with curve's transform changed is not working correctly
                if (curve.Mode2D != BGCurve.Mode2DEnum.Off)
                {
                    value = curve.Apply2D(value);
                }
                pointTransform.position = worldSpaceIsUsed ? value : curve.transform.TransformPoint(value);
            }

            curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointPosition) : null, sender: this);
        }
Beispiel #4
0
        /// <summary> Fires Changed event if some conditions are met </summary>
        public void FireChange(BGCurveChangedArgs change, bool ignoreEventsGrouping = false)
        {
            if (eventMode == EventModeEnum.NoEvents || Changed == null) return;

            if (transactionLevel > 0 || (eventMode != EventModeEnum.Immediate && !ignoreEventsGrouping))
            {
                changed = true;
                if (UseEventsArgs && !ChangeList.Contains(change)) ChangeList.Add(change);
                return;
            }

            Changed(this, UseEventsArgs ? change : null);
        }
Beispiel #5
0
        //set local control 2 (it's basically copy/paste from SetControlFirstLocal, but we can not use delegates here because of performance)
        private void SetControlSecondLocal(Vector3 value)
        {
            curve.FireBeforeChange(BGCurve.EventPointControl);

            if (curve.Mode2D != BGCurve.Mode2DEnum.Off)
            {
                value = curve.Apply2D(value);
            }

            if (controlType == BGCurvePoint.ControlTypeEnum.BezierSymmetrical)
            {
                controlFirstLocal = -value;
            }

            controlSecondLocal = value;
            curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointControl) : null, sender: this);
        }
Beispiel #6
0
 protected bool Equals(BGCurveChangedArgs other)
 {
     return(changeType == other.changeType && Equals(curve, other.curve) && Equals(point, other.point));
 }