Exemple #1
0
    void _ui()
    {
        // bombPanel
        float bombPanel_width  = (float)(300 / 375.0) * Display.main.systemWidth,
              bombPanel_height = (float)(200.0 / 300) * bombPanel_width;

        BombPanel.GetComponent <RectTransform>().sizeDelta = new Vector2(bombPanel_width, bombPanel_height);
        // title_text
        float title_text_posy    = -(float)(20 / 667.0) * Display.main.systemHeight,
              title_text_width   = (float)(240 / 375.0) * Display.main.systemWidth,
              titile_text_height = (float)(25 / 667.0) * Display.main.systemHeight;

        TitleText.rectTransform.sizeDelta          = new Vector2(title_text_width, titile_text_height);
        TitleText.rectTransform.anchoredPosition3D = new Vector3(0, title_text_posy, 0);
        // content_text
        float content_text_width  = (float)(280 / 375.0) * Display.main.systemWidth,
              content_text_height = (float)(80 / 667.0) * Display.main.systemHeight;
        int fontsize = (int)((18 / 375.0) * Display.main.systemWidth);

        ContentText.fontSize = fontsize;
        ContentText.rectTransform.sizeDelta = new Vector2(ContentText.preferredWidth, content_text_height);
        // update_button
        float update_button_width  = (float)(240 / 375.0) * Display.main.systemWidth,
              update_button_height = (float)(35 / 667.0) * Display.main.systemHeight;

        UpdateButton.GetComponent <RectTransform>().sizeDelta          = new Vector2(update_button_width, update_button_height);
        UpdateButton.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(0, -title_text_posy, 0);

        // updata_button_text
        UpdateButton.transform.Find("Text").GetComponent <RectTransform>().sizeDelta = new Vector2(update_button_width - 10, update_button_height / 2.0f);
    }
Exemple #2
0
    /// <summary>
    /// 初始化画布,将小方块填充整个画布
    /// </summary>
    void InitCanvas()
    {
        int initX;
        int initY = blockHeight;

        //blocks.count--画布行数,blocks[i].count--画布列数
        for (int row = 0; row < rowBlockNum; row++)
        {
            initX = blockWidth;
            blocks.Add(new List <Block>());
            for (int col = 0; col < colBlockNum; col++)
            {
                //实例化小方块
                Block blockPrefab = Resources.Load <Block>("Prefabs/Block");
                Block blockTmp    = Instantiate(blockPrefab, eliminateToLeCanvas.transform);

                blockTmp.GetComponent <BlockScript>().ClearCrossArea = ClearCrossArea;
                blockTmp.GetComponent <BlockScript>().BoomProps      = BoomBlocks;

                blockTmp.transform.position = new Vector3(initX, initY, 0);
                blockTmp.GetComponent <BlockScript>().SetIndex(row, col);

                int color = UnityEngine.Random.Range(0, 10);
                blockTmp.GetComponent <Image>().color = blockScript.colors[color];

                blocks[row].Add(blockTmp);

                initX += blockWidth * 2;
            }
            initY += blockHeight * 2;
        }
    }
Exemple #3
0
        /// <summary>
        /// 初始化按扭为text或image
        /// </summary>
        /// <param name="image"></param>
        /// <param name="button"></param>
        private void InitButton(Data.ImgNode image, UnityEngine.UI.Button button)
        {
            if (image.type == ImgType.Label)
            {
                var text = button.GetComponent <UnityEngine.UI.Text>();
                if (text == null)
                {
                    text = button.gameObject.AddComponent <UnityEngine.UI.Text>();

                    button.targetGraphic = text;

                    SetRectTransform(image.rect, text.rectTransform);
#if UNITY_EDITOR
                    UnityEditorInternal.ComponentUtility.MoveComponentUp(text);
#endif
                }
            }
            else
            {
                var img = button.GetComponent <UnityEngine.UI.Image>();
                if (img == null)
                {
                    img = button.gameObject.AddComponent <UnityEngine.UI.Image>();
                    button.targetGraphic = img;
#if UNITY_EDITOR
                    UnityEditorInternal.ComponentUtility.MoveComponentUp(img);
#endif
                }
            }
        }
