コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        // Detect and handle pause via key press (for testing)
        if (Input.GetKeyDown(KeyCode.P))
        {
            if (Time.timeScale == 1)
            {
                Time.timeScale = 0;
                showPaused();
            }
            else if (Time.timeScale == 0)
            {
                Time.timeScale = 1;
                hidePaused();
            }
        }


        // Update UI if phase has changed
        // For some reason, it doesn't seem to work to put the following two lines in Start(), they seem to need to be redone here

        VisibilityControllerScript visibilityControllerScript = segContainer.GetComponent <VisibilityControllerScript>();

        //VisibilityControllerScript visibilityControllerScript= segConObj.GetComponent<VisibilityControllerScript>();
        if (visibilityControllerScript.currentPhaseIndex != currentPhaseIndex)
        {
            currentPhaseIndex = visibilityControllerScript.currentPhaseIndex;
            updateFrameSlider();
            updateFrameText();
        }
    }
コード例 #2
0
    void SliderValueChanged()
    {
        // Force user change of slider value to change the displayed phase
        int currentPhaseIndex = (int)frameSlider.value;
        VisibilityControllerScript visibilityControllerScript = segContainer.GetComponent <VisibilityControllerScript>();

        visibilityControllerScript.ChangeCurrentPhaseIndex(currentPhaseIndex);
    }
コード例 #3
0
    void RegionCheckboxChanged()
    {
        // Scan checkbox boolean values and apply them to _vis flags in visibility controller script

        VisibilityControllerScript visibilityControllerScript = segContainer.GetComponent <VisibilityControllerScript>();


        for (int ind = 0; ind < regionToggleObjs.Length; ind++)
        {
            // Find the corresponding visibility boolean flag and set it to match
            GameObject curToggleObj     = regionToggleObjs[ind];
            Toggle     ToggleComponent  = curToggleObj.GetComponent <Toggle>();
            bool       isChecked        = ToggleComponent.isOn;
            string     regionToggleName = curToggleObj.name;

            // Set the matching visibiility flag
            // NB: This is incredibily clunky and badly fragile, but it is the only easy way to structure it that I
            // can figure out right now.  Ideally, there would be a much better way to ensure conformance between the
            // checkbox being clicked and the visibility flag being set.  This method relies on a a fixed, hard-coded
            // ordering of the regions, as well as hard-coded names for the regions.  This should most certainly be
            // refactored later!!!  TODO
            // TODO TODO TODO!!
            // Update: Slightly better now, at least relies on name matching between name of toggle and visibility field name
            switch (regionToggleName)
            {
            case "ToggleLA":
                visibilityControllerScript.LA_vis = isChecked;
                break;

            case "ToggleLV":
                visibilityControllerScript.LV_vis = isChecked;
                break;

            case "ToggleAorta":
                visibilityControllerScript.Ao_vis = isChecked;
                break;

            case "ToggleRA":
                visibilityControllerScript.RA_vis = isChecked;
                break;

            case "ToggleRV":
                visibilityControllerScript.RV_vis = isChecked;
                break;

            case "TogglePA":
                visibilityControllerScript.PA_vis = isChecked;
                break;

            default:
                Debug.LogError("Did not match a case in region flag checking!");
                break;
            }
        }
        // Trigger visibility update even if animation is currently paused
        visibilityControllerScript.ChangeCurrentPhaseIndex(currentPhaseIndex);
    }