Ejemplo n.º 1
0
    void OnMouseDown()
    {
        GameObject red_light = GameObject.Find("Directional light");
        Light      red       = red_light.GetComponent <Light> ();

        if (red.intensity != 0)
        {
            GameObject carl_spine = GameObject.Find("Spine2");
            float      m_x        = carl_spine.transform.localEulerAngles.x;
            float      m_y        = carl_spine.transform.localEulerAngles.y;
            float      m_z        = carl_spine.transform.localEulerAngles.z;

            AndroidPluginManager.GetInstance().CallMessageDialog(m_x, m_y, m_z);
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (this.isSwing == true)
        {
            GameObject carl_spine = GameObject.Find("Spine");
            carl_spine.transform.localEulerAngles = new Vector3(60 * Mathf.Sin(Time.realtimeSinceStartup), 1, 60 * Mathf.Cos(Time.realtimeSinceStartup));
            // carl_spine.transform.Rotate (60*Mathf.Sin(Time.realtimeSinceStartup), 0, Mathf.Cos(Time.realtimeSinceStartup));
        }
        else
        {
            GameObject carl_spine = GameObject.Find("Spine2");

            string data = AndroidPluginManager.GetInstance().getData();
            if (data != null)
            {
                string[] result = data.Split(' ');

                float resultZ = System.Convert.ToSingle(result[0]);
                float resultX = System.Convert.ToSingle(result[1]) * -1;
                float resultY = System.Convert.ToSingle(result[2]);

                carl_spine.transform.localEulerAngles = new Vector3(resultX, resultY, resultZ);
            }

            GameObject red_light = GameObject.Find("Directional light");
            Light      red       = red_light.GetComponent <Light> ();
            if (isWrongAngle(carl_spine))
            {
                red.intensity = 10;
            }
            else
            {
                red.intensity = 0;
            }
        }
    }