Ejemplo n.º 1
0
        //copies current rectt values to component of statesitem, method called from custom editor
        public void CopyCurrentComponentValuesToStateListItem(TransformComponents component, int i)
        {
            if (component == TransformComponents.anchoredPosition)
            {
                States[i].AnchoredPosition = _rectt.anchoredPosition;
            }

            if (component == TransformComponents.localScale)
            {
                States[i].LocalScale = _rectt.localScale;
            }

            if (component == TransformComponents.sizeDelta)
            {
                States[i].SizeDelta = _rectt.sizeDelta;
            }

            if (component == TransformComponents.rotation)
            {
                States[i].Rotation = transform.eulerAngles.z;
            }

            if (component == TransformComponents.alpha)
            {
                if (_canvasGroup != null)
                {
                    States[i].Alpha = _canvasGroup.alpha;
                }
            }
        }
Ejemplo n.º 2
0
        //snaps rectt to values of component from statesitem, method called from custom editor
        public void SnapToStateListItemComponentValues(TransformComponents component, int i)
        {
            if (component == TransformComponents.anchoredPosition)
            {
                _rectt.anchoredPosition = States[i].AnchoredPosition;
            }

            if (component == TransformComponents.localScale)
            {
                _rectt.localScale = States[i].LocalScale;
            }

            if (component == TransformComponents.sizeDelta)
            {
                _rectt.sizeDelta = States[i].SizeDelta;
            }

            if (component == TransformComponents.rotation)
            {
                transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, States[i].Rotation);
            }

            if (component == TransformComponents.alpha)
            {
                if (_canvasGroup != null)
                {
                    _canvasGroup.alpha = States[i].Alpha;
                }
            }
        }
Ejemplo n.º 3
0
 public ActorTransformConstraint()
 {
     m_SourceSpace = TransformSpace.World;
     m_DestSpace   = TransformSpace.World;
     m_ComponentsA = new TransformComponents();
     m_ComponentsB = new TransformComponents();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Remove all component data
 /// </summary>
 public void ClearComponents()
 {
     TransformComponents.Clear();
     PhysicsComponents.Clear();
     CollisionComponents.Clear();
     MeshComponents.Clear();
 }
Ejemplo n.º 5
0
        private void RemoveComponentToAnimateFromList(TransformComponents component)
        {
            if (_componentsToAnimate == null)
            {
                _componentsToAnimate = new List <TransformComponents>();
            }

            if (_componentsToAnimate.Contains(component))
            {
                _componentsToAnimate.Remove(component);
            }
        }
Ejemplo n.º 6
0
        private void AddComponentToAnimateToList(TransformComponents component)
        {
            if (_componentsToAnimate == null)
            {
                _componentsToAnimate = new List <TransformComponents>();
            }

            if (!_componentsToAnimate.Contains(component))
            {
                _componentsToAnimate.Add(component);
            }
        }
Ejemplo n.º 7
0
 public ActorRotationConstraint()
 {
     m_Copy        = false;
     m_Scale       = 1.0f;
     m_EnableMin   = false;
     m_EnableMax   = false;
     m_Min         = 0.0f;
     m_Max         = 0.0f;
     m_Offset      = false;
     m_SourceSpace = TransformSpace.World;
     m_DestSpace   = TransformSpace.World;
     m_MinMaxSpace = TransformSpace.World;
     m_ComponentsA = new TransformComponents();
     m_ComponentsB = new TransformComponents();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Resizes all component arrays to contain at least maxSize amount of objects
        /// </summary>
        public void SetComponentArraySize(int maxSize)
        {
            int oldSize = TransformComponents.Length;

            if (maxSize > oldSize)
            {
                TransformComponents.SetSize(maxSize);
                PhysicsComponents.SetSize(maxSize);
                CollisionComponents.SetSize(maxSize);
                MeshComponents.SetSize(maxSize);

                for (int i = oldSize; i < maxSize; i++)
                {
                    // Initialize defaults
                    TransformComponents[i].SetDefaults();
                    CollisionComponents[i].SetDefaults();
                    MeshComponents[i].SetDefaults();
                }
            }
        }
Ejemplo n.º 9
0
        void ConstrainRotation(BoneChain fk, float rotation)
        {
            ActorBone           bone        = fk.m_Bone;
            Mat2D               parentWorld = bone.Parent.WorldTransform;
            Mat2D               transform   = bone.Transform;
            TransformComponents c           = fk.m_TransformComponents;

            if (rotation == 0.0f)
            {
                Mat2D.Identity(transform);
            }
            else
            {
                Mat2D.FromRotation(transform, rotation);
            }
            // Translate
            transform[4] = c.X;
            transform[5] = c.Y;
            // Scale
            float scaleX = c.ScaleX;
            float scaleY = c.ScaleY;

            transform[0] *= scaleX;
            transform[1] *= scaleX;
            transform[2] *= scaleY;
            transform[3] *= scaleY;
            // Skew
            float skew = c.Skew;

            if (skew != 0.0)
            {
                transform[2] = transform[0] * skew + transform[2];
                transform[3] = transform[1] * skew + transform[3];
            }

            Mat2D.Multiply(bone.WorldTransform, parentWorld, transform);
        }
Ejemplo n.º 10
0
 ActorScaleConstraint()
 {
     m_ComponentsA = new TransformComponents();
     m_ComponentsB = new TransformComponents();
 }