public void SelectMobileInput(MobileInputConfig input)
 {
     if (!input)
     {
         DeselectMobileInput();
         return;
     }
     if (uiRoot)
     {
         uiRoot.SetActive(true);
     }
     if (scaleSlider)
     {
         scaleSlider.onValueChanged.RemoveAllListeners();
         scaleSlider.minValue = input.minScale;
         scaleSlider.maxValue = input.maxScale;
         scaleSlider.value    = input.CurrentScale;
         scaleSlider.onValueChanged.AddListener(input.SetScale);
     }
     if (alphaSlider)
     {
         alphaSlider.onValueChanged.RemoveAllListeners();
         alphaSlider.minValue = input.minAlpha;
         alphaSlider.maxValue = input.maxAlpha;
         alphaSlider.value    = input.CurrentAlpha;
         alphaSlider.onValueChanged.AddListener(input.SetAlpha);
     }
 }
 protected virtual void Start()
 {
     canvasGroup = GetComponent <CanvasGroup>();
     if (canvasGroup == null)
     {
         canvasGroup       = gameObject.AddComponent <CanvasGroup>();
         canvasGroup.alpha = GetAlphaByCurrentState() * alphaMultiplier;
     }
     config = GetComponent <MobileInputConfig>();
     if (config != null)
     {
         // Updating default canvas group alpha when loading new config
         config.onLoadAlpha += OnLoadAlpha;
     }
 }
示例#3
0
 private void Start()
 {
     canvasGroup = GetComponent <CanvasGroup>();
     if (canvasGroup == null)
     {
         canvasGroup       = gameObject.AddComponent <CanvasGroup>();
         canvasGroup.alpha = alphaWhileIdling * alphaMultiplier;
     }
     config = GetComponent <MobileInputConfig>();
     if (config != null)
     {
         // Updating default canvas group alpha when loading new config
         config.onLoadAlpha += OnLoadAlpha;
     }
 }
示例#4
0
 private void Start()
 {
     canvasGroup = GetComponent <CanvasGroup>();
     if (canvasGroup == null)
     {
         canvasGroup       = gameObject.AddComponent <CanvasGroup>();
         canvasGroup.alpha = 1f;
     }
     if (controllerBackground != null)
     {
         // Prepare background offset, it will be used to calculate joystick movement
         backgroundOffset = controllerBackground.position - controllerHandler.position;
         // Get canvas group, will use it to change alpha later
         backgroundCanvasGroup = controllerBackground.GetComponent <CanvasGroup>();
         if (backgroundCanvasGroup != null)
         {
             backgroundCanvasGroup.alpha = backgroundAlphaWhileIdling;
         }
     }
     if (controllerHandler != null)
     {
         // Get canvas group, will use it to change alpha later
         handlerCanvasGroup = controllerHandler.GetComponent <CanvasGroup>();
         if (handlerCanvasGroup != null)
         {
             handlerCanvasGroup.alpha = handlerAlphaWhileIdling;
         }
     }
     config = GetComponent <MobileInputConfig>();
     if (config != null)
     {
         // Updating default canvas group alpha when loading new config
         config.onLoadAlpha += OnLoadAlpha;
     }
     defaultCanvasGroupAlpha        = canvasGroup.alpha;
     defaultControllerLocalPosition = controllerHandler.localPosition;
     defaultSiblingIndex            = transform.GetSiblingIndex();
     SetIdleState();
 }