Example #1
0
        void Awake()
        {
            // create range sliders
            // slider
            GameObject rangeSliderPrefab = Resources.Load <GameObject>("VPET/Prefabs/RangeTemplate");

            if (rangeSliderPrefab == null)
            {
                Debug.LogError(string.Format("{0}: Cannot load: RangeTemplate.", this.GetType()));
            }
            else
            {
                // intensity
                GameObject sliderInstance = Instantiate(rangeSliderPrefab);
                sliderInstance.name = rangeSliderPrefab.name;
                sliderInstance.transform.SetParent(this.transform, false);
                sliderInstance.transform.localPosition = new Vector3(0, (-VPETSettings.Instance.canvasHalfHeight + 2 * UI.ButtonOffset) * VPETSettings.Instance.canvasAspectScaleFactor, 0);
                sliderInstance.transform.localScale    = Vector3.one;
                slider = sliderInstance.GetComponent <RangeSlider>();

                /*
                 *  // range
                 *  sliderInstance = Instantiate(rangeSliderPrefab);
                 *  sliderInstance.name = rangeSliderPrefab.name + "_range";
                 *  sliderInstance.transform.parent = this.transform;
                 *  sliderInstance.transform.localPosition = new Vector3(100, 0, 0);
                 *  sliderInstance.transform.localScale = Vector3.one;
                 *  rangeSlider = sliderInstance.GetComponent<RangeSlider>();
                 *  rangeSlider.Callback = this.updateRange;
                 *
                 *  // angle
                 *  sliderInstance = Instantiate(rangeSliderPrefab);
                 *  sliderInstance.name = rangeSliderPrefab.name + "_angle";
                 *  sliderInstance.transform.parent = this.transform;
                 *  sliderInstance.transform.localPosition = new Vector3(400, 0, 0);
                 *  sliderInstance.transform.localScale = Vector3.one;
                 *  angleSlider = sliderInstance.GetComponent<RangeSlider>();
                 *  angleSlider.MaxValue = 179f;
                 *  angleSlider.Callback = this.updateAngle;
                 */
            }

            // color wheel
            GameObject colorWheelPrefab = Resources.Load <GameObject>("VPET/ColorWheelTemplate");

            if (colorWheelPrefab == null)
            {
                Debug.LogError(string.Format("{0}: Cannot load: ColorWheelTemplate.", this.GetType()));
            }
            else
            {
                GameObject colorWheelInstance = Instantiate(colorWheelPrefab);
                colorWheelInstance.transform.SetParent(this.transform, false);
                colorWheelInstance.transform.localPosition = new Vector3(-VPETSettings.Instance.canvasHalfWidth + 250, (-VPETSettings.Instance.canvasHalfHeight + 250) * VPETSettings.Instance.canvasAspectScaleFactor, 0);
                colorWheelInstance.transform.localScale    = 4 * Vector3.one;
                colorWheel          = colorWheelInstance.GetComponent <ColorWheel>();
                colorWheel.Callback = this.updateColor;
            }
        }
Example #2
0
 void Awake()
 {
     // get color wheel
     colorWheel = transform.GetComponentInChildren <ColorWheel>();
     if (colorWheel == null)
     {
         Debug.LogWarning(string.Format("{0}: Cant Find Component in Canvas: ColorWheel.", this.GetType()));
     }
     else
     {
         colorWheel.Callback = this.updateColor;
     }
 }
