void Update()
    {
        if (isFindingArea)
        {
            rays.Clear();

            if (Input.GetMouseButtonDown(0))
            {
                var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                //NOTE(Simon): Add both directions, because winding order determines from wich direction a mesh can collide
                rays.Add(ray);
                rays.Add(ray.ReverseRay());
            }

            for (int i = 0; i < controllers.Length; i++)
            {
                if (controllers[i].triggerPressed)
                {
                    var ray = controllers[i].CastRay();
                    //NOTE(Simon): Add both directions, because winding order determines from wich direction a mesh can collide
                    rays.Add(ray);
                    rays.Add(ray.ReverseRay());
                }
            }

            AreaRenderer target = null;
            for (int i = 0; i < rays.Count; i++)
            {
                if (Physics.Raycast(rays[i], out var hit, Mathf.Infinity, LayerMask.GetMask("Area")))
                {
                    target = hit.transform.GetComponent <AreaRenderer>();
                    break;
                }
            }

            if (target != null)
            {
                for (int i = 0; i < areaRenderers.Count; i++)
                {
                    var areaRenderer = areaRenderers[i].GetComponent <AreaRenderer>();
                    areaRenderer.EnableRenderer();
                    areaRenderer.DisableCollider();

                    if (i != correct)
                    {
                        areaRenderer.SetColor(incorrectBackground, incorrectOutline);
                    }
                }

                player.UnsuspendInteractionPoint();

                startButton.gameObject.SetActive(false);
                result.gameObject.SetActive(true);

                isFindingArea = false;
                completed     = true;
            }
        }
    }
Пример #2
0
    void Awake()
    {
        AreaLayer = LayerMask.NameToLayer("Area");

        goContainer = new GameObject("goContainer");

        indicator       = NewPoint(Vector3.zero);
        indicator.name  = "indicator";
        indicator.layer = 0;
        Destroy(indicator.GetComponent <SphereCollider>());

        areaRenderer = Instantiate(areaRendererPrefab).GetComponent <AreaRenderer>();

        MouseLook.Instance.forceActive = true;
    }
        protected override void CreateChildControls()
        {
            // Persist last item

            _ActiveItem.ID = "OfficeWebUI_Workspace_LastItem";
            this.Controls.Add(_ActiveItem);

            String lScript_ActiveItem = "var OfficeWebUI_Workspace_LastItem = \"" + _ActiveItem.ClientID + "\";\n";

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OfficeWebUI.Workspace.LastItem", lScript_ActiveItem, true);


            // Persist last area

            _ActiveArea.ID = "OfficeWebUI_Workspace_LastArea";
            this.Controls.Add(_ActiveArea);

            String lScript_ActiveArea = "var OfficeWebUI_Workspace_LastArea = \"" + _ActiveArea.ClientID + "\";\n";

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OfficeWebUI.Workspace.LastArea", lScript_ActiveArea, true);



            foreach (Area lAreaSrc in this._areas)
            {
                AreaRenderer lArea = new AreaRenderer(lAreaSrc, this._navContainer);
                _areasContainer.Controls.Add(lArea);
            }



            /* Support Async page load caused by Ajax, so try to find a ScriptManager */

            Boolean isUsingAjax = false;

            foreach (Control lctrl in Page.Form.Controls)
            {
                if (lctrl.GetType().ToString() == "System.Web.UI.ScriptManager")
                {
                    isUsingAjax = true;
                }
            }

            if (isUsingAjax)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "OfficeWebUI.Workspace.AjaxPageLoadSupport", "<script>try { Sys.Application.add_load(OfficeWebUI.Workspace._AjaxLoadSupport); } catch(e) { alert(e); }</script>");
            }
        }