Exemple #4
0
    void Start()
    {
        eliminateToLeCanvas = GameObject.Find("EliminateToLeCanvas").GetComponent <Canvas>();
        newYearPic          = eliminateToLeCanvas.transform.Find("NewYearPic").GetComponent <Image>();
        countDownBar        = eliminateToLeCanvas.transform.Find("CountDownBar").GetComponent <Slider>();

        mainCanvs = GameObject.Find("MainCanvas").GetComponent <Canvas>();
        manager   = GameObject.Find("CanvasManager").GetComponent <CanvasManager>();
        Block block = Resources.Load <Block>("Prefabs/Block");

        block = Instantiate(block);

        blockWidth  = Convert.ToInt32(block.GetComponent <RectTransform>().rect.width);
        blockHeight = Convert.ToInt32(block.GetComponent <RectTransform>().rect.height);

        //在右侧减少一列
        colBlockNum = width / blockWidth - 1;
        rowBlockNum = height / blockHeight;

        this.blockWidth  = blockWidth / 2;
        this.blockHeight = blockHeight / 2;

        blockScript = block.GetComponent <BlockScript>();

        DestroyImmediate(block.gameObject);
    }
Exemple #5
0
 public RectTransform GetRectTransform()
 {
     if (uiButton != null && uiButton.GetComponent <RectTransform>())
     {
         return(uiButton.GetComponent <RectTransform>());
     }
     return(null);
 }
    private void oqbClick()
    {
        RectTransform rt = panel.GetComponent <RectTransform>();

        rt.localScale = new Vector3(1, 1, 1);
        RectTransform rt2 = qbutton.GetComponent <RectTransform>();

        rt2.localScale = new Vector3(0, 0, 0);
    }
Exemple #7
0
 private void Awake()
 {
     if (PlayerPrefs.HasKey("lvl2"))
     {
         _continue.GetComponent <Button>().enabled = true;
         _continue.GetComponent <Image>().color    = new Color(255, 255, 255, 255);
         _contText       = _continue.GetComponentInChildren <Text>();
         _contText.color = new Color(255, 255, 255, 255);
     }
 }
    private void loadSearchTab()
    {
        clearCurrentWindow();
        currentTab = 0;
        searchWindow.localScale = new Vector3(1, 1, 1);
        Color col = searchBtn.GetComponent <Image>().color;

        col.a = 1;
        searchBtn.GetComponent <Image>().color = col;
        urlText.text = "www.search.com";
    }
    private void loadHelpTab()
    {
        clearCurrentWindow();
        currentTab            = 2;
        helpWindow.localScale = new Vector3(1, 1, 1);
        Color col = helpBtn.GetComponent <Image>().color;

        col.a = 1;
        helpBtn.GetComponent <Image>().color = col;
        urlText.text = "www.help.com";
    }
Exemple #10
0
 /**
  * <summary>Gets the boundary of the UI Button.</summary>
  * <returns>The boundary Rect of the UI Button</returns>
  */
 public RectTransform GetRectTransform()
 {
     if (uiButton)
     {
         RectTransform rectTransform = uiButton.GetComponent <RectTransform>();
         if (rectTransform)
         {
             return(rectTransform);
         }
     }
     return(null);
 }
Exemple #11
0
	public void SetSelected()
	{
        if (isSelected)
            return;

		isSelected = true;
		var colors = button.colors;
		colors.normalColor = inUseColor;
		button.colors = colors;
		button.GetComponent<UnityEngine.UI.Image>().color = inUseColor;
        ability.PrePurchase();
	}
 private void UpdateButtons()
 {
     if (GraphSearchAlgorithm.IsSearching)
     {
         StartButton.GetComponent <Button>().interactable = false;
         GoalButton.GetComponent <Button>().interactable  = false;
         ResetButton.GetComponent <Button>().interactable = false;
     }
     else
     {
         StartButton.GetComponent <Button>().interactable = true;
         GoalButton.GetComponent <Button>().interactable  = true;
         ResetButton.GetComponent <Button>().interactable = true;
     }
 }