Example #3
0
	    void Awake()
		{
            doLoadFromResource = true;
            // Submit button
            Transform childWidget = this.transform.Find("Start_button");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: Start_button.", this.GetType()));
            else
            {
				submitButton = childWidget.GetComponent<Button>();
				if (submitButton == null) Debug.LogError(string.Format("{0}: Cant Component: Button.", this.GetType()));
                else
                {
					submitButton.onClick.RemoveAllListeners();
					submitButton.onClick.AddListener(() => OnSubmit());
                }
            }

			// Textfield Server IP
			childWidget = this.transform.Find("ServerIP_field");
			if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ServerIP_field.", this.GetType()));
			else
			{
				serverIPField = childWidget.GetComponent<InputField>();
				if (serverIPField == null) Debug.LogError(string.Format("{0}: Cant Component: InputField.", this.GetType()));
			}


			// debug toggle
            childWidget = this.transform.Find("Debug_toggle");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: Debug_toggle.", this.GetType()));
            else
            {
				debugToggle = childWidget.GetComponent<Toggle>();
				if (debugToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
                else
                {
                    debugToggle.onValueChanged.AddListener(this.OnToggleDebug);
                }
            }

            // grid toggle
            childWidget = this.transform.Find("Grid_toggle");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: Grid_toggle.", this.GetType()));
            else
            {
                gridToggle = childWidget.GetComponent<Toggle>();
                if (gridToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
                else
                {
                    gridToggle.onValueChanged.AddListener(this.OnToggleGrid);
                }
            }

            // ar toggle
            childWidget = this.transform.Find("AR_toggle");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: AR_toggle.", this.GetType()));
            else
            {

#if USE_TANGO || USE_ARKIT
                arToggle = childWidget.GetComponent<Toggle>();
                if (arToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
                else
                {
                    arToggle.onValueChanged.AddListener(this.OnToggleAr);
                }
#else
                childWidget.gameObject.SetActive(false);
#endif
            }

            // showCameras toggle
            childWidget = this.transform.Find("ShowCam_toggle");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ShowCam_toggle.", this.GetType()));
            else
            {
                showCamToggle = childWidget.GetComponent<Toggle>();
                if (showCamToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
                else
                {
                    showCamToggle.onValueChanged.AddListener(this.OnToggleCamera);
                }
            }


            // ar key toggle
            childWidget = this.transform.Find("ARKey_toggle");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ARKey_toggle.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arKeyToggle = childWidget.GetComponent<Toggle>();
                if (arKeyToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
                else
                {
                    arKeyToggle.onValueChanged.AddListener(this.OnToggleArKey);
                }
#endif
                // hide by default
                childWidget.gameObject.SetActive(false);
            }

            // ar matte toggle
            childWidget = this.transform.Find("ARMatte_toggle");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ARMatte_toggle.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arMatteToggle = childWidget.GetComponent<Toggle>();
                if (arMatteToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
                else
                {
                    arMatteToggle.onValueChanged.AddListener(this.OnToggleMatte);
                }

#endif
                // hide by default
                childWidget.gameObject.SetActive(false);
            }

            //ar color picker button
            childWidget = this.transform.Find("ARKeyPick_button");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ARKeyPick_button.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arColorPickerButton = childWidget.GetComponent<Button>();
                if (arColorPickerButton == null) Debug.LogError(string.Format("{0}: Cant Component: Button.", this.GetType()));
#endif
                // hide by default
                childWidget.gameObject.SetActive(false);
            }


            // ar video plane
            arKeyVideoPlane = this.transform.Find("../ARVideoPlane");
            if (arKeyVideoPlane == null) Debug.LogError(string.Format("{0}: Cant Find: ARColorPlane.", this.GetType()));
            else
            {
                // hide by default
                arKeyVideoPlane.gameObject.SetActive(false);
            }


            // ar color picker plane
            childWidget = this.transform.Find("../ARColorPlane");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ARColorPlane.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arColorPicker = childWidget.GetComponent<ColorPicker>();
                if (arColorPicker == null) Debug.LogError(string.Format("{0}: Cant Component: ColorPicker.", this.GetType()));
                else
                {
                    arColorPicker.Callback = this.OnKeyColorChanged;
                }
#endif
            }


            // ar video color wheel
            childWidget = this.transform.Find("../ARKeyWidget/ARColorWheel");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ARColorWheel.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arColorWheel = childWidget.GetComponent<ColorWheel>();
                if (arColorWheel == null) Debug.LogError(string.Format("{0}: Cant Component: ColorWheel.", this.GetType()));
                else
                {
                    arColorWheel.Callback = this.OnKeyColorChanged;
                }
#endif
                // hide by default
                childWidget.gameObject.SetActive(false);
            }

            // ar color field
            childWidget = this.transform.Find("../ARKeyWidget/ColorField");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: ColorField.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arColorField = childWidget.GetComponent<Image>();
                if (arColorField == null) Debug.LogError(string.Format("{0}: Cant Component: Image.", this.GetType()));
#endif                
                
            }

            // ar video radius slider
            childWidget = this.transform.Find("../ARKeyWidget/KeyRadiusSlider/KeyRadius_Slider");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: KeyRadiusSlider.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arkeyRadiusSlider = childWidget.GetComponent<Slider>();
                if (arkeyRadiusSlider == null) Debug.LogError(string.Format("{0}: Cant Component: Slider.", this.GetType()));
                else
                {
                    arkeyRadiusSlider.onValueChanged.AddListener( this.OnKeyRadiusChanged);
                }
#endif
            }

            // ar video threshold slider
            childWidget = this.transform.Find("../ARKeyWidget/KeyThresholdSlider/KeyThreshold_Slider");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: KeyThresholdSlider.", this.GetType()));
            else
            {
#if USE_TANGO || USE_ARKIT
                arkeyThresholdSlider = childWidget.GetComponent<Slider>();
                if (arkeyThresholdSlider == null) Debug.LogError(string.Format("{0}: Cant Component: Slider.", this.GetType()));
                else
                {
                    arkeyThresholdSlider.onValueChanged.AddListener( this.OnKeyThresholdChanged);
                }
#endif
            }


            // Cache Load Local
            childWidget = this.transform.Find("LoadCache_toggle");
            if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: LoadCache_toggle.", this.GetType()));
            else
            {
                loadCacheToggle = childWidget.GetComponent<Toggle>();
                if (loadCacheToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
            }

			// Checkbox Load Texture
			childWidget = this.transform.Find("LoadTextures_toggle");
			if (childWidget == null) Debug.LogError(string.Format("{0}: Cant Find: LoadTextures_toggle.", this.GetType()));
			else
			{
				loadTexturesToggle = childWidget.GetComponent<Toggle>();
				if (loadTexturesToggle == null) Debug.LogError(string.Format("{0}: Cant Component: Toggle.", this.GetType()));
			}

			// ambient intensity
			childWidget = this.transform.Find("AI_Slider/Ambient_slider");
			if (childWidget == null) Debug.LogWarning(string.Format("{0}: Cant Find: Ambient_slider.", this.GetType()));
			else
			{
				ambientIntensitySlider = childWidget.GetComponent<Slider>();
				if (ambientIntensitySlider == null) Debug.LogWarning(string.Format("{0}: Cant Component: Slider.", this.GetType()));
				else
				{
					ambientIntensitySlider.value = ambientLight;
					ambientIntensitySlider.onValueChanged.AddListener( this.OnAmbientChanged );
				}
			}

            // controller speed
            childWidget = this.transform.Find("CS_Slider/ControllerSpeed_slider");
            if (childWidget == null) Debug.LogWarning(string.Format("{0}: Cant Find: ControllerSpeed.", this.GetType()));
            else
            {
                controllerSpeedSlider = childWidget.GetComponent<Slider>();
                if (controllerSpeedSlider == null) Debug.LogWarning(string.Format("{0}: Cant Component: Slider.", this.GetType()));
                else
                {
                    if(VPETSettings.Instance.controllerSpeed <= 1)
                        controllerSpeedSlider.value = (VPETSettings.Instance.controllerSpeed-0.25f)/ 1.5f;
                    else
                        controllerSpeedSlider.value = (VPETSettings.Instance.controllerSpeed + 23f) /48f;
                    controllerSpeedSlider.onValueChanged.AddListener(this.onControllerSpeedChanged);
                }
            }

        }