/// <summary>
    /// Before animation starts use text file animation rule to setup gear orientation
    /// </summary>
    /// <param name="rotateAxis"></param>
    /// <param name="angleOffset"></param>
    /// <param name="children"></param>
    public void GearSetup(Vector3 rotateAxis, float angleOffset, Transform[] children)
    {
        //children = gameObject.GetComponentsInChildren<Transform>();

        GearControl gearSource = children[1].GetComponent <GearControl>();

        gearSource.rotateAxis = rotateAxis;
        gearSource.clockwise  = false;
        gearSource.speed      = float.Parse(CustomFunction_Gear.speed);

        for (int i = 2; i < children.Length; i++)
        {
            //totOffset += angleOffset;
            //children[i].Rotate(Vector3.right, totOffset);
            //gearSource = children[i-1].GetComponent<GearControl>();
            GearControl gear = children[i].GetComponent <GearControl>();
            if (gear.reference != null)
            {
                gear.clockwise = !gear.reference.clockwise;
                if (gear.clockwise)
                {
                    children[i].Rotate(Vector3.right, angleOffset);
                }

                gear.speed      = float.Parse(CustomFunction_Gear.speed);
                gear.rotateAxis = !gear.reference.clockwise ? -rotateAxis : rotateAxis;
            }
            else
            {
                Debug.LogError("Gear " + i + "is missing reference gear!");
            }
        }
    }
    /// <summary>
    /// Before animation starts use text file animation rule to setup gear orientation
    /// </summary>
    /// <param name="rotateAxis"></param>
    /// <param name="angleOffset"></param>
    /// <param name="children"></param>
    public void GearSetup(Vector3 rotateAxis, float angleOffset, Transform[] children)
    {
        //children = gameObject.GetComponentsInChildren<Transform>();

        GearControl gearSource = children[1].GetComponent <GearControl>();

        gearSource.rotateAxis = rotateAxis;
        gearSource.clockwise  = false;
        if (animeReady)
        {
            if (SelectObject.combinationName == "Transmission")
            {
                gearSource.speed = float.Parse(CustomFunction_Transmission.speed2);
            }
            else
            {
                gearSource.speed = float.Parse(CustomFunction_Gear.speed);
            }
        }
        else
        {
            gearSource.speed = 0;
        }


        for (int i = 2; i < children.Length; i++)
        {
            GearControl gear = children[i].GetComponent <GearControl>();
            if (gear.reference != null)
            {
                gear.clockwise = !gear.reference.clockwise;
                if (gear.clockwise)
                {
                    children[i].Rotate(rotateAxis, angleOffset);
                }

                if (animeReady)
                {
                    if (SelectObject.combinationName == "Transmission")
                    {
                        float gear_ratio = gear.reference.teeth / gear.teeth;
                        gear.speed = gear_ratio * float.Parse(CustomFunction_Transmission.speed2);
                    }
                    else
                    {
                        gear.speed = float.Parse(CustomFunction_Gear.speed);
                    }
                }
                else
                {
                    gear.speed = 0;
                }
                gear.rotateAxis = !gear.reference.clockwise ? -rotateAxis : rotateAxis;
            }
            else
            {
                Debug.LogError("Gear " + i + " is missing reference gear!");
            }
            if (SelectObject.combinationName == "Transmission")
            {
                speedTransmission = gear.speed;
            }
        }
    }