Exemple #13
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Pickup") && other.gameObject.GetComponent <Pickups>().isPickable)
        {
            switch (other.gameObject.name)
            {
            case ("Käse"):
                cheeseAmount++;
                break;

            case ("Wurst"):
                sausageAmount++;
                break;

            case ("Fleisch"):
                meatAmount++;
                break;

            case ("Soße"):
                sauceAmount++;
                break;
            }
            inventoryButton.GetComponent <Animator>().SetTrigger("itemAdded");
            Destroy(other.gameObject);
        }
    }
Exemple #14
0
    void ChangeShopHat()
    {
        SoundManager.Clicks.Play();

        obShopWp.enabled = true;
        obShopWp.GetComponent <UnityEngine.UI.Image> ().sprite = FrameUnChoose;
        shopWpGob.SetActive(false);

        obShopHat.enabled = false;
        obShopHat.GetComponent <UnityEngine.UI.Image> ().sprite = FrameChoose;
        shopHatGob.SetActive(true);

        obShopFoot.enabled = true;
        obShopFoot.GetComponent <UnityEngine.UI.Image> ().sprite = FrameUnChoose;
        shopFootGob.SetActive(false);
    }
        private IEnumerator Start()
        {
            yield return(null);

            var localData = LocalSaveSystem.LoadLocalData();

            musicSlider.value       = localData.Settings.MusicVolume;
            soundsSlider.value      = localData.Settings.SoundsVolume;
            antiAliasingToggle.isOn = localData.Settings.Antialiasing;
            shadowsToggle.isOn      = localData.Settings.Shadows;

            ChangeMusicVolume(localData.Settings.MusicVolume);
            ChangeSoundsVolume(localData.Settings.SoundsVolume);
            QualitySettings.antiAliasing =
                localData.Settings.Antialiasing ? (int)AntiAliasing.Enabled : (int)AntiAliasing.Disabled;
            QualitySettings.shadows =
                localData.Settings.Shadows ? ShadowQuality.HardOnly : ShadowQuality.Disable;

            switch (LocalizationSettings.SelectedLocale.Identifier.Code)
            {
            case "en":
                englishLocaleButton.GetComponent <Util.Button>().SelectOnStart();
                break;

            case "ru":
                russianLocaleButton.GetComponent <Util.Button>().SelectOnStart();
                break;
            }
        }
    // Update is called once per frame
    void onMiscibleclick()
    {
        if (qno == 0)
        {
            t.text      = "water and oil are immiscible. Choose the correct option to proceed";
            t.fontSize  = 12;
            t.fontStyle = FontStyle.Bold;
            t.color     = Color.red;
        }

        else if (qno == 1)
        {
            t.text     = "CORRECT";
            t.fontSize = 15;
            t.color    = Color.green;
            qno++;
            StartCoroutine(wait());
            t.text     = "How will you remove grease stains from cotton fabrics?";
            t.color    = Color.white;
            t.fontSize = 12;
            Destroy(miscibleb.gameObject);
            Destroy(imiscibleb.gameObject);
            RectTransform rt = IF.GetComponent <RectTransform>();
            rt.localScale = new Vector3(1, 1, 1);
            rt            = submitb.GetComponent <RectTransform>();
            rt.localScale = new Vector3(1, 1, 1);
        }
    }
Exemple #17
0
    void StartRound()
    {
        if (autoHideUI)
        {
            hideUI.GetComponent <HideUI>().Hide();
        }

        numSecondsRemaining = kNumSecondsPerRound;
        foreach (var txtVote in votes)
        {
            txtVote.text = "";
        }

        player.transform.position = player.GetComponent <CharacterMove>().startPosition;
        for (int i = 0; i < NPCs.childCount; i++)
        {
            NPCs.GetChild(i).gameObject.SetActive(true);
            NPCs.GetChild(i).transform.position = NPCs.GetChild(i).GetComponent <CharacterMove>().startPosition;
            NPCs.GetChild(i).GetComponent <NPC>().ReEvalInfluences();
        }
        for (int i = 0; i < Judges.childCount; i++)
        {
            Judges.GetChild(i).gameObject.SetActive(true);
            Judges.GetChild(i).transform.position = Judges.GetChild(i).GetComponent <CharacterMove>().startPosition;
        }
    }
Exemple #18
0
    // Use this for initialization
    void Start()
    {
        girlImage = girlPlayer.GetComponent <Image>();
        boyImage  = boyPlayer.GetComponent <Image>();

        rockImage   = rockButton.GetComponent <Image>();
        forestImage = forestButton.GetComponent <Image>();

        userName.text = DataController.GetUser();

        selectedCharacter = DataController.GetCharacter();
        if (selectedCharacter == "girl")
        {
            girlButtonClick();
        }
        else
        {
            boyButtonClick();
        }

        selectedSkin = DataController.GetSkin();
        if (selectedSkin == "rocks")
        {
            rockButtonClick();
        }
        else
        {
            forestButtonClick();
        }
    }
Exemple #19
0
 // Update is called once per frame
 void Update()
 {
     if (b.GetComponent <UnityEngine.UI.Image>().color.Equals(new Color(76f / 255f, 255f / 255f, 159f / 255f)))
     {
         sphere.GetComponent <Renderer>().material.mainTexture = t;
     }
 }
Exemple #20
0
    void Update()
    {
        timer -= (timer > -1.0f ? Time.deltaTime * 5 : 0);

        if (timer <= 0 && IsResume)
        {
            this.gameObject.SetActive(false);
        }
        else if (timer <= 0 && IsMainMenu)
        {
            SceneManager.LoadScene(0);
        }

        if (button[0].GetComponent <buttonbehaviour>().isOn == false && button[1].GetComponent <buttonbehaviour>().isOn == false)
        {
            resume.GetComponent <buttonbehaviour>().isOn = true;
            currentButton = 0;
        }

        if (IsVertical)
        {
            if (XCI.GetAxis(XboxAxis.LeftStickY) < 0 && timer <= 0)
            {
                timer = 1.0f;
                currentButton++;
            }

            if (XCI.GetAxis(XboxAxis.LeftStickY) > 0 && timer <= 0)
            {
                timer = 1.0f;
                currentButton--;
            }
        }
        else
        {
            if (XCI.GetAxis(XboxAxis.LeftStickX) < 0 && timer <= 0)
            {
                timer = 1.0f;
                currentButton--;
            }

            if (XCI.GetAxis(XboxAxis.LeftStickX) > 0 && timer <= 0)
            {
                timer = 1.0f;
                currentButton++;
            }
        }


        currentButton = (currentButton > 1 ? 0 : (currentButton < 0 ? 0 : currentButton));

        buttonBehaviours[0].isOn = (currentButton == 0 ? true : false);
        buttonBehaviours[1].isOn = (currentButton == 1 ? true : false);

        if (XCI.GetButtonDown(XboxButton.A) && timer <= 0)
        {
            timer = 1.0f;
            ButtonPressed(button[currentButton]);
        }
    }
Exemple #21
0
    // Start is called before the first frame update
    void Start()
    {
        //Adds a listener to the input field to invoke a method when the value changes.
        inputField.onValueChanged.AddListener(delegate { InputFieldValueChange(); });

        // Add listener to button click
        editButton.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(OnEditButtonClick);
    }
Exemple #22
0
 void Start()
 {
     GameOverCanvas         = GameOverCanvas.GetComponent <Canvas>();
     GameOverCanvas.enabled = false;
     btnUp     = btnUp.GetComponent <UnityEngine.UI.Button>();
     btnDown   = btnDown.GetComponent <UnityEngine.UI.Button>();
     btnLaunch = btnLaunch.GetComponent <UnityEngine.UI.Button>();
 }
Exemple #23
0
    private void ButtonPressed(UnityEngine.UI.Button currentButton)
    {
        currentButton.GetComponent <buttonbehaviour>().Pressed();
        timer = 1.0f;

        IsResume   = (currentButton == resume ? true : false);
        IsMainMenu = (currentButton == mainMenu ? true : false);
    }
Exemple #24
0
 /**
  * <summary>Gets the boundary of the element</summary>
  * <param name = "_slot">Ignored by this subclass</param>
  * <returns>The boundary Rect of the element</returns>
  */
 public override RectTransform GetRectTransform(int _slot)
 {
     if (uiButton)
     {
         return(uiButton.GetComponent <RectTransform>());
     }
     return(null);
 }
    public void achieved(UnityEngine.UI.Button input)
    {
        UnityEngine.UI.Button     button     = input.GetComponent("Button") as UnityEngine.UI.Button;
        UnityEngine.UI.ColorBlock colorblock = new UnityEngine.UI.ColorBlock();
        colorblock.normalColor      = new Color(255f, 215f, 0f, 1.0f);
        colorblock.pressedColor     = new Color(255f, 215f, 0f, 1.0f);
        colorblock.disabledColor    = new Color(255f, 215f, 0f, 1.0f);
        colorblock.highlightedColor = new Color(255f, 215f, 0f, 1.0f);
        colorblock.colorMultiplier  = 1f;
        button.colors = colorblock;
        UnityEngine.UI.Image image = input.GetComponent("Image") as UnityEngine.UI.Image;
        image.color = new Color(255f, 215f, 0f, 1.0f);

        UnityEngine.UI.Text text = input.GetComponentInChildren <UnityEngine.UI.Text> ();
        text.color = new Color(0f, 0f, 0f, 1f);

        GetComponent <AudioSource>().Play();
    }
Exemple #26
0
 public Button(UnityEngine.UI.Button button)
 {
     this.button = button;
     img         = button.GetComponent <Image>();
     button.onClick.AddListener(delegate
     {
         Activate();
         OnActivated();
     });
 }
Exemple #27
0
    public void OnTriggerEnter(Collider col)
    {
        const float REF_VALUE = 0.5f;
        Coordinate  movement  = new Coordinate(0, 0);

        if (transform.localPosition.x > REF_VALUE)
        {
            movement.x = -1;
        }
        else if (transform.localPosition.x < -REF_VALUE)
        {
            movement.x = 1;
        }
        else if (transform.localPosition.z > REF_VALUE)
        {
            movement.z = -1;
        }
        else if (transform.localPosition.z < -REF_VALUE)
        {
            movement.z = 1;
        }

        Game        game     = Game.getInstance();
        const float DISTANCE = 2.0f;
        Coordinate  current  = Coordinate.fromRealPoint(transform.parent.transform.position);

        Coordinate next = current + movement;

        if (game.isMovableAt(next))
        {
            transform.parent.Translate(new Vector3(movement.x * DISTANCE, 0.0f, movement.z * DISTANCE));
            applyAppropriateColor();

            game.moveCube(current, next);

            if (game.isCompleted())
            {
                GameObject btn = (GameObject)Instantiate(Button);

                UnityEngine.UI.Button btn2 = btn.GetComponent <UnityEngine.UI.Button>();

                RectTransform rect = btn2.GetComponent <RectTransform>();
                rect.anchorMax = new Vector2(1, 1);
                rect.anchorMin = new Vector2(1, 1);
                rect.position  = new Vector3(-92.0f, -64.0f, 0.0f);
                btn2.transform.SetParent(canvas.transform, false);

                btn2.onClick.AddListener(() => {
                    Game.currentStage++;
                    Application.LoadLevel(Application.loadedLevel);
                });
            }
        }
    }
Exemple #28
0
    // Start is called before the first frame update
    void Start()
    {
        rigi = GetComponent <Rigidbody2D>();
        Button repeat = repeatButton.GetComponent <Button>();

        repeat.onClick.AddListener(TaskOnClick1);
        if (Health.hpValue >= 1 && fuel.fuelValue >= 1)
        {
            repeatButton.gameObject.SetActive(false);
        }
    }
Exemple #29
0
 void dictationToggleUI_(bool bOn)
 {
     if (bOn)
     {
         btnVoiceTest.GetComponent <RectTransform>().localScale = Vector3.one * 1.2f;
         var text = btnVoiceTest.GetComponentInChildren <UnityEngine.UI.Text>();
         if (text != null)
         {
             text.text = "現在 音声入力ON";
         }
     }
     else
     {
         btnVoiceTest.GetComponent <RectTransform>().localScale = Vector3.one;
         var text = btnVoiceTest.GetComponentInChildren <UnityEngine.UI.Text>();
         if (text != null)
         {
             text.text = "現在 音声入力OFF";
         }
     }
 }
Exemple #30
0
    /* Core of the game's code */
    void Update()
    {
        // This creates a small buffer timer so that the game doesn't just zip from text to text
        while (timer >= 0)
        {
            timer -= Time.deltaTime;
            return;
        }

        // Moves things along if any key is pressed
        if (!Input.anyKeyDown)
        {
            return;
        }

        // Variable for formatting
        float offset = 0;

        // If the story can continue and a key has been pressed, clears the board, creates new text, and resets timer.
        if (_inkStory.canContinue)
        {
            RemoveChildren();
            GetText(offset);
        }

        // Calls the CheckVariables method
        CheckVariables();
        EncounterDesign();

        // If there are choices and the the needChoices variable is set, then this will create the choices
        if (_inkStory.currentChoices.Count > 0 && needChoices)
        {
            for (int ii = 0; ii < _inkStory.currentChoices.Count; ++ii)
            {
                UnityEngine.UI.Button choice = Instantiate(button);
                choice.transform.SetParent(canvas.transform, false);
                choice.transform.Translate(new Vector2(0, offset));

                TextMeshProUGUI choiceText = choice.GetComponentInChildren <TextMeshProUGUI> ();
                choiceText.text = _inkStory.currentChoices [ii].text;
                StartCoroutine(FadeImageToFullAlpha(2f, choice.image));
                StartCoroutine(FadeTextToFullAlpha(2f, choice.GetComponentInChildren <TextMeshProUGUI>()));
                UnityEngine.UI.HorizontalLayoutGroup layoutGroup = choice.GetComponent <UnityEngine.UI.HorizontalLayoutGroup> ();

                int choiceId = ii;
                choice.onClick.AddListener(delegate { ChoiceSelected(choiceId); });

                offset -= (choiceText.fontSize + layoutGroup.padding.top + layoutGroup.padding.bottom + elementPadding);
            }
            timer       = 1.0f;
            needChoices = false;
        }
    }
Exemple #31
0
 public static void SetAnchor(AnchorType at, Button button)
 {
     SetAnchor(at, button.GetComponent<RectTransform>());
 }
 private void PaintButton(Button button, Color color)
 {
     button.GetComponent<Image>().color = color;
 }
Exemple #33
0
 public static void SetSize(float x, float y, Button button)
 {
     SetSize(x, y, button.GetComponent<RectTransform>());
     for (int i = 0; i < button.transform.childCount; i++)
     {
         var text = button.transform.GetChild(i).GetComponent<Text>();
         if (text != null)
             SetTextSize(text, 45);
     }
 }
Exemple #34
0
 public static void SetPosition(float x, float y, Button button)
 {
     SetPosition(x, y, button.GetComponent<RectTransform>());
 }
Exemple #35
0
		void SetButtonOffset(Button button,float offsetX)
		{
			RectTransform rectTransform = button.GetComponent<RectTransform>();
			rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left,offsetX,rectTransform.rect.width);
		}