예제 #1
0
    public List <int> CheckboxToUser(string message, List <string> choices)
    {
        MainCamera.IsFrozen = true;
        int     pas = 0;
        Vector3 cameraposbis, sp, v;
        Camera  mycam          = MainCamera.GetCamera();
        Vector3 cameraposition =
            MainCamera.GetCameraPosition();
        float x           = cameraposition[0];
        float y           = cameraposition[1];
        float z           = cameraposition[2];
        int   _policysize = 30;

        foreach (string ch  in choices)
        {
            UnityEngine.Debug.Log("Add checkbox choice");
            GameObject newobj = new GameObject(name + ".chkbox.choice");
            newobj.SetActive(false);
            newobj.AddComponent(typeof(TextMesh));
            newobj.AddComponent(typeof(BoxCollider));
            newobj.GetComponent <TextMesh>().fontSize  = _policysize;
            newobj.GetComponent <TextMesh>().fontStyle = FontStyle.Bold;
            newobj.GetComponent <TextMesh>().text      = ch;
            TextMesh    mesh = newobj.GetComponent <TextMesh>();
            BoxCollider box  = newobj.GetComponent <BoxCollider>();
            box.size = new Vector3(GetWidth(mesh), _policysize * 0.1f, 1);
            float xx = (float)(box.center[0] + GetWidth(mesh) * 0.5);
            float yy = (float)(box.center[1] - _policysize * 0.1f * 0.5);
            box.center = new Vector3(xx, yy, box.center[2]);

            cameraposbis = new Vector3(x, y, z);
            UnityEngine.Debug.Log(cameraposbis);
            sp = mycam.ViewportToScreenPoint(cameraposbis);
            v  = mycam.ScreenToWorldPoint(new Vector3(sp[0] - 50, sp[1] + 200 - pas, sp[2] + 50));
            newobj.transform.position = v;
            pas = pas + _policysize + 15;
            newobj.SetActive(true);
        }

        return(null);
    }