Exemplo n.º 1
0
    // Show action settings popup
    public ActionPopup ShowActionPopup(string actionName, List <string> paramNames, List <int> paramValues, List <int> paramMins, List <int> paramMaxs)
    {
        // Reset action popup first
        HideActionPopup(false);

        actionPopupRef.GetComponent <ActionPopup>().headerRef.text = actionName;
        ActionPopup actionPopup = actionPopupRef.GetComponent <ActionPopup>();

        // Add parameter settings for this action type
        for (int i = 0; i < paramValues.Count; i++)
        {
            GameObject newParamObj = GameObject.Instantiate(actionPopup.parameterPrefab);
            newParamObj.transform.SetParent(actionPopup.parametersRef.transform, false);
            Vector3 pos = newParamObj.GetComponent <RectTransform>().anchoredPosition3D;
            pos.y = actionPopup.paramStartY + (i * actionPopup.paramIntervalY);
            newParamObj.GetComponent <RectTransform>().anchoredPosition3D = pos;

            ActionParameter ap = newParamObj.GetComponent <ActionParameter>();
            ap.SetParamIndex(i);
            ap.paramName = paramNames[i];

            // Set limits of value
            ap.sliderRef.minValue = paramMins[i];
            ap.sliderRef.maxValue = paramMaxs[i];

            // Set value and update header
            ap.sliderRef.value = paramValues[i];
            ap.UpdateHeader();
        }

        actionPopupRef.SetActive(true);

        actionPopupRef.AddComponent <VRTK.VRTK_UIGraphicRaycaster>();

        return(actionPopup);
    }