protected void Start()
        {
            switch (m_UIType)
            {
            case UIType.Text:
                m_Text = this.GetComponent <UnityEngine.UI.Text>();
                break;

            case UIType.Image:
                m_Image = this.GetComponent <UnityEngine.UI.Image>();
                break;

            case UIType.RawImage:
                m_RawImage = this.GetComponent <UnityEngine.UI.RawImage>();
                break;

            case UIType.Button:
                m_Button = this.GetComponent <UnityEngine.UI.Button>();
                m_Button.onClick.AddListener(ButtonOnClick);
                break;

            case UIType.Toggle:
                m_Toggle = this.GetComponent <UnityEngine.UI.Toggle>();
                m_Toggle.onValueChanged.AddListener(delegate { ToggleValueChanged(m_Toggle); });
                break;

            case UIType.Dropdown:
                m_Dropdown = GetComponent <UnityEngine.UI.Dropdown>();
                m_Dropdown.onValueChanged.AddListener(DropdownValueChanged);
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        public UINode DrawLayer(Layer layer, UINode parent)
        {
            UINode node = PSDImportUtility.InstantiateItem(PSDImporterConst.PREFAB_PATH_TOGGLE, layer.name, parent);// GameObject.Instantiate(temp) as UnityEngine.UI.Toggle;

            UnityEngine.UI.Toggle toggle = node.InitComponent <UnityEngine.UI.Toggle>();
            if (layer.images != null)
            {
                for (int imageIndex = 0; imageIndex < layer.images.Length; imageIndex++)
                {
                    Image  image     = layer.images[imageIndex];
                    string lowerName = image.name.ToLower();
                    if (lowerName.StartsWith("b_"))
                    {
                        PSDImportUtility.SetPictureOrLoadColor(image, toggle.targetGraphic);
                        PSDImportUtility.SetRectTransform(image, toggle.GetComponent <RectTransform>());
                    }
                    else if (lowerName.StartsWith("m_"))
                    {
                        PSDImportUtility.SetPictureOrLoadColor(image, toggle.graphic);
                    }
                    else
                    {
                        ctrl.DrawImage(image, node);
                    }
                }
            }
            return(node);
        }
Esempio n. 3
0
        int UnityEngineUIToggleGroup_m_NotifyToggleOn(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            UnityEngine.UI.ToggleGroup gen_to_be_invoked = (UnityEngine.UI.ToggleGroup)translator.FastGetCSObj(L, 1);

            if (gen_param_count == 3 && translator.Assignable <UnityEngine.UI.Toggle>(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3))
            {
                UnityEngine.UI.Toggle _toggle = (UnityEngine.UI.Toggle)translator.GetObject(L, 2, typeof(UnityEngine.UI.Toggle));
                bool _sendCallback            = LuaAPI.lua_toboolean(L, 3);

                gen_to_be_invoked.NotifyToggleOn(_toggle, _sendCallback);



                return(0);
            }
            if (gen_param_count == 2 && translator.Assignable <UnityEngine.UI.Toggle>(L, 2))
            {
                UnityEngine.UI.Toggle _toggle = (UnityEngine.UI.Toggle)translator.GetObject(L, 2, typeof(UnityEngine.UI.Toggle));

                gen_to_be_invoked.NotifyToggleOn(_toggle);



                return(0);
            }


            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.UI.ToggleGroup.NotifyToggleOn!"));
        }
        private void Update()
        {
            UpdateMovement();
            UpdateMouseLook();
            if (Flashlight != null && WeatherMakerLightManagerScript.Instance != null)
            {
                if (Input.GetKeyDown(KeyCode.F))
                {
                    // hack: Bug in Unity, doesn't recognize that the light was enabled unless we rotate the camera
                    transform.Rotate(0.0f, 0.01f, 0.0f);
                    transform.Rotate(0.0f, -0.01f, 0.0f);

                    Flashlight.enabled = !Flashlight.enabled;
                    GameObject toggleObj = GameObject.Find("FlashlightCheckbox");
                    if (toggleObj != null)
                    {
                        UnityEngine.UI.Toggle toggle = toggleObj.GetComponent <UnityEngine.UI.Toggle>();
                        if (toggle != null)
                        {
                            toggle.isOn = !toggle.isOn;
                        }
                    }
                }
                WeatherMakerLightManagerScript.Instance.AddLight(Flashlight);
            }
        }
Esempio n. 5
0
        // ------------------------------------------------

        void AnimateToggle(UnityEngine.UI.Toggle toggle, bool isOn, float animDuration = 0.36f)
        {
            Color interactiveCol           = ColorThemeData.Instance.interactionColor;
            Color onButNotInteractiveColor = new Color(interactiveCol.r, interactiveCol.g, interactiveCol.b, 0.25f);

            Color bgCol = toggle.isOn
                ? (toggle.interactable ? interactiveCol : onButNotInteractiveColor)
                : new Color(0.632f, 0.632f, 0.632f);

            toggle.targetGraphic.DOColor(bgCol, animDuration);

            // Transform toggleKnob = toggle.targetGraphic.transform.GetChild(0);
            Transform     toggleKnob    = toggle.transform.GetChild(0).transform.GetChild(0);
            RectTransform rectTransform = toggleKnob.GetComponent <RectTransform>();

            rectTransform.DOAnchorPos3DX(endValue: isOn ? 32 : -32, duration: animDuration).SetEase(Ease.InOutExpo);

            // Debug.Log(rectTransform);
            // float toggleKnobX = toggleKnob.GetComponent<RectTransform>().anchoredPosition3D.x;
            // off=-32, on=32
            // toggleKnob.DOLocalMoveX(endValue: isOn ? 32 : -32, duration: animDuration)
            // .SetEase(Ease.InOutExpo);


            // rectTransform.anchoredPosition3D = new Vector3(isOn ? 32 : -32, 0, 0);
            // rectTransform.anchoredPosition = new Vector2(isOn ? 32 : -32, 0);
        }
Esempio n. 6
0
 protected override void OnInit()
 {
     base.OnInit();
     tog = GetComponent <UnityEngine.UI.Toggle>();
     AddClickCallBack(OnClick);
     AddLongPressEndCallBack(OnPressEndClick);
 }
Esempio n. 7
0
        int UnityEngineUIToggle_g_get_onValueChanged(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;

            UnityEngine.UI.Toggle gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
            translator.Push(L, gen_to_be_invoked.onValueChanged);
            return(1);
        }
Esempio n. 8
0
        int UnityEngineUIToggle_g_get_isOn(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;

            UnityEngine.UI.Toggle gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
            LuaAPI.lua_pushboolean(L, gen_to_be_invoked.isOn);
            return(1);
        }
Esempio n. 9
0
 private void InitializeToggle(UnityEngine.UI.Toggle toggle, UnityEngine.Events.UnityAction <bool> valueChangedHandler)
 {
     // Set the current settings
     valueChangedHandler(toggle.isOn);
     // Add listeners
     toggle.onValueChanged.AddListener(valueChangedHandler);
     toggle.onValueChanged.AddListener(PlayToggleSound);
 }
Esempio n. 10
0
 private void Awake()
 {
     toggle = GetComponent <UnityEngine.UI.Toggle>();
     if (toggle != null)
     {
         toggle.onValueChanged.AddListener(SetValue);
     }
 }
Esempio n. 11
0
        int UnityEngineUIToggle_s_set_onValueChanged(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;

            UnityEngine.UI.Toggle gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
            gen_to_be_invoked.onValueChanged = (UnityEngine.UI.Toggle.ToggleEvent)translator.GetObject(L, 2, typeof(UnityEngine.UI.Toggle.ToggleEvent));

            return(0);
        }
Esempio n. 12
0
        int UnityEngineUIToggle_s_set_graphic(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;

            UnityEngine.UI.Toggle gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
            gen_to_be_invoked.graphic = (UnityEngine.UI.Graphic)translator.GetObject(L, 2, typeof(UnityEngine.UI.Graphic));

            return(0);
        }
Esempio n. 13
0
        void SetTriggerVisualInteractiveState(UnityEngine.UI.Toggle toggle, bool interactable, bool isOn)
        {
            Color bgCol = bgColorForToggle(toggle.interactable, isOn);

            toggle.targetGraphic.color = bgCol;

            // UnityEngine.UI.Image knobImage = toggle.transform.GetChild(0).transform.GetChild(0).GetComponent<UnityEngine.UI.Image>();
            // knobImage.color = toggle.interactable ? Color.white : new Color(0.8f, 0.8f, 0.8f);
        }
Esempio n. 14
0
        void Start()
        {
            doState          = new state[] { Sleep, Resolutions, Fullscreen, Quality, Accept, Exit };
            resolutionBar    = resolution;
            qualityBar       = quality;
            fullscreenButton = fullscreen;
            resText          = resolutionText;
            qualText         = qualityText;
            List <Resolution> temp = new List <Resolution>();
            double            num  = 0;

            foreach (Resolution r in Screen.resolutions)
            {
                num = r.width / 16.0;
                if ((double)(r.height) / num - 9 < 1 && (double)(r.height) / num - 9 > -1)
                {
                    temp.Add(r);
                }
            }
            if (temp.Count == 0)
            {
                temp.Add(Screen.resolutions[0]);
            }
            res = temp.ToArray();
            touchedResolution      = true;
            touchedFullscreen      = true;
            touchedQuality         = true;
            resolutionBar.minValue = 0;
            resolutionBar.maxValue = res.Length - 1;
            qualityBar.minValue    = 0;
            qualityBar.maxValue    = QualitySettings.names.Length - 1;
            if (PlayerPrefs.HasKey(videoHash + 0))
            {
                if (PlayerPrefs.GetInt(videoHash + 0) >= res.Length)
                {
                    resolutionBar.value = 0;
                    PlayerPrefs.SetInt(videoHash + 0, 0);
                }
                else
                {
                    resolutionBar.value = PlayerPrefs.GetInt(videoHash + 0);
                }
                fullscreen.isOn  = (PlayerPrefs.GetInt(videoHash + 1) == 0) ? false : true;
                qualityBar.value = PlayerPrefs.GetInt(videoHash + 2);
            }
            else
            {
                PlayerPrefs.SetInt(videoHash + 0, 0);
                PlayerPrefs.SetInt(videoHash + 1, 0);
                PlayerPrefs.SetInt(videoHash + 2, 0);
                resolutionBar.value = 0;
                fullscreen.isOn     = false;
                qualityBar.value    = 0;
            }
            resText.text  = res[(int)resolutionBar.value].width + "x" + res[(int)resolutionBar.value].height;
            qualText.text = QualitySettings.names[(int)qualityBar.value];
        }
Esempio n. 15
0
 public static void ClearToggleClick(GameObject obj)
 {
     UnityEngine.UI.Toggle toggle = obj.GetComponent <UnityEngine.UI.Toggle>();
     if (toggle == null)
     {
         return;
     }
     toggle.onValueChanged.RemoveAllListeners();
 }
Esempio n. 16
0
 protected override void GetDependencies(System.Collections.Generic.Dictionary <long, UnityEngine.Object> dependencies, object obj)
 {
     base.GetDependencies(dependencies, obj);
     if (obj == null)
     {
         return;
     }
     UnityEngine.UI.Toggle o = (UnityEngine.UI.Toggle)obj;
     AddDependency(o.group, dependencies);
 }
Esempio n. 17
0
        void Start()
        {
            toggle      = GetComponent <UnityEngine.UI.Toggle>();
            canvasGroup = GetComponentInParent <CanvasGroup>();

            // set alpha to "off" value
            canvasGroup.alpha = offValue;
            // add listener to this toggle button
            toggle.onValueChanged.AddListener(OnToggleValueChanged);
        }
Esempio n. 18
0
        int UnityEngineUIToggle_s_set_toggleTransition(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;

            UnityEngine.UI.Toggle gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
            UnityEngine.UI.Toggle.ToggleTransition gen_value; translator.Get(L, 2, out gen_value);
            gen_to_be_invoked.toggleTransition = gen_value;

            return(0);
        }
Esempio n. 19
0
        public override void BhvOnEnter()
        {
            m_canvas = GetComponentInParent <Canvas>();

            OnChangeIsUsingFixedBase(true);
            OnChangeIsUsingAcceleration(false);

            AddEventTrigger(OnPressedTouchStick, EventTriggerType.PointerDown);
            AddEventTrigger(OnReleasedTouchStick, EventTriggerType.PointerUp);

            if (DebuggingToggleList != null)
            {
                for (int i = 0; i < DebuggingToggleList.Count; i++)
                {
                    if (DebuggingToggleList[i] == null)
                    {
                        continue;
                    }

                    UnityEngine.UI.Toggle toggle = DebuggingToggleList[i];

                    switch (i)
                    {
                    //FixedBase
                    case 0:
                        toggle.onValueChanged.AddListener((bool ison) => { OnChangeIsUsingFixedBase(ison); });
                        break;

                    //Acceleration
                    case 1:
                        toggle.onValueChanged.AddListener((bool ison) => { OnChangeIsUsingAcceleration(ison); });
                        break;
                    }
                }
            }

            InitializeStickPositions();

            if (Application.platform == RuntimePlatform.WindowsEditor ||
                Application.platform == RuntimePlatform.OSXEditor)
            {
                m_accelerationBase.x = Input.mousePosition.x;
                m_accelerationBase.y = Input.mousePosition.y;
            }

            if (FixedBaseToggle != null)
            {
                IsUsingFixedBase = FixedBaseToggle.isOn;
            }

            if (AccelerationToggle != null)
            {
                IsUsingAcceleration = AccelerationToggle.isOn;
            }
        }
 private static void AddVariable(StoryInstance instance, string name, UnityEngine.GameObject control)
 {
     instance.SetVariable(name, control);
     UnityEngine.UI.Text text = control.GetComponent <UnityEngine.UI.Text>();
     if (null != text)
     {
         instance.SetVariable(string.Format("{0}_Text", name), text);
     }
     UnityEngine.UI.Image image = control.GetComponent <UnityEngine.UI.Image>();
     if (null != image)
     {
         instance.SetVariable(string.Format("{0}_Image", name), image);
     }
     UnityEngine.UI.RawImage rawImage = control.GetComponent <UnityEngine.UI.RawImage>();
     if (null != rawImage)
     {
         instance.SetVariable(string.Format("{0}_RawImage", name), rawImage);
     }
     UnityEngine.UI.Button button = control.GetComponent <UnityEngine.UI.Button>();
     if (null != button)
     {
         instance.SetVariable(string.Format("{0}_Button", name), button);
     }
     UnityEngine.UI.Dropdown dropdown = control.GetComponent <UnityEngine.UI.Dropdown>();
     if (null != dropdown)
     {
         instance.SetVariable(string.Format("{0}_Dropdown", name), dropdown);
     }
     UnityEngine.UI.InputField inputField = control.GetComponent <UnityEngine.UI.InputField>();
     if (null != inputField)
     {
         instance.SetVariable(string.Format("{0}_Input", name), inputField);
     }
     UnityEngine.UI.Slider slider = control.GetComponent <UnityEngine.UI.Slider>();
     if (null != inputField)
     {
         instance.SetVariable(string.Format("{0}_Slider", name), slider);
     }
     UnityEngine.UI.Toggle toggle = control.GetComponent <UnityEngine.UI.Toggle>();
     if (null != toggle)
     {
         instance.SetVariable(string.Format("{0}_Toggle", name), toggle);
     }
     UnityEngine.UI.ToggleGroup toggleGroup = control.GetComponent <UnityEngine.UI.ToggleGroup>();
     if (null != toggleGroup)
     {
         instance.SetVariable(string.Format("{0}_ToggleGroup", name), toggleGroup);
     }
     UnityEngine.UI.Scrollbar scrollbar = control.GetComponent <UnityEngine.UI.Scrollbar>();
     if (null != scrollbar)
     {
         instance.SetVariable(string.Format("{0}_Scrollbar", name), scrollbar);
     }
 }
Esempio n. 21
0
        /// <summary>
        /// 扩展Toggle组件
        /// </summary>
        /// <param name="toggle"></param>
        /// <param name="parent"></param>
        /// <param name="pos"></param>
        /// <param name="content"></param>
        /// <param name="onSwitch"></param>
        /// <returns></returns>
        public static UnityEngine.UI.Toggle SetupToggle(this UnityEngine.UI.Toggle toggle, Transform parent, Vector3 pos, float scale, string content, UnityEngine.Events.UnityAction <bool> onSwitch, string labelName = "Label")
        {
            Transform trans = toggle.transform;

            trans.SetParent(parent);
            trans.localPosition = pos;
            trans.localScale    = Vector3.one * scale;
            trans.Find(labelName).GetComponent <UnityEngine.UI.Text>().text = content;
            toggle.onValueChanged.AddListener(onSwitch);
            return(toggle);
        }
Esempio n. 22
0
 public override void ReadFrom(object obj)
 {
     base.ReadFrom(obj);
     if (obj == null)
     {
         return;
     }
     UnityEngine.UI.Toggle o = (UnityEngine.UI.Toggle)obj;
     group = o.group.GetMappedInstanceID();
     isOn  = o.isOn;
 }
Esempio n. 23
0
        void SetTriggerVisualInteractiveState(UnityEngine.UI.Toggle toggle)
        {
            Color interactiveCol           = ColorThemeData.Instance.interactionColor;
            Color onButNotInteractiveColor = new Color(interactiveCol.r, interactiveCol.g, interactiveCol.b, 0.25f);

            Color bgCol = toggle.isOn
                ? (toggle.interactable ? interactiveCol : onButNotInteractiveColor)
                : new Color(0.632f, 0.632f, 0.632f);

            toggle.targetGraphic.color = bgCol;
        }
Esempio n. 24
0
 public override object WriteTo(object obj, System.Collections.Generic.Dictionary <long, UnityEngine.Object> objects)
 {
     obj = base.WriteTo(obj, objects);
     if (obj == null)
     {
         return(null);
     }
     UnityEngine.UI.Toggle o = (UnityEngine.UI.Toggle)obj;
     o.group = (UnityEngine.UI.ToggleGroup)objects.Get(group);
     o.isOn  = isOn;
     return(o);
 }
Esempio n. 25
0
        static int _s_set_graphic(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.UI.Toggle gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.graphic = (UnityEngine.UI.Graphic)translator.GetObject(L, 2, typeof(UnityEngine.UI.Graphic));
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(0);
        }
Esempio n. 26
0
        static int _g_get_onValueChanged(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.UI.Toggle gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
                translator.Push(L, gen_to_be_invoked.onValueChanged);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
Esempio n. 27
0
 public static void AddToggleClick(GameObject obj, LuaFunction func)
 {
     UnityEngine.UI.Toggle button = obj.GetComponent <UnityEngine.UI.Toggle>();
     if (button == null)
     {
         return;
     }
     button.onValueChanged.AddListener((isbool) =>
     {
         func.Call <bool, GameObject>(isbool, obj);
     });
 }
Esempio n. 28
0
        static int _s_set_onValueChanged(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                UnityEngine.UI.Toggle __cl_gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
                __cl_gen_to_be_invoked.onValueChanged = (UnityEngine.UI.Toggle.ToggleEvent)translator.GetObject(L, 2, typeof(UnityEngine.UI.Toggle.ToggleEvent));
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
Esempio n. 29
0
        static int _s_set_isOn(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                UnityEngine.UI.Toggle __cl_gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
                __cl_gen_to_be_invoked.isOn = LuaAPI.lua_toboolean(L, 2);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
Esempio n. 30
0
        static int _g_get_graphic(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                UnityEngine.UI.Toggle __cl_gen_to_be_invoked = (UnityEngine.UI.Toggle)translator.FastGetCSObj(L, 1);
                translator.Push(L, __cl_gen_to_be_invoked.graphic);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(1);
        }
Esempio n. 31
0
		public override void OnEnter()
		{

			GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject);
			if (_go!=null)
			{
				_toggle = _go.GetComponent<UnityEngine.UI.Toggle>();
			}

			DoGetValue();
			
			if (!everyFrame)
			{
				Finish();
			}
		}
Esempio n. 32
0
        public override void OnEnter()
        {
            GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (_go!=null)
            {
                _toggle = _go.GetComponent<UnityEngine.UI.Toggle>();
            }

            if (resetOnExit.Value)
            {
                _originalValue = _toggle.isOn;
            }

            DoSetValue();

            Finish();
        }
		public override void OnEnter()
		{
			GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
			if (go!=null)
			{
				_toggle = go.GetComponent<UnityEngine.UI.Toggle>();
				if (_toggle!=null)
				{
					_toggle.onValueChanged.AddListener(DoOnValueChanged);
				}else{
					LogError("Missing UI.Toggle on "+go.name);
				}
			}else{
				LogError("Missing GameObject");
			}

		}
Esempio n. 34
0
 // Use this for initialization
 void Awake()
 {
     myToggle = gameObject.GetComponent<UnityEngine.UI.Toggle>();
     toggleAnimator = gameObject.GetComponent<Animator>();
 }
Esempio n. 35
0
    // Use this for initialization
    void Start()
    {
        //We can come from the game into this menu. In the game the cursor is hidden. Force it visible to be sure.
        Cursor.visible = true;

        //Get the canvas
        thisCanvas = GetComponent<Canvas>();

        //Get the Canvas groups for the different sub-menus
        welcomeGroup = transform.Find("Group_Welcome").gameObject.GetComponent<CanvasGroup>();
        welcomeGroup.interactable = false;
        commonsMenuGroup = transform.Find("Group_Commons").gameObject.GetComponent<CanvasGroup>();
        commonsMenuGroup.interactable = false;
        mainMenuGroup = transform.Find("Group_MainMenu").gameObject.GetComponent<CanvasGroup>();
        mainMenuGroup.interactable = false;
        optionsMenuGroup = transform.Find("Group_OptionsMenu").gameObject.GetComponent<CanvasGroup>();
        optionsMenuGroup.interactable = false;

        //Get the dynamic elements from welcome screen
        clickText = welcomeGroup.transform.Find("Text_ClicktoBegin").gameObject.GetComponent<UnityEngine.UI.Text>();

        //Get the interactive elements from options screen
        graphSlider = optionsMenuGroup.transform.Find("Graph_Quality_Slider").gameObject.GetComponent<UnityEngine.UI.Slider>();
        graphSlider.value = QualitySettings.GetQualityLevel();

        subtitleToggle = optionsMenuGroup.transform.Find("Subtitle_Toggle").gameObject.GetComponent<UnityEngine.UI.Toggle>();

        //Reads subtitles preferences in "preferences" save file. 0 if no value. Checkbox is changed accordingly.
        if ( PlayerPrefs.GetInt("subtitles", 0) == 1 ) {
            subtitleToggle.isOn = true;
        }
        else
        {
            subtitleToggle.isOn = false;
        }

        PlayerPrefs.SetInt("subtitles", 0);

        //Modify size of background image to make sure it fills screen
        RectTransform backgroundSize = gameObject.transform.Find("BackgroundImage").gameObject.GetComponent<RectTransform>();
        backgroundSize.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width);
        backgroundSize.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Screen.height);

        //Setup the black fader to fill the screen
        blackFader = transform.Find("BlackFader").gameObject.GetComponent<UnityEngine.UI.Image>();
        blackFader.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width);
        blackFader.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Screen.height);

        //Fetch and store menu audio source
        audioSrc = GetComponent<AudioSource>();

        //Start first step : showing the Unity logo. It starts the chain of events
        StartCoroutine("ShowGobelinsLogo");
    }
Esempio n. 36
0
 void Start()
 {
     this.toggleSound = GetComponentInParent<UnityEngine.UI.Toggle>();
 }