Beispiel #1
0
    /// <summary>
    /// slider 由p1指向p2
    /// </summary>
    /// <param name="p1"></param>
    /// <param name="p2"></param>
    /// <param name="mySlider"></param>
    void SetLineUI(Vector3 p1, Vector3 p2, Slider mySlider)
    {
        float centerX = (p1.x + p2.x) / 2;
        float centerY = (p1.y + p2.y) / 2;

        float distance = Vector3.Distance(p1, p2);

        mySlider.transform.position         = new Vector3(centerX, centerY, 0);
        mySlider.transform.localEulerAngles = UIUtils.GetEulerAngle(p1, p2);
        mySlider.GetComponent <RectTransform>().sizeDelta = new Vector2(distance, 20);
        mySlider.GetComponent <Slider>().value            = 0f;
    }
    // Start is called before the first frame update
    void Start()
    {
        InitOnStart();

        SoundManager.Instance.BgmSpeaker
            (SoundManager.BGM.Boss,
            SoundManager.State.Play, bgmClip);

        GameManager.onPlayerDie += IsPlayerDied;

        playerShieldGauge     = GameObject.Find("Player Shield Gauge").GetComponent <UnityEngine.UI.Slider>();
        playerShieldGuageRect = playerShieldGauge.GetComponent <RectTransform>();

        playerShieldMaxValue = playerShieldGauge.maxValue;

        playerShieldGuageOriginalOffsetMax = playerShieldGuageRect.offsetMax;
        //Debug.Log("Orig offsetMax : " + playerShieldGuageRect.offsetMax);
        //float newOffsetMaxY =
        //     (playerShieldGuageRect.offsetMax.y * 2.0f) -
        //     ((playerShieldGuageRect.offsetMax.y * 0.01f) * playerShieldDivideValue);
        //Debug.Log("MAX : " + playerShieldGuageRect.offsetMin.y);
        //Debug.Log("MIN : " + (playerShieldGuageRect.offsetMin.y + playerShieldGuageRect.offsetMax.y));
        float newOffsetMaxY =
            (playerShieldGuageRect.offsetMin.y + playerShieldGuageRect.offsetMax.y)
            * 0.01f * playerShieldDivideValue;

        //Debug.Log("1% : " + ((playerShieldGuageRect.offsetMin.y - playerShieldGuageRect.offsetMax.y)
        //  * 0.01f));
        //Debug.Log("NEW * Percent : " + newOffsetMaxY);
        playerShieldGuageFixedOffsetMax = new Vector2(playerShieldGuageRect.offsetMax.x, newOffsetMaxY);
        //Debug.Log("Now offsetMax : " + playerShieldGuageFixedOffsetMax);

        SoundManager.Instance.BgmSpeaker
            (SoundManager.BGM.Boss, SoundManager.State.Play, bgmClip);
    }
Beispiel #3
0
    private void Awake()
    {
        m_SliderRectTransform          = m_ShotSlider.GetComponent <RectTransform>();
        m_PerfectPowerBarRectTransform = m_PerfectPowerBar.GetComponent <RectTransform>();

        m_SliderHeight = m_SliderRectTransform.sizeDelta.y;
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        sweetSlider.GetComponent <RectTransform>().sizeDelta  = new Vector2(Screen.width - 100, 20);
        sourSlider.GetComponent <RectTransform>().sizeDelta   = new Vector2(Screen.width - 100, 20);
        bitterSlider.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width - 100, 20);
        saltySlider.GetComponent <RectTransform>().sizeDelta  = new Vector2(Screen.width - 100, 20);
        umamiSlider.GetComponent <RectTransform>().sizeDelta  = new Vector2(Screen.width - 100, 20);

        sweet.text  = sweetSlider.value.ToString();
        sour.text   = sourSlider.value.ToString();
        bitter.text = bitterSlider.value.ToString();
        salty.text  = saltySlider.value.ToString();
        umami.text  = umamiSlider.value.ToString();
    }
Beispiel #5
0
    void init_settings()
    {
        NetData.settings = new Dictionary <string, float>()
        {
            { "Ambient Occulusion", 0.05f },
            { "Bloom Effect", 4f },
            { "Depth of Field", 20f },
            { "Color Grading", 89f },
        };

        TestSettings = this.clone(NetData.settings);

        SettingsPointer = new Dictionary <int, string>();
        OPTION_DATA     = new GameObject[4];

        UnityEngine.UI.Slider[] options = new UnityEngine.UI.Slider[] {
            OPTION0, OPTION1, OPTION2, OPTION3
        };

        int i = 0;

        NetData.fancyGraphics = true;
        foreach (var option in NetData.settings)
        {
            SettingsPointer.Add(i, option.Key);
            UnityEngine.UI.Slider slider = options[i];
            RectTransform         s_t    = slider.GetComponent <RectTransform>();
            TMPro.TextMeshProUGUI text   = s_t.GetChild(s_t.childCount - 1).GetComponent <TMPro.TextMeshProUGUI>();

            slider.value = option.Value;
            pieceCode code  = slider.gameObject.AddComponent <pieceCode>();
            int       iCopy = i;
            slider.onValueChanged.AddListener(delegate {
                TestSettings[SettingsPointer[iCopy]] = slider.value;
            });
            OPTION_DATA[i] = slider.gameObject;
            i++;
        }
        APPLY_BUTTON.onClick.AddListener(delegate {
            NetData.settings = clone(TestSettings);
        });

        BUTTON_TOGGLE.onValueChanged.AddListener(delegate {
            NetData.fancyGraphics = !NetData.fancyGraphics;
            foreach (var item in options)
            {
                item.enabled = NetData.fancyGraphics;
            }
        });
    }
Beispiel #6
0
 // Start is called before the first frame update
 void Start()
 {
     jetpackAudio = GetComponent <AudioSource>();
     jetpackParticles.Stop();
     if (!flightTimeSlider.gameObject.activeSelf)
     {
         flightTimeSlider.gameObject.SetActive(true);
     }
     isFloating                = false;
     isFlying                  = false;
     currentFlightAccel        = flightAccel;
     currentFlightTime         = flightTime;
     sliderAnim                = flightTimeSlider.GetComponent <Animator>();
     playerFPController        = GetComponentInChildren <FirstPersonController>();
     playerCharController      = playerFPController.GetComponent <CharacterController>();
     flightTimeSlider.maxValue = flightTime;
 }
    /// <summary>
    /// Awakes the script.
    /// </summary>
    void Awake()
    {
        logSeriesId = LoggerAssembly.GetLogSeriesId();

        smc  = FindObjectOfType <SumoMainController>();
        tic  = FindObjectOfType <TrafficIntegrationController>();
        ebpc = FindObjectOfType <EventButtonPanelController>();
        fped = FindObjectOfType <FlashPedestriansGlobalParameters>();

        if (timeSlider != null)
        {
            timeSliderContr = timeSlider.GetComponent <TimeSliderController>();
        }

        if (loadingSplash != null)
        {
            loadingSplash.SetActive(true);
        }
    }
Beispiel #8
0
 void Start()
 {
     ant = slider.GetComponent <Animator>();
 }
        public UGUINode DrawLayer(GroupNode layer, UGUINode parent)
        {
            UGUINode node = PSDImportUtility.InstantiateItem(GroupType.SLIDER, layer.Name, parent); //GameObject.Instantiate(temp) as UnityEngine.UI.Slider;

            UnityEngine.UI.Slider slider = node.InitComponent <UnityEngine.UI.Slider>();
            PSDImportUtility.SetRectTransform(layer, slider.GetComponent <RectTransform>());
            slider.value = 1;

            ImgNode bg     = layer.images.Find(x => x.Name.ToLower().StartsWith("b_"));
            ImgNode fill   = layer.images.Find(x => x.Name.ToLower().StartsWith("f_"));
            ImgNode handle = layer.images.Find(x => x.Name.ToLower().StartsWith("h_"));

            if (bg != null)
            {
                var graph = node.InitComponent <UnityEngine.UI.Image>();
                PSDImportUtility.SetPictureOrLoadColor(bg, graph);
            }

            if (fill != null)
            {
                var fillAreaNode = PSDImportUtility.InstantiateItem(GroupType.EMPTY, "Fill Area", node);
                var fileNode     = ctrl.DrawImage(fill, fillAreaNode);
                fileNode.InitComponent <Image>().type = Image.Type.Tiled;
                PSDImportUtility.SetRectTransform(fill, fillAreaNode.InitComponent <RectTransform>());

                fillAreaNode.ReprocessEvent = () =>
                {
                    slider.fillRect = fileNode.InitComponent <RectTransform>();
                };
            }

            if (handle != null && bg != null)
            {
                var tempRect = fill != null ? fill : bg;
                SetSlider(slider, handle, layer);
                var handAreaNode = PSDImportUtility.InstantiateItem(GroupType.EMPTY, "Handle Slide Area", node);
                var handNode     = ctrl.DrawImage(handle, handAreaNode);
                PSDImportUtility.SetRectTransform(tempRect, handAreaNode.InitComponent <RectTransform>());

                switch (layer.direction)
                {
                case Direction.LeftToRight:
                    handNode.anchoType = AnchoType.Right | AnchoType.YStretch;
                    break;

                case Direction.BottomToTop:
                    handNode.anchoType = AnchoType.Up | AnchoType.XStretch;
                    break;

                case Direction.TopToBottom:
                    handNode.anchoType = AnchoType.Down | AnchoType.XStretch;
                    break;

                case Direction.RightToLeft:
                    handNode.anchoType = AnchoType.Left | AnchoType.YStretch;
                    break;

                default:
                    break;
                }
                handNode.ReprocessEvent = () =>
                {
                    slider.handleRect = handNode.InitComponent <RectTransform>();
                    slider.handleRect.anchoredPosition = Vector3.zero;
                };
            }
            else
            {
                SetSlider(slider, layer.direction);
            }


            return(node);
        }
        public UINode DrawLayer(Layer layer, UINode parent)
        {
            UINode node = PSDImportUtility.InstantiateItem(PSDImporterConst.PREFAB_PATH_SLIDER, layer.name, parent); //GameObject.Instantiate(temp) as UnityEngine.UI.Slider;

            UnityEngine.UI.Slider slider = node.GetComponent <UnityEngine.UI.Slider>();
            string type = layer.arguments[0].ToUpper();

            switch (type)
            {
            case "R":
                slider.direction = Slider.Direction.RightToLeft;
                break;

            case "L":
                slider.direction = Slider.Direction.LeftToRight;
                break;

            case "T":
                slider.direction = Slider.Direction.TopToBottom;
                break;

            case "B":
                slider.direction = Slider.Direction.BottomToTop;
                break;

            default:
                break;
            }
            bool haveHandle = false;

            for (int i = 0; i < layer.images.Length; i++)
            {
                Image  image               = layer.images[i];
                string lowerName           = image.name.ToLower();
                UnityEngine.UI.Image graph = null;

                if (lowerName.StartsWith("b_"))
                {
                    graph = slider.transform.Find("Background").GetComponent <UnityEngine.UI.Image>();
                    PSDImportUtility.SetRectTransform(image, slider.GetComponent <RectTransform>());
                    slider.name = layer.name;
                }
                else if (lowerName.StartsWith("f_"))
                {
                    graph = slider.fillRect.GetComponent <UnityEngine.UI.Image>();
                }
                else if (lowerName.StartsWith("h_"))
                {
                    graph = slider.handleRect.GetComponent <UnityEngine.UI.Image>();
                    RectTransform rect = graph.GetComponent <RectTransform>();
                    rect.name             = image.name;
                    rect.sizeDelta        = new Vector2(image.size.width, 0);
                    rect.anchoredPosition = Vector2.zero;
                    haveHandle            = true;
                }

                if (graph == null)
                {
                    continue;
                }

                PSDImportUtility.SetPictureOrLoadColor(image, graph);
            }

            if (!haveHandle)
            {
                UnityEngine.Object.DestroyImmediate(slider.handleRect.parent.gameObject);
            }
            return(node);
        }
Beispiel #11
0
    // private void Update()
    //{

    //for (int i = 0; i < DefinePause.ImageNumber; i++)
    //{

    //    if (PauseScript[i].pauseUI[i].activeSelf == true)
    //    {
    //        slider = GameObject.Find("Slider").GetComponent<Slider>();
    //    }
    //}
    //}
    //スライダーで音量調整
    public void  FixedUpdate()
    {
        SoundScript.audio.GetComponent <AudioSource>().volume = slider.GetComponent <Slider>().normalizedValue;
    }
Beispiel #12
0
        public void DrawLayer(Layer layer, GameObject parent)
        {
            //UnityEngine.UI.Slider temp = AssetDatabase.LoadAssetAtPath(PSDImporterConst.PREFAB_PATH_SLIDER, typeof(UnityEngine.UI.Slider)) as UnityEngine.UI.Slider;
            UnityEngine.UI.Slider slider = PSDImportUtility.LoadAndInstant <UnityEngine.UI.Slider>(PSDImporterConst.ASSET_PATH_SLIDER, layer.name, parent); //GameObject.Instantiate(temp) as UnityEngine.UI.Slider;

            RectTransform rectTransform = slider.GetComponent <RectTransform>();

            rectTransform.sizeDelta        = new Vector2(layer.size.width, layer.size.height);
            rectTransform.anchoredPosition = new Vector2(layer.position.x, layer.position.y);

            //slider.transform.SetParent(parent.transform, true); //parent = parent.transform;

            PosLoader posloader = slider.gameObject.AddComponent <PosLoader>();

            posloader.worldPos = rectTransform.position;

            string type = layer.arguments[0].ToUpper();

            switch (type)
            {
            case "R":
                slider.direction = Slider.Direction.RightToLeft;
                break;

            case "L":
                slider.direction = Slider.Direction.LeftToRight;
                break;

            case "T":
                slider.direction = Slider.Direction.TopToBottom;
                break;

            case "B":
                slider.direction = Slider.Direction.BottomToTop;
                break;

            default:
                break;
            }

            for (int i = 0; i < layer.layers.Length; i++)
            {
                PSImage image     = layer.layers[i].image;
                string  assetPath = PSDImportUtility.baseDirectory + image.name + PSDImporterConst.PNG_SUFFIX;
                Sprite  sprite    = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite)) as Sprite;

                if (image.name.ToLower().Contains("bg"))
                {
                    var bgRect  = slider.transform.Find("Background").GetComponent <RectTransform>();
                    var bgImage = bgRect.GetComponent <UnityEngine.UI.Image>();
                    if (image.imageType != ImageType.SliceImage)
                    {
                        bgImage.type = Image.Type.Simple;
                    }
                    bgImage.sprite   = sprite;
                    bgRect.sizeDelta = new Vector2(image.size.width, image.size.height);
                }
                else if (image.name.ToLower().Contains("fill"))
                {
                    var fillImage = slider.fillRect.GetComponent <UnityEngine.UI.Image>();
                    if (image.imageType != ImageType.SliceImage)
                    {
                        fillImage.type = Image.Type.Simple;
                    }
                    fillImage.sprite = sprite;

                    var fillArea = slider.transform.Find("Fill Area").GetComponent <RectTransform>();
                    fillArea.sizeDelta = new Vector2(image.size.width, image.size.height);
                }
                else if (image.name.ToLower().Contains("handle"))       //默认没有handle
                {
                    var handleRectTrans = slider.transform.Find("Handle Slide Area/Handle").GetComponent <RectTransform>();
                    var handleSprite    = handleRectTrans.GetComponent <UnityEngine.UI.Image>();
                    slider.handleRect   = handleRectTrans;
                    handleSprite.sprite = sprite;

                    handleRectTrans.gameObject.SetActive(true);
                }
            }
        }
Beispiel #13
0
 // Start is called before the first frame update
 void Start()
 {
     my_ang_slider = ang_slider.GetComponent <UnityEngine.UI.Slider> ();
     my_len_slider = len_slider.GetComponent <UnityEngine.UI.Slider> ();
 }