Esempio n. 1
0
    // Use this for initialization


    void Awake() {
        if (instance != null && instance != this) {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
        }
        if (instance == null) {
            instance = this;
            mainPanel = transform.Find("MainPanel").gameObject;
            settingsPanel = transform.Find("Settings").gameObject;
            controlsPanel = transform.Find("ControlsPanel").gameObject;
            menuConfirmPanel = transform.Find("MenuConfirm").gameObject;
            desktopConfirmPanel = transform.Find("DesktopConfirm").gameObject;
            background = transform.Find("Background").gameObject;

            resumeButton = transform.Find("MainPanel/ResumeButton").GetComponent<UnityEngine.UI.Button>();
            settingsButton = transform.Find("MainPanel/SettingsButton").GetComponent<UnityEngine.UI.Button>();
            controlsButton = transform.Find("MainPanel/ControlsButton").GetComponent<UnityEngine.UI.Button>();
            menuButton = transform.Find("MainPanel/MenuButton").GetComponent<UnityEngine.UI.Button>();
            quitButton = transform.Find("MainPanel/QuitButton").GetComponent<UnityEngine.UI.Button>();

            settingsBackButton = transform.Find("Settings/BackButton").GetComponent<UnityEngine.UI.Button>();
            controlsBackButton = transform.Find("ControlsPanel/BackButton").GetComponent<UnityEngine.UI.Button>();
            /*
            controlsKeyboardButton = transform.Find("ControlsPanel/KeyboardButton").GetComponent<UnityEngine.UI.Button>();
            controlsPadButton = transform.Find("ControlsPanel/PadButton").GetComponent<UnityEngine.UI.Button>();
            */

        }
    }
Esempio n. 2
0
 void Start()
 {
     HeaderText = this.GetComponentsInChildren<Text>().First(t => t.name == "headertext");
     HeaderText.text = Card.Name;
     PlayButton = this.GetComponentsInChildren<Button>().First(i => i.name == "PlayButton");
     PlayButton.onClick.AddListener(HandleClick);
 }
Esempio n. 3
0
        public void Awake()
        {
            _button = GetComponent<Button>();
            IsInteractable = _button.interactable;

            StateChanged();
        }
Esempio n. 4
0
        public void CopyButton(MenuButton _element)
        {
            uiButton = _element.uiButton;
            uiText = _element.uiText;
            label = _element.label;
            hotspotLabel = _element.hotspotLabel;
            hotspotLabelID = _element.hotspotLabelID;
            anchor = _element.anchor;
            textEffects = _element.textEffects;
            buttonClickType = _element.buttonClickType;
            simulateInput = _element.simulateInput;
            simulateValue = _element.simulateValue;
            doFade = _element.doFade;
            switchMenuTitle = _element.switchMenuTitle;
            inventoryBoxTitle = _element.inventoryBoxTitle;
            shiftInventory = _element.shiftInventory;
            loopJournal = _element.loopJournal;
            actionList = _element.actionList;
            inputAxis = _element.inputAxis;
            clickTexture = _element.clickTexture;
            clickAlpha = _element.clickAlpha;
            shiftAmount = _element.shiftAmount;
            onlyShowWhenEffective = _element.onlyShowWhenEffective;
            allowContinuousClick = _element.allowContinuousClick;
            parameterID = _element.parameterID;
            parameterValue = _element.parameterValue;

            base.Copy (_element);
        }
Esempio n. 5
0
        void Awake()
        {
            Transform PanelMessageContainer0 = transform.FindChild("PanelMessageContainer");
            messageContainer = PanelMessageContainer0.GetComponent<RectTransform>();
            Transform PanelSystemContainer00 = PanelMessageContainer0.FindChild("PanelSystemContainer");
            systemContainer = PanelSystemContainer00.GetComponent<RectTransform>();
            Transform PanelSystemRichEdit000 = PanelSystemContainer00.FindChild("PanelSystemRichEdit");
            systemRichEdit = PanelSystemRichEdit000.GetComponent<RectTransform>();
            Transform PanelChatContainer01 = PanelMessageContainer0.FindChild("PanelChatContainer");
            chatContainer = PanelChatContainer01.GetComponent<RectTransform>();
            Transform PanelChatRichEdit010 = PanelChatContainer01.FindChild("PanelChatRichEdit");
            chatRichEdit = PanelChatRichEdit010.GetComponent<RectTransform>();
            Transform PanelChatButtonContainer011 = PanelChatContainer01.FindChild("PanelChatButtonContainer");
            chatButtonContainer = PanelChatButtonContainer011.GetComponent<RectTransform>();
            Transform InputFieldChat0110 = PanelChatButtonContainer011.FindChild("InputFieldChat");
            Transform TextChatInputText01100 = InputFieldChat0110.FindChild("ChatInputText");
            chatInputText = TextChatInputText01100.GetComponent<Text>();
            Transform ButtonChatFace0111 = PanelChatButtonContainer011.FindChild("ButtonChatFace");
            buttonChatFace = ButtonChatFace0111.GetComponent<Button>();
            buttonChatFace.onClick.AddListener(OnButtonChatFaceClicked);

            Transform ButtonSend0112 = PanelChatButtonContainer011.FindChild("ButtonSend");
            buttonSend = ButtonSend0112.GetComponent<Button>();
            buttonSend.onClick.AddListener(OnButtonSendClicked);

            Transform PanelMainButtonContainer1 = transform.FindChild("PanelMainButtonContainer");
            mainButtonContainer = PanelMainButtonContainer1.GetComponent<RectTransform>();
            Transform ButtonSystem10 = PanelMainButtonContainer1.FindChild("ButtonSystem");
            buttonSystem = ButtonSystem10.GetComponent<Button>();
            buttonSystem.onClick.AddListener(OnButtonSystemClicked);

            Transform ButtonChat11 = PanelMainButtonContainer1.FindChild("ButtonChat");
            buttonChat = ButtonChat11.GetComponent<Button>();
            buttonChat.onClick.AddListener(OnButtonChatClicked);
        }
Esempio n. 6
0
 void Start()
 {
     quitMenu = quitMenu.GetComponent<Canvas>();
     quitMenu.enabled = false;
     startText = startText.GetComponent<Button>();
     exitText = exitText.GetComponent<Button>();
 }
Esempio n. 7
0
 void Start()
 {
     button = GetComponent<UnityEngine.UI.Button>();
     text = GetComponentInChildren<Text>();
     canvasGroup = GetComponent<CanvasGroup>();
     normalGlow = glow.color;
 }
Esempio n. 8
0
 public void SetEnabled(Button button, bool enabled)
 {
     if (enabled)
         Enable(button);
     else
         Disable(button);
 }
Esempio n. 9
0
        public ButtonObject(string buttonImageFileName, string text, Action onClick)
        {
            Go = Resources.Load(Settings.Instance.PREFAB_PATH + "Button") as GameObject;
               // Go.SetActive(false);
            Go = GameObject.Instantiate<GameObject>(Go);

            _image = Go.GetComponent<Image>();

            Sprite sprite = Resources.Load<Sprite>(Settings.Instance.UI_IMAGE_PATH + buttonImageFileName);

            if (_image && sprite)
            {
                _image.sprite = sprite;
            }
            else
            {
                Debug.Log("Do not find image file");
            }

            _text = Go.GetComponentInChildren<Text>();
            _text.text = text;

            _button = Go.GetComponent<Button>();
            if(_button)
            {
                _button.onClick.AddListener(new UnityEngine.Events.UnityAction(onClick));
            }
        }
Esempio n. 10
0
 // Use this for initialization
 public void EnableButton()
 {
     ThisButton = gameObject.AddComponent<UnityEngine.UI.Button>();
     ThisButton.transition = Selectable.Transition.None;
     ThisButton.onClick.RemoveAllListeners();
     ThisButton.onClick.AddListener( () => OnAClick() );
 }
Esempio n. 11
0
    public override void Awake()
    {
        base.Awake();
        if (gameObject.transform is RectTransform)
        {
            var input = gameObject.GetComponent<InputField>();
            if (input != null)
            {
                input.onEndEdit.AddListener((text)=> OnClick());
                return;
            }

            button = GetComponent<UnityEngine.UI.Button>();
            if (button == null)
            {
                if (GetComponent<UnityEngine.UI.Toggle>() == null)
                {
                    button = gameObject.AddComponent<UnityEngine.UI.Button>();
                    button.interactable = true;
                    button.transition = Selectable.Transition.None;
                }

            }
            if (button != null && button.onClick.GetPersistentEventCount() == 0)
            {                
                button.onClick.AddListener(OnClick);
            }
        }
    }
        // Use this for initialization
        void Start()
        {
            if (this.player == null)
                return;
            this.stats_panel = transform.Find("Stats").gameObject;
            this.undefined_panel = transform.Find("Undefined").gameObject;
            this.name_text = transform.Find("Name").GetComponent<Text>();
            this.defi_text = transform.Find("Defi").Find("Text").GetComponent<Text>();
            this.name_text.text = this.player.Name;
            this.defi_text.text = "Defi";
            //this.manager = GameObject.Find("Manager").GetComponent<PhiManager>();

            InstantiateSwungMen();
            SetUpStats();

            this.buy = transform.Find("Buy").GetComponent<Button>();
            this.unlocked = Settings.Instance.Default_player.ContainsKey(this.player.UID);
            if (this.unlocked)
            {
                this.undefined_panel.SetActive(false);
                BoughtButton();
            }
            else
            {
                this.swungMen.SetActive(false);
            }
        }
Esempio n. 13
0
        // Use this for initialization
        private void Start()
        {
            this.unlocked = false;
            // f**k compiler warnings :D
            if (this.unlocked) { }
            this.upgraded = false;

            this.upgradeName = this.GetComponentInChildren<Text>();

            this.unlockButton = this.GetComponent<Button>();
            this.unlockButton.image.sprite = this.regularImg;

            this.upgrade = this.upgradeObj.GetComponent<IUpgrade>();
            this.upgradeName.text = this.upgrade.Name;

            foreach (Skill s in this.requiredSkills)
            {
                s.unlockSkill = this;
                //_RequiredUnlocks += 1;
            }

            if (this.requiredSkills.Length != 0)
            {
                this.unlockButton.image.sprite = this.lockedImg;
                this.unlockButton.interactable = false;

            }
        }
Esempio n. 14
0
        private void Start()
        {
            gridRect = GetComponentInParent<RectTransform>();
            gridCanvas = GetComponentInParent<Canvas>();
            gridLayout = GetComponentInParent<GridLayoutGroup>();

            gridRect.pivot = new Vector2(0, 0);
            gridRect.position = new Vector3(terrainMesh.transform.position.x, 6.0f, terrainMesh.transform.position.z);
            gridRect.anchorMin = new Vector2(terrainMesh.transform.position.x, terrainMesh.transform.position.z);
            gridRect.anchorMax = new Vector2(terrainMesh.terrainData.size.x, terrainMesh.terrainData.size.z);

            gridLayout.CalculateLayoutInputHorizontal();

            Debug.Log(string.Format("Origin: {0}, Size: {1}, Cell size: {2}\n", gridRect.position.ToString(), gridRect.rect.size.ToString(), gridLayout.cellSize));

            buttonTemplate = GetComponentInChildren<Button>();
            for (int y = 0; y < gridRect.rect.y; y++)
            {
                for (int x = 0; x < gridRect.rect.x; x++)
                {
                    Vector3 pos = new Vector3(x, 0, y); // * spacing;
                    Button b = (Button)Instantiate(buttonTemplate, pos, Quaternion.identity);
                    //b.gameObject.AddComponent<LayoutElement>();

                    //b.name = "Button " + x.ToString() + "," + y.ToString();
                    //b.GetComponentInChildren<Text>().text = b.name;
                    gridLayout.SetLayoutHorizontal();
                }
            }
        }
Esempio n. 15
0
		override public void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
		{
			if (firstField == null)
			{
				var firstFieldTransform = animator.transform.Find(firstFieldPath);
				if (firstFieldTransform != null)
				{
					firstField = firstFieldTransform.GetComponent<InputField>();
				}
			}

			if (submitButton == null)
			{
				var submitButtonTransform = animator.transform.Find(submitButtonPath);
				if (submitButtonTransform != null)
				{
					submitButton = submitButtonTransform.GetComponent<Button>();
				}
			}

			if (firstField != null)
			{
				firstField.Select();
			}
		}
Esempio n. 16
0
 public ListItem(GameObject gameObj, Text text, RectTransform rt, Image background, Button button)
 {
     this.gameObj = gameObj;
     this.text = text;
     this.rt = rt;
     this.background = background;
     this.button = button;
 }
Esempio n. 17
0
 public UnityButton(IGameObject obj)
     : base(obj)
 {
     btn = obj.GetComponent<Button>();
     if (null == btn) {
         throw new NullReferenceException("Object " + obj.Name  + " expected to have a UnityEngine.UI.Button but none was found");
     }
 }
Esempio n. 18
0
        void Start()
        {
            _button = GetComponent<Button>();
            _text = transform.FindChild("Text").GetComponent<Text>();
            _text.text = addRobotText;

            _button.onClick.AddListener(OnAddRobot);
        }
	/// <summary>
	/// 初期化
	/// </summary>
	/// <param name="data">セーブデータ</param>
	/// <param name="index">インデックス</param>
	/// <param name="isSave">セーブ画面用ならtrue、ロード画面用ならfalse</param>
	public void Init(AdvSaveData data, Action<UtageUguiSaveLoadItem> ButtonClickedEvent, int index, bool isSave)
	{
		this.data = data;
		this.index = index;
		this.button = this.GetComponent<UnityEngine.UI.Button>();
		this.button.onClick.AddListener( ()=>ButtonClickedEvent(this) );
		Refresh(isSave);
	}
Esempio n. 20
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>();
 }
Esempio n. 21
0
        public override void OnRegister()
        {
            base.OnRegister();

            m_Button = GetComponent<Button>();

            m_Button.onClick.AddListener(OnClick);
        }
        void Awake()
        {
            _win = this.GetComponent<Canvas>();
            _label = this.GetComponentInChildren<Text>();
            _win.enabled = false;

            _yes = GameObject.Find("Yes").GetComponent<Button>();
        }
Esempio n. 23
0
		public override void SetUpElementProperties ()
		{
			base.SetUpElementProperties ();
			if (button == null) {
				button = gameObject.GetComponent<Button> ();
			}
			rectTransform.sizeDelta = new Vector2 (140, 20);
		}
Esempio n. 24
0
 /**
  * The default Constructor.
  */
 public UISlot()
 {
     uiButton = null;
     uiButtonID = 0;
     uiText = null;
     uiImage = null;
     sprite = null;
 }
Esempio n. 25
0
        void Awake()
        {
            _uiText_GameTime = GameObject.Find("Text_GameTime").GetComponent<Text>();
            _uiText_OrbitalJumps = GameObject.Find("Text_OrbitalJumps").GetComponent<Text>();
            _uiButton_Continue = GameObject.Find("Btn_Continue").GetComponent<Button>();

            _uiButton_Continue.onClick.AddListener(HideCompleteLevelMenu);
        }
		void Start()
		{
			button = GetComponent<Button>();
			if (button!=null)
			{
				button.onClick.AddListener(Click);
			}
		}
Esempio n. 27
0
        void Update()
        {
            if (Button == null)
                Button = GetComponent<Button>();

            if (Button != null)
                ApplyStyle(Button);
        }
Esempio n. 28
0
		// Use this for initialization
		void Start () {
			audioSource = gameObject.AddComponent<AudioSource>();

			button = GetComponent<Button>();

//			button.onClick.AddListener ( () => {ClickSound();});

		}
Esempio n. 29
0
    // Use this for initialization
    void Start()
    {
        button = GetComponent<UnityEngine.UI.Button>();
        textbox = GetComponentInChildren<UnityEngine.UI.Text>();

        Enabled = LevelNumber <= PlayerPrefs.GetFloat("game.lastlevel", 1);

        textbox.text = Enabled ? LevelNumber.ToString() : string.Empty;
    }
Esempio n. 30
0
 protected override void Awake(GameObject rGo)
 {
     base.Awake(rGo);
     btnClose = Util.Get<Button>(gameObject, "ButtonClose");
     btnClose.onClick.AddListener(() =>
     {
         Hide();
     });
 }
Esempio n. 31
0
 void Start()
 {
     buttonToValidate = this.gameObject.GetComponent <UnityEngine.UI.Button>();
 }
Esempio n. 32
0
 void Start()
 {
     button = GetComponent <UnityEngine.UI.Button>();
     button.onClick.AddListener(OnClick);
 }
Esempio n. 33
0
 public void ToggleButton(UnityEngine.UI.Button button)
 {
     button.interactable = !button.interactable;
 }
Esempio n. 34
0
 public static void SetClickFunc(this UI.Button _this, Events.UnityAction callback)
 {
     _this.onClick.AddListener(callback);
 }
 void AddListener(UnityEngine.UI.Button b, string value)
 {
     b.onClick.AddListener(() => OnValidationClickedValue(value));
 }
Esempio n. 36
0
    /// <summary>
    /// A function to implement the spinner behaviour.
    /// </summary>
    /// <param name="mgr">The application manager.</param>
    /// <param name="actor">The actor that owns the parameter the widget is being setup for.</param>
    /// <param name="btn">The spinner button.</param>
    /// <param name="ev">The parameter value.</param>
    /// <param name="ve">The parameter's widget.</param>
    public static void SetupWidgetDrag(Main mgr, SceneActor actor, UnityEngine.UI.Button btn, EditValue ev, ValueEditor_Base ve)
    {
        UnityEngine.EventSystems.EventTrigger et =
            btn.gameObject.AddComponent <UnityEngine.EventSystems.EventTrigger>();

        et.triggers = new List <UnityEngine.EventSystems.EventTrigger.Entry>();

        UnityEngine.EventSystems.EventTrigger.Entry aBeginDrag = new UnityEngine.EventSystems.EventTrigger.Entry();
        aBeginDrag.eventID = UnityEngine.EventSystems.EventTriggerType.BeginDrag;
        aBeginDrag.callback.AddListener(
            (x) =>
        {
            UnityEngine.EventSystems.PointerEventData ped = x as UnityEngine.EventSystems.PointerEventData;

            if (ve.escapeCheck != null)
            {
                ve.StopCoroutine(ve.escapeCheck);
            }

            ve.escapeCheck = ve.StartCoroutine(EndDragOnEscape(ped, mgr, actor, ve));

            startingDragValue = ev.val.Clone();
            startDrag         = ped.position;
        });

        UnityEngine.EventSystems.EventTrigger.Entry aEndDrag = new UnityEngine.EventSystems.EventTrigger.Entry();
        aEndDrag.eventID = UnityEngine.EventSystems.EventTriggerType.EndDrag;
        aEndDrag.callback.AddListener(
            (x) =>
        {
            UnityEngine.EventSystems.PointerEventData ped = x as UnityEngine.EventSystems.PointerEventData;

            ValFloat diff = new ValFloat(-(startDrag.y - ped.position.y));
            Val vb        = ev.Offset(startingDragValue, diff);
            ev.val.SetValue(vb);

            mgr.NotifyActorModified(actor, ev.name);
            if (ve != null && ve.escapeCheck != null)
            {
                ve.StopCoroutine(ve.escapeCheck);
                ve.escapeCheck = null;
            }
        });

        UnityEngine.EventSystems.EventTrigger.Entry aDrag = new UnityEngine.EventSystems.EventTrigger.Entry();
        aDrag.eventID = UnityEngine.EventSystems.EventTriggerType.Drag;
        aDrag.callback.AddListener(
            (x) =>
        {
            UnityEngine.EventSystems.PointerEventData ped = x as UnityEngine.EventSystems.PointerEventData;

            ValFloat diff = new ValFloat(-(startDrag.y - ped.position.y));
            Val vb        = ev.Offset(startingDragValue, diff);
            ev.val.SetValue(vb);

            mgr.NotifyActorModified(actor, ev.name);
        });

        et.triggers.Add(aBeginDrag);
        et.triggers.Add(aEndDrag);
        et.triggers.Add(aDrag);
    }
    public void createValidationsList()
    {
        int nrentries       = m_ValidationSessionNames.Count;
        int nrentriesactive = m_ValidationSessionNames.Count;

        m_Buttons      = new ArrayList();
        m_ButtonsStart = new ArrayList();
        m_ButtonsStop  = new ArrayList();
        m_ButtonsIds   = new ArrayList();


        RectTransform rectTransform2 = m_Content.GetComponent <RectTransform>();
        float         scalex         = rectTransform2.sizeDelta.x;
        float         scaley         = rectTransform2.sizeDelta.y;
        float         heightentry    = 260.0f;//280.0f;//350.0f;

        rectTransform2.sizeDelta = new Vector2(scalex, heightentry * nrentriesactive + 100.0f);


        string sessions = PlayerPrefs.GetString("ActiveSessions");

        string[] splitArray = sessions.Split(char.Parse(" "));


        float posoffset      = 0;
        int   nrentriesadded = 0;
        int   curreport      = 1;

        for (int i = nrentries - 1; i >= 0; i--)
        {
            Debug.Log("Create validation entry: " + i);

            GameObject    copy;
            RectTransform rectTransform;
            float         curpos;
            float         curposx;
            int           currank;
            string        text;

            nrentriesadded++;

            copy = (GameObject)GameObject.Instantiate(m_NameS);
            copy.transform.SetParent(m_Content.transform, false);
            copy.SetActive(true);
            rectTransform = copy.GetComponent <RectTransform>();
            curpos        = rectTransform.localPosition.y;
            curposx       = rectTransform.localPosition.x;
            curpos       -= posoffset;//i * heightentry;
            rectTransform.localPosition = new Vector2(curposx, curpos);
            m_AddedTexts.Add(copy);
            copy.GetComponentInChildren <UnityEngine.UI.Text>().text = (string)m_ValidationSessionNames[i];


            copy = (GameObject)GameObject.Instantiate(m_UploadQuest);
            copy.transform.SetParent(m_Content.transform, false);
            copy.SetActive(true);
            rectTransform = copy.GetComponent <RectTransform>();
            curpos        = rectTransform.localPosition.y;
            curposx       = rectTransform.localPosition.x;
            curpos       -= posoffset;//i * heightentry;
            rectTransform.localPosition = new Vector2(curposx, curpos);
            m_AddedTexts.Add(copy);

            m_Buttons.Add(copy);
            m_ButtonsIds.Add(i + "");
            copy.GetComponentInChildren <UnityEngine.UI.Text>().text = LocalizationSupport.GetString("ShowDetails");//"UPLOAD";

            UnityEngine.UI.Button b = copy.GetComponent <UnityEngine.UI.Button>();
            AddListener(b, i + "");



            string curvalidationid = (string)m_ValidationSessionIds[i];

            bool bActive = false;
            for (int active = 0; active < splitArray.Length && !bActive; active++)
            {
                if (splitArray[active] == curvalidationid)
                {
                    bActive = true;
                }
            }


            if (bActive == false)
            {
                copy = (GameObject)GameObject.Instantiate(m_DownloadQuest);
                copy.transform.SetParent(m_Content.transform, false);
                copy.SetActive(true);
                rectTransform = copy.GetComponent <RectTransform>();
                curpos        = rectTransform.localPosition.y;
                curposx       = rectTransform.localPosition.x;
                curpos       -= posoffset;//i * heightentry;
                rectTransform.localPosition = new Vector2(curposx, curpos);
                m_AddedTexts.Add(copy);

                m_Buttons.Add(copy);
                m_ButtonsStart.Add(copy);
                m_ButtonsStop.Add(copy);
                copy.GetComponentInChildren <UnityEngine.UI.Text>().text = LocalizationSupport.GetString("Start");//"UPLOAD";

                b = copy.GetComponent <UnityEngine.UI.Button>();
                AddListenerDownload(b, i + "");
            }
            else
            {
                copy = (GameObject)GameObject.Instantiate(m_DownloadQuest);
                copy.transform.SetParent(m_Content.transform, false);
                copy.SetActive(false);
                rectTransform = copy.GetComponent <RectTransform>();
                curpos        = rectTransform.localPosition.y;
                curposx       = rectTransform.localPosition.x;
                curpos       -= posoffset;//i * heightentry;
                rectTransform.localPosition = new Vector2(curposx, curpos);
                m_AddedTexts.Add(copy);

                m_ButtonsStart.Add(copy);
                copy.GetComponentInChildren <UnityEngine.UI.Text>().text = LocalizationSupport.GetString("Start");//"UPLOAD";

                b = copy.GetComponent <UnityEngine.UI.Button>();
                AddListenerDownload(b, i + "");



                copy = (GameObject)GameObject.Instantiate(m_StopQuest);
                copy.transform.SetParent(m_Content.transform, false);
                copy.SetActive(true);
                rectTransform = copy.GetComponent <RectTransform>();
                curpos        = rectTransform.localPosition.y;
                curposx       = rectTransform.localPosition.x;
                curpos       -= posoffset;//i * heightentry;
                rectTransform.localPosition = new Vector2(curposx, curpos);
                m_AddedTexts.Add(copy);

                m_ButtonsStop.Add(copy);
                copy.GetComponentInChildren <UnityEngine.UI.Text>().text = LocalizationSupport.GetString("Stop");//"UPLOAD";

                b = copy.GetComponent <UnityEngine.UI.Button>();
                AddListenerStop(b, i + "");
            }


            posoffset += heightentry;
        }

        Debug.Log("Validation list created");
    }
Esempio n. 38
0
    private UnityEngine.UI.Text prompt; //The UI text

    void Start()                        //Use this for initialization
    {
        //playerModel = m_Player.GetComponent<MeshFilter>(); //Get the player's model
        //playerTextureRenderer = m_Player.GetComponent<Renderer>(); //Get the player's texture renderer
        //enemyModel = m_Enemy.GetComponent<MeshFilter>(); //Get the enemy's model
        //enemyTextureRenderer = m_Enemy.GetComponent<Renderer>(); //Get the enemy's texture renderer

        playerTextureRenderer.material.color  = Color.black;
        enemyUITextureRenderer.material.color = Color.black;

        GameManager.playerColor = playerTextureRenderer.material.color;
        GameManager.enemyColor  = enemyUITextureRenderer.material.color;

        UnityEngine.UI.Image[] allUIImages = FindObjectsOfType <UnityEngine.UI.Image>();
        int numColorBoxes = 0;

        for (int i = 0; i < allUIImages.Length; i++) //For each UI image
        {
            if (allUIImages[i].name.Contains("Box"))
            {
                colorBoxes[numColorBoxes] = allUIImages[i];
                numColorBoxes++;
            }
            else if (allUIImages[i].name == "HighlightPlayer")
            {
                highlightPlayer = allUIImages[i];
            }
            else if (allUIImages[i].name == "HighlightEnemy")
            {
                highlightEnemy = allUIImages[i];
            }
        }

        UnityEngine.UI.Text[] allUIText = FindObjectsOfType <UnityEngine.UI.Text>();
        int numText = 0;

        for (int i = 0; i < allUIText.Length; i++) //For each UI image
        {
            if (allUIText[i].name.Contains("Text"))
            {
                UIText[numText] = allUIText[i];
                numText++;
            }
            else if (allUIText[i].name == "Prompt")
            {
                prompt = allUIText[i];
            }
        }

        UnityEngine.UI.Button[] allUIButtons = FindObjectsOfType <UnityEngine.UI.Button>();

        for (int i = 0; i < allUIButtons.Length; i++) //For each UI image
        {
            if (allUIButtons[i].name == "Start")
            {
                startButton = allUIButtons[i];
            }
        }

        //shouldPingPong = false;
        //ping = false;
        playerSelected         = true;
        highlightEnemy.enabled = false;
        startButton.enabled    = false;
    }
Esempio n. 39
0
    /**
     * @brief 어떤 행동인지 체크
     * @param activity 행동 코드
     * @param actButton 행동 버튼
     * @param actName 행동 이름
     * @param actDesc 행동 설명
     * @param costText 행동 비용
     */
    public void checkActivity(ACTIVITY activity, UnityEngine.UI.Button actButton, UnityEngine.UI.Text actName, UnityEngine.UI.Text actDesc, UnityEngine.UI.Image Frame, UnityEngine.UI.Text costText, UnityEngine.UI.Image costImg)
    {
        switch (activity)
        {
        case ACTIVITY.MOVE:
            actName.text     = "이동";
            actDesc.text     = "한 턴 소요";
            costText.enabled = false;
            costImg.enabled  = false;
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _range.AttackrangeTileReset(); _UnitGM.Move(); });
            canUseActivity(actButton, Frame, 0);
            break;

        case ACTIVITY.BUILD_MINE:
            actName.text     = "광산";
            actDesc.text     = "한 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = MINE_COST.ToString();
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _UnitGM.buildMine(); });
            canUseActivity(actButton, Frame, MINE_COST);
            break;

        case ACTIVITY.BUILD_FARM:
            actName.text     = "농장";
            actDesc.text     = "한 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = FARM_COST.ToString();
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _UnitGM.buildFarm(); });
            canUseActivity(actButton, Frame, FARM_COST);
            break;

        case ACTIVITY.BUILD_ATTACK_BUILDING:
            actName.text     = "터렛";
            actDesc.text     = "두 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = TURRET_COST.ToString();
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _UnitGM.buildAttackBuilding(); });
            canUseActivity(actButton, Frame, TURRET_COST);
            break;

        case ACTIVITY.BUILD_MILLITARY_BASE:
            actName.text     = "군사 기지";
            actDesc.text     = "두 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = MILITARYBASE_COST.ToString();
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _UnitGM.buildMillitaryBaseBuilding(); });
            canUseActivity(actButton, Frame, MILITARYBASE_COST);
            break;

        case ACTIVITY.BUILD_SHIELD_BUILDING:
            actName.text = "방어 건물";
            actDesc.text = "두 턴 소요";
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _UnitGM.buildShieldBuilding(); });
            break;

        case ACTIVITY.BUILD_UPGRADE_BUILDING:
            actName.text = "강화 건물";
            actDesc.text = "세 턴 소요";
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _UnitGM.buildUpgradeBuilding(); });
            break;

        case ACTIVITY.WORKER_UNIT_CREATE:
            actName.text     = "일꾼 생성";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = WORKER_COST.ToString();
            actButton.onClick.AddListener(delegate { _BuiltGM.act = activity; Castle.CreateUnitBtn(); });
            canUseActivity(actButton, Frame, WORKER_COST);
            break;

        case ACTIVITY.DESTROY_BUILT:
            actName.text     = "건물 파괴";
            costText.enabled = false;
            costImg.enabled  = false;
            actButton.onClick.AddListener(delegate { _BuiltGM.act = activity; _BuiltGM.DestroyBuilt(); });
            canUseActivity(actButton, Frame, 0);
            break;

        case ACTIVITY.ATTACK:
            actName.text     = "공격";
            actDesc.text     = "두 턴 소요";
            costText.enabled = false;
            costImg.enabled  = false;
            actButton.onClick.AddListener(delegate { _UnitGM.act = activity; _range.rangeTileReset(); _UnitGM.unitAttacking(); });
            canUseActivity(actButton, Frame, 0);
            break;

        case ACTIVITY.SOLDIER_0_UNIT_CREATE:
            actName.text     = "전사1 생성";
            actDesc.text     = "두 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = SOLDIER_0_COST.ToString();
            actButton.onClick.AddListener(delegate { _BuiltGM.act = activity; MillitaryBase.CreateAttackFirstUnitBtn(); });
            canUseActivity(actButton, Frame, SOLDIER_0_COST);
            break;

        case ACTIVITY.SOLDIER_1_UNIT_CREATE:
            actName.text     = "전사2 생성";
            actDesc.text     = "두 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = SOLDIER_1_COST.ToString();
            actButton.onClick.AddListener(delegate { _BuiltGM.act = activity; MillitaryBase.CreateAttackSecondUnitBtn(); });
            canUseActivity(actButton, Frame, SOLDIER_1_COST);
            break;

        case ACTIVITY.SOLDIER_2_UNIT_CREATE:
            actName.text     = "전사3 생성";
            actDesc.text     = "두 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = SOLDIER_2_COST.ToString();
            actButton.onClick.AddListener(delegate { _BuiltGM.act = activity; MillitaryBase.CreateAttackThirdUnitBtn(); });
            canUseActivity(actButton, Frame, SOLDIER_2_COST);
            break;

        case ACTIVITY.WITCH_0_UNIT_CREATE:
            actName.text     = "마법사1 생성";
            actDesc.text     = "두 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = WITCH_0_COST.ToString();
            actButton.onClick.AddListener(delegate { _BuiltGM.act = activity; MillitaryBase.CreateAttackFourthUnitBtn(); });
            canUseActivity(actButton, Frame, WITCH_0_COST);
            break;

        case ACTIVITY.WITCH_1_UNIT_CREATE:
            actName.text     = "마법사2 생성";
            actDesc.text     = "두 턴 소요";
            costText.enabled = true;
            costImg.enabled  = true;
            costText.text    = WITCH_1_COST.ToString();
            actButton.onClick.AddListener(delegate { _BuiltGM.act = activity; MillitaryBase.CreateAttackFifthUnitBtn(); });
            canUseActivity(actButton, Frame, WITCH_1_COST);
            break;

        default:
            break;
        }
    }
Esempio n. 40
0
    private UnityEngine.UI.Button removeButton; // variable to keep the remove button reference

    void Awake()
    {
        icon         = transform.GetChild(0).GetChild(0).GetComponent <UnityEngine.UI.Image> ();
        removeButton = transform.GetChild(1).GetComponent <UnityEngine.UI.Button> ();
    }
Esempio n. 41
0
        // Draw monster if in scroll range (offset is scroll position)
        public void Draw(int offset)
        {
            // Check if in scroll range
            if (index < offset)
            {
                return;
            }
            if (index > offset + 4)
            {
                return;
            }

            GameObject mImg = new GameObject("monsterImg" + m.monsterData.name);

            mImg.tag = Game.MONSTERS;
            mImg.transform.SetParent(game.uICanvas.transform);

            RectTransform trans = mImg.AddComponent <RectTransform>();

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            mImg.AddComponent <CanvasRenderer>();

            icon        = mImg.AddComponent <UnityEngine.UI.Image>();
            icon.sprite = iconSprite;
            icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

            UnityEngine.UI.Button button = mImg.AddComponent <UnityEngine.UI.Button>();
            button.interactable = true;
            button.onClick.AddListener(delegate { MonsterDiag(); });

            iconFrame = null;
            if (game.gameType is D2EGameType)
            {
                icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f, monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f);
                GameObject mImgFrame = new GameObject("monsterFrame" + m.monsterData.name);
                mImgFrame.tag = Game.MONSTERS;
                mImgFrame.transform.SetParent(game.uICanvas.transform);

                RectTransform transFrame = mImgFrame.AddComponent <RectTransform>();
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                mImgFrame.AddComponent <CanvasRenderer>();

                iconFrame        = mImgFrame.AddComponent <UnityEngine.UI.Image>();
                iconFrame.sprite = frameSprite;
                iconFrame.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

                UnityEngine.UI.Button buttonFrame = mImgFrame.AddComponent <UnityEngine.UI.Button>();
                buttonFrame.interactable = true;
                buttonFrame.onClick.AddListener(delegate { MonsterDiag(); });

                if (m.GetHealth() != 0)
                {
                    UIElement ui = new UIElement(Game.MONSTERS);
                    ui.SetLocation(UIScaler.GetRight(-2.25f), 5.75f + ((index - offset) * 4.5f), 2, 2);
                    ui.SetText(m.GetHealth().ToString(), Color.red);
                    ui.SetFontSize(UIScaler.GetMediumFont());
                    ui.SetButton(MonsterDiag);
                    new UIElementBorder(ui, Color.red);
                }
            }

            iconDupe = null;
            if (duplicateSprite != null)
            {
                GameObject mImgDupe = new GameObject("monsterDupe" + m.monsterData.name);
                mImgDupe.tag = Game.MONSTERS;
                mImgDupe.transform.SetParent(game.uICanvas.transform);

                RectTransform dupeFrame = mImgDupe.AddComponent <RectTransform>();
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, ((monsterSize / 2f) + 3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                mImgDupe.AddComponent <CanvasRenderer>();

                iconDupe        = mImgDupe.AddComponent <UnityEngine.UI.Image>();
                iconDupe.sprite = duplicateSprite;
                iconDupe.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() / 2f, monsterSize * UIScaler.GetPixelsPerUnit() / 2f);

                UnityEngine.UI.Button buttonDupe = mImgDupe.AddComponent <UnityEngine.UI.Button>();
                buttonDupe.interactable = true;
                buttonDupe.onClick.AddListener(delegate { MonsterDiag(); });
            }

            Update();
        }
Esempio n. 42
0
        public override void ShowGUI(Menu menu)
        {
            string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuCycle)";

            MenuSource source = menu.menuSource;

            EditorGUILayout.BeginVertical("Button");

            if (source != AC.MenuSource.AdventureCreator)
            {
                cycleUIBasis = (CycleUIBasis)CustomGUILayout.EnumPopup("UI basis:", cycleUIBasis, apiPrefix + ".cycleUIBasis");

                if (cycleUIBasis == CycleUIBasis.Button)
                {
                    uiButton = LinkedUiGUI <UnityEngine.UI.Button> (uiButton, "Linked Button:", source);
                }
                else if (cycleUIBasis == CycleUIBasis.Dropdown)
                {
                                        #if UNITY_5_3_OR_NEWER
                    uiDropdown = LinkedUiGUI <Dropdown> (uiDropdown, "Linked Dropdown:", source);
                                        #else
                    EditorGUILayout.HelpBox("This option is only available with Unity 5.4 or newer.", MessageType.Info);
                                        #endif
                }
                uiSelectableHideStyle = (UISelectableHideStyle)CustomGUILayout.EnumPopup("When invisible:", uiSelectableHideStyle, apiPrefix + ".uiSelectableHideStyle");
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical("Button");
            }

            cycleType = (AC_CycleType)CustomGUILayout.EnumPopup("Cycle type:", cycleType, apiPrefix + ".cycleType");

            if (source == MenuSource.AdventureCreator || cycleUIBasis == CycleUIBasis.Button)
            {
                label = CustomGUILayout.TextField("Label text:", label, apiPrefix + ".label");
            }

            if (cycleType == AC_CycleType.CustomScript || cycleType == AC_CycleType.Variable)
            {
                int numOptions = optionsArray.Count;
                numOptions = EditorGUILayout.IntField("Number of choices:", optionsArray.Count);
                if (numOptions < 0)
                {
                    numOptions = 0;
                }

                if (numOptions < optionsArray.Count)
                {
                    optionsArray.RemoveRange(numOptions, optionsArray.Count - numOptions);
                }
                else if (numOptions > optionsArray.Count)
                {
                    if (numOptions > optionsArray.Capacity)
                    {
                        optionsArray.Capacity = numOptions;
                    }
                    for (int i = optionsArray.Count; i < numOptions; i++)
                    {
                        optionsArray.Add("");
                    }
                }

                for (int i = 0; i < optionsArray.Count; i++)
                {
                    optionsArray [i] = CustomGUILayout.TextField("Choice #" + i.ToString() + ":", optionsArray [i], apiPrefix + ".optionsArray[" + i.ToString() + "]");
                }

                if (cycleType == AC_CycleType.CustomScript)
                {
                    if (optionsArray.Count > 0)
                    {
                        selected = CustomGUILayout.IntField("Default option #:", selected, apiPrefix + ".selected");
                    }
                    ShowClipHelp();
                }
                else if (cycleType == AC_CycleType.Variable)
                {
                    varID = AdvGame.GlobalVariableGUI("Global integer var:", varID, VariableType.Integer);
                }

                actionListOnClick = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList on click:", actionListOnClick, false, apiPrefix + ".actionListOnClick");
            }
            alternativeInputButton = CustomGUILayout.TextField("Alternative input button:", alternativeInputButton, apiPrefix + ".alternativeInputButton");
            EditorGUILayout.EndVertical();

            base.ShowGUI(menu);
        }
Esempio n. 43
0
 /// <inheritdoc />
 public UnityButtonUIButtonAdapterImplementation([NotNull] Button unityButton)
 {
     UnityButton = unityButton ?? throw new ArgumentNullException(nameof(unityButton));
 }
Esempio n. 44
0
 public MyButtonManager(UnityEngine.UI.Button button, Transform parent, string label,
                        UnityEngine.Events.UnityAction onClick)
     : base(button.gameObject, parent, label)
 {
     button.onClick.AddListener(onClick);
 }
Esempio n. 45
0
    // Add a hero
    void AddHero(Quest.Hero h, Game game)
    {
        Sprite heroSprite;
        Sprite frameSprite;

        // FIXME: should be game type specific
        Texture2D frameTex = Resources.Load("sprites/borders/grey_frame") as Texture2D;

        string heroName = h.id.ToString();

        // If hero selected use blue frame (FIX for game type)
        if (h.heroData != null)
        {
            frameTex = Resources.Load("sprites/borders/blue_frame") as Texture2D;
            heroName = h.heroData.name.Translate();
        }

        GameObject heroFrame = new GameObject("heroFrame" + heroName);

        heroFrame.tag = "herodisplay";
        heroFrame.transform.parent = game.uICanvas.transform;
        RectTransform transFrame = heroFrame.AddComponent <RectTransform>();

        transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (0.25f + offset) * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0.25f * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        heroFrame.AddComponent <CanvasRenderer>();

        UnityEngine.UI.Image imageFrame = heroFrame.AddComponent <UnityEngine.UI.Image>();
        icon_frames.Add(h.id, imageFrame);
        frameSprite       = Sprite.Create(frameTex, new Rect(0, 0, frameTex.width, frameTex.height), Vector2.zero, 1);
        imageFrame.sprite = frameSprite;
        imageFrame.rectTransform.sizeDelta = new Vector2(heroSize * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());

        UnityEngine.UI.Button buttonFrame = heroFrame.AddComponent <UnityEngine.UI.Button>();
        buttonFrame.interactable = true;
        buttonFrame.onClick.AddListener(delegate { HeroDiag(h.id); });

        GameObject heroImg = new GameObject("heroImg" + heroName);

        heroImg.tag = "herodisplay";
        heroImg.transform.parent = game.uICanvas.transform;
        RectTransform trans = heroImg.AddComponent <RectTransform>();

        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (0.25f + offset) * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        offset += heroSize + 0.5f;
        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0.25f * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        heroImg.AddComponent <CanvasRenderer>();
        UnityEngine.UI.Image image = heroImg.AddComponent <UnityEngine.UI.Image>();

        icons.Add(h.id, image);
        image.rectTransform.sizeDelta = new Vector2(heroSize * UIScaler.GetPixelsPerUnit() * 0.8f, heroSize * UIScaler.GetPixelsPerUnit() * 0.8f);
        image.color = Color.clear;

        UnityEngine.UI.Button button = heroImg.AddComponent <UnityEngine.UI.Button>();
        button.interactable = true;
        button.onClick.AddListener(delegate { HeroDiag(h.id); });

        // Add hero image if selected
        if (h.heroData != null)
        {
            Texture2D newTex = ContentData.FileToTexture(h.heroData.image);
            heroSprite   = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = heroSprite;
        }
    }
Esempio n. 46
0
 // Start is called before the first frame update
 void Start()
 {
     btnComponent = GetComponent <Button>();
     btnComponent.onClick.AddListener(ResumeGame);
 }
Esempio n. 47
0
 private void Awake()
 {
     button = GetComponent <UnityEngine.UI.Button>();
 }
 void AddListenerStop(UnityEngine.UI.Button b, string value)
 {
     b.onClick.AddListener(() => OnStopClickedValue(value));
 }
Esempio n. 49
0
        static void Postfix(StandardLevelDetailView __instance, ref LevelParamsPanel ____levelParamsPanel, ref IDifficultyBeatmap ____selectedDifficultyBeatmap,
                            ref PlayerData ____playerData, /*ref TextMeshProUGUI ____songNameText,*/ ref UnityEngine.UI.Button ____actionButton,
                            ref UnityEngine.UI.Button ____practiceButton, ref BeatmapDifficultySegmentedControlController ____beatmapDifficultySegmentedControlController,
                            ref BeatmapCharacteristicSegmentedControlController ____beatmapCharacteristicSegmentedControlController)
        {
            bool firstSelection = false;
            var  level          = ____selectedDifficultyBeatmap.level is CustomBeatmapLevel ? ____selectedDifficultyBeatmap.level as CustomPreviewBeatmapLevel : null;

            if (level != lastLevel)
            {
                firstSelection = true;
                lastLevel      = level;
            }
            ____actionButton.interactable   = true;
            ____practiceButton.interactable = true;
            ____actionButton.gameObject.GetComponentInChildren <Image>().color = new Color(0, 0.706f, 1.000f, 0.784f);


            //____songNameText.text = "<size=78%>" + ____songNameText.text.Replace(@"<", "<\u200B").Replace(@">", ">\u200B");
            //    ____songNameText.overflowMode = TextOverflowModes.Overflow;
            //     ____songNameText.enableWordWrapping = false;

            //____songNameText.richText = true;
            RequirementsUI.instance.ButtonGlowColor    = "#000000";
            RequirementsUI.instance.ButtonInteractable = false;
            if (level != null)
            {
                Data.ExtraSongData songData = Collections.RetrieveExtraSongData(Utilities.Hashing.GetCustomLevelHash(level), level.customLevelPath);

                if (songData == null)
                {
                    RequirementsUI.instance.ButtonGlowColor    = "#000000";
                    RequirementsUI.instance.ButtonInteractable = false;
                    return;
                }
                bool wipFolderSong = false;
                IDifficultyBeatmap selectedDiff            = ____selectedDifficultyBeatmap;
                Data.ExtraSongData.DifficultyData diffData = Collections.RetrieveDifficultyData(selectedDiff);
                //songData._difficulties?.FirstOrDefault(x => x._difficulty == selectedDiff.difficulty
                //&& (x._beatmapCharacteristicName == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.characteristicName || x._beatmapCharacteristicName == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName));
                if (diffData != null)
                {
                    //If no additional information is present
                    if (diffData.additionalDifficultyData._requirements.Count() == 0 && diffData.additionalDifficultyData._suggestions.Count() == 0 &&
                        diffData.additionalDifficultyData._warnings.Count() == 0 && diffData.additionalDifficultyData._information.Count() == 0 &&
                        songData.contributors.Count() == 0)
                    {
                        RequirementsUI.instance.ButtonGlowColor    = "#000000";
                        RequirementsUI.instance.ButtonInteractable = false;
                    }
                    else if (diffData.additionalDifficultyData._warnings.Count() == 0)
                    {
                        RequirementsUI.instance.ButtonGlowColor    = "#0000FF";
                        RequirementsUI.instance.ButtonInteractable = true;
                    }
                    else if (diffData.additionalDifficultyData._warnings.Count() > 0)
                    {
                        RequirementsUI.instance.ButtonGlowColor    = "#FFFF00";
                        RequirementsUI.instance.ButtonInteractable = true;
                        if (diffData.additionalDifficultyData._warnings.Contains("WIP"))
                        {
                            ____actionButton.interactable = false;
                            ____actionButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow;
                        }
                    }
                }
                if (level.levelID.EndsWith(" WIP"))
                {
                    RequirementsUI.instance.ButtonGlowColor    = "#FFFF00";
                    RequirementsUI.instance.ButtonInteractable = true;
                    ____actionButton.interactable = false;
                    ____actionButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow;
                    wipFolderSong = true;
                }
                if (diffData != null)
                {
                    for (int i = 0; i < diffData.additionalDifficultyData._requirements.Count(); i++)
                    {
                        if (!Collections.capabilities.Contains(diffData.additionalDifficultyData._requirements[i]))
                        {
                            ____actionButton.interactable   = false;
                            ____practiceButton.interactable = false;
                            ____actionButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red;
                            RequirementsUI.instance.ButtonGlowColor = "#FF0000";
                        }
                    }
                }


                if (selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName == "MissingCharacteristic")
                {
                    ____actionButton.interactable   = false;
                    ____practiceButton.interactable = false;
                    ____actionButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red;
                    RequirementsUI.instance.ButtonGlowColor = "#FF0000";
                }

                RequirementsUI.instance.level     = level;
                RequirementsUI.instance.songData  = songData;
                RequirementsUI.instance.diffData  = diffData;
                RequirementsUI.instance.wipFolder = wipFolderSong;


                //Difficulty Label Handling
                levelLabels.Clear();
                string currentCharacteristic = "";
                foreach (Data.ExtraSongData.DifficultyData diffLevel in songData._difficulties)
                {
                    var    difficulty     = diffLevel._difficulty;
                    string characteristic = diffLevel._beatmapCharacteristicName;
                    if (characteristic == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName)
                    {
                        currentCharacteristic = characteristic;
                    }
                    if (!levelLabels.ContainsKey(characteristic))
                    {
                        levelLabels.Add(characteristic, new OverrideLabels());
                    }
                    OverrideLabels charLabels = levelLabels[characteristic];
                    if (!string.IsNullOrWhiteSpace(diffLevel._difficultyLabel))
                    {
                        switch (difficulty)
                        {
                        case BeatmapDifficulty.Easy:
                            charLabels.EasyOverride = diffLevel._difficultyLabel;
                            break;

                        case BeatmapDifficulty.Normal:
                            charLabels.NormalOverride = diffLevel._difficultyLabel;
                            break;

                        case BeatmapDifficulty.Hard:
                            charLabels.HardOverride = diffLevel._difficultyLabel;
                            break;

                        case BeatmapDifficulty.Expert:
                            charLabels.ExpertOverride = diffLevel._difficultyLabel;
                            break;

                        case BeatmapDifficulty.ExpertPlus:
                            charLabels.ExpertPlusOverride = diffLevel._difficultyLabel;
                            break;
                        }
                    }
                }
                if (!string.IsNullOrWhiteSpace(currentCharacteristic))
                {
                    SetCurrentLabels(levelLabels[currentCharacteristic]);
                }
                else
                {
                    clearOverrideLabels();
                }

                ____beatmapDifficultySegmentedControlController.SetData(____selectedDifficultyBeatmap.parentDifficultyBeatmapSet.difficultyBeatmaps, ____beatmapDifficultySegmentedControlController.selectedDifficulty);
                clearOverrideLabels();
                if (songData._defaultCharacteristic != null && firstSelection)
                {
                    if (____beatmapCharacteristicSegmentedControlController.selectedBeatmapCharacteristic.serializedName != songData._defaultCharacteristic)
                    {
                        var chars = ____beatmapCharacteristicSegmentedControlController.GetField <List <BeatmapCharacteristicSO> >("_beatmapCharacteristics");
                        int index = 0;
                        foreach (var characteristic in chars)
                        {
                            if (songData._defaultCharacteristic == characteristic.serializedName)
                            {
                                break;
                            }
                            index++;
                        }
                        if (index != chars.Count)
                        {
                            ____beatmapCharacteristicSegmentedControlController.GetField <HMUI.IconSegmentedControl>("_segmentedControl").SelectCellWithNumber(index);
                        }
                        ____beatmapCharacteristicSegmentedControlController.HandleDifficultySegmentedControlDidSelectCell(
                            ____beatmapCharacteristicSegmentedControlController.GetField <HMUI.IconSegmentedControl>("_segmentedControl"), index);
                    }
                }
            }
        }
Esempio n. 50
0
        public override void StartGame()
        {
            if (first_question)
            {
                //BEGIN instantiating question/answer GameObjects
                Question = Instantiate(questionPrefab, GameObject.Find("Canvas").transform, false);
                Vector3 q_pos = new Vector3(0f, 134f, 0f);
                Question.GetComponent <RectTransform>().localPosition = q_pos;

                buttons[0] = Instantiate(buttonPrefab, GameObject.Find("Canvas").transform, false);
                UnityEngine.UI.Button button_temp = buttons[0].GetComponent <UnityEngine.UI.Button>();
                button_temp.onClick.AddListener(Selection);
                Vector3 position = new Vector3(181f, 47f, 3f);
                buttons[0].GetComponent <RectTransform>().localPosition = position;

                buttons[1]  = Instantiate(buttonPrefab, GameObject.Find("Canvas").transform, false);
                button_temp = buttons[1].GetComponent <UnityEngine.UI.Button>();
                button_temp.onClick.AddListener(Selection1);
                position = new Vector3(-181f, 47f, 3f);
                buttons[1].GetComponent <RectTransform>().localPosition = position;

                buttons[2]  = Instantiate(buttonPrefab, GameObject.Find("Canvas").transform, false);
                button_temp = buttons[2].GetComponent <UnityEngine.UI.Button>();
                button_temp.onClick.AddListener(Selection2);
                position = new Vector3(181f, -99f, 3f);
                buttons[2].GetComponent <RectTransform>().localPosition = position;

                buttons[3]  = Instantiate(buttonPrefab, GameObject.Find("Canvas").transform, false);
                button_temp = buttons[3].GetComponent <UnityEngine.UI.Button>();
                button_temp.onClick.AddListener(Selection3);
                position = new Vector3(181f, -26f, 3f);
                buttons[3].GetComponent <RectTransform>().localPosition = position;

                buttons[4]  = Instantiate(buttonPrefab, GameObject.Find("Canvas").transform, false);
                button_temp = buttons[4].GetComponent <UnityEngine.UI.Button>();
                button_temp.onClick.AddListener(Selection4);
                position = new Vector3(-181f, -99f, 3f);
                buttons[4].GetComponent <RectTransform>().localPosition = position;

                buttons[5]  = Instantiate(buttonPrefab, GameObject.Find("Canvas").transform, false);
                button_temp = buttons[5].GetComponent <UnityEngine.UI.Button>();
                button_temp.onClick.AddListener(Selection5);
                position = new Vector3(-181f, -26f, 3f);
                buttons[5].GetComponent <RectTransform>().localPosition = position;

                first_question = false;
            }

            //END object instantiations ----------------- ----------------------

            //step 1: fill an Array with all available filenames to choose between
            //		  choose a file at random after getting these filenames
            //		  (maybe give them a special extension?)
            //        FOR NOW, just going to open the file

            string current_dir = Path.Combine(Application.persistentDataPath, "quizData.dat");

            if (debugLogs)
            {
                Debug.Log(current_dir);
            }


            if (!File.Exists(Path.Combine(Application.persistentDataPath, "quizData.dat")))
            {
                if (!completed)
                {
                    completed = true;
                    GameCompleted();
                }
            }

            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = new FileStream(Path.Combine(Application.persistentDataPath, "quizData.dat"), FileMode.Open, FileAccess.Read, FileShare.None);
            QuizData        data = (QuizData)bf.Deserialize(file);

            file.Close();
            //step 2: Choose a question from the array at random
            //        must make use of a line counter for files to do this
            System.Random rand = new System.Random();

            int upper_limit = data.questions.Count;

            int line = rand.Next(0, upper_limit);

            selected_line = data.questions[line];

            if (debugLogs)
            {
                Debug.Log(selected_line);
            }

            //step 3: display the question text
            string[] parsed_text = selected_line.Split('#');
            if (debugLogs)
            {
                Debug.Log(parsed_text[1]);
            }
            Question.GetComponentInChildren <Text>().text = parsed_text[1];
            string correct_answers = parsed_text[3];
            string wrong_answers   = parsed_text[5];

            //step 4: Fill a list of right and wrong answers
            string[] correct_array = correct_answers.Split(',');
            string[] wrong_array   = wrong_answers.Split(',');

            //these limits are size-1 because both the correct/incorrect answer
            // pools end with a comma, so the last position will be empty
            int correct_limit = correct_array.Length - 1;
            int wrong_limit   = wrong_array.Length - 1;

            //choose the number of correct answers to be diplayed
            int num_correct = rand.Next(1, 4);

            //set the global win condition variable
            num_correct_answers = num_correct;

            if (debugLogs)
            {
                Debug.Log("Number of correct answers: " + num_correct);
            }
            //the rest will be incorrect answers
            int num_wrong = TOTAL_POSSIBLE_ANSWERS - num_correct;

            List <string> correct_selections = new List <string>();
            List <string> wrong_selections   = new List <string>();

            int get_answer_at_pos;
            //we can't allow duplicates, so keep track of answers we've already selected
            List <int> already_selected = new List <int>();

            for (int i = 0; i < num_correct;)
            {
                //gather random correct answers
                get_answer_at_pos = rand.Next(0, correct_limit);
                if (is_seen(get_answer_at_pos, already_selected))
                {
                    //answer here would be a duplicate, go back to loop
                    continue;
                }
                else
                {
                    already_selected.Add(get_answer_at_pos);
                    correct_selections.Add(correct_array[get_answer_at_pos]);
                    i++;
                }
            }

            //get list ready for wrong answer selection

            already_selected.Clear();

            for (int i = 0; i < num_wrong;)
            {
                //gather random wrong answers
                get_answer_at_pos = rand.Next(0, wrong_limit);
                if (is_seen(get_answer_at_pos, already_selected))
                {
                    //answer here would be a duplicate, go back to loop
                    continue;
                }
                else
                {
                    already_selected.Add(get_answer_at_pos);
                    wrong_selections.Add(wrong_array[get_answer_at_pos]);
                    i++;
                }
            }

            int temp;
            int right_or_wrong = -1;

            //put the answer text on buttons!
            for (int i = 0; i < TOTAL_POSSIBLE_ANSWERS; i++)
            {
                //first, choose a right or wrong answer to give to a button
                if (correct_selections.Count > 0 && wrong_selections.Count > 0)
                {
                    //we don't want to put right/wrong answers in a deterministic ordering,
                    // so we'll but them in a random order
                    right_or_wrong = rand.Next(0, 2);
                }
                if (right_or_wrong == 1)
                {
                    temp = rand.Next(0, correct_selections.Count);
                    //Add a correct answer to the button
                    buttons[i].GetComponentInChildren <Text>().text = correct_selections[temp];
                    answer_key[i] = true;
                    correct_selections.RemoveAt(temp);

                    if (correct_selections.Count <= 0)
                    {
                        //if we've ran out of correct answers,
                        // only select from the wrong list from here on out
                        right_or_wrong = 0;
                    }
                }
                else if (right_or_wrong == 0)
                {
                    temp = rand.Next(0, wrong_selections.Count);
                    //Add a correct answer to the button
                    buttons[i].GetComponentInChildren <Text>().text = wrong_selections[temp];
                    answer_key[i] = false;
                    wrong_selections.RemoveAt(temp);

                    if (wrong_selections.Count <= 0)
                    {
                        //if we've ran out of wrong answers,
                        // only select from the correct list from here on out
                        right_or_wrong = 1;
                    }
                }
                else
                {
                    if (debugLogs)
                    {
                        Debug.Log("ERROR IN QUIZ CONTROLLER line 272");
                    }
                }
            }            //END FOR LOOP ---------------------------------------------------
        }
Esempio n. 51
0
    private void Start()
    {
        if (Type1 == H.OptionalFeedback || Type1 == H.BugReport)
        {
            Program.LockInputSt();
        }

        _completeQuest = GetChildCalled("CompleteQuest");
        if (_completeQuest != null)
        {
            _completeQuest.SetActive(false);
        }

        if (Type1 == H.CompleteQuest)
        {
            _completeQuest.SetActive(true);
        }

        var t = GetChildCalled("TextHere");

        _textHere = t.GetComponentInChildren <Text>();

        _textHere.text = Languages.ReturnString(Type1 + "") + Str1;

        //doesnt have any of below
        if (Type1 == H.MandatoryFeedback)
        {
            return;
        }

        _okBtnGO = GetChildCalled("Ok_Btn");
        _ok      = _okBtnGO.GetComponent <UnityEngine.UI.Button>();

        _rateBtnGO = GetChildCalled("Rate_Btn");
        if (_rateBtnGO != null)
        {
            _rateBtnGO.SetActive(false);
        }

        var inText = GetChildCalled("Input_Field");

        if (inText != null)
        {
            InputText = inText.GetComponent <InputField>();
        }

        //for email invitation for private beta
        //Input_Field_Email_1
        var email1 = GetChildCalled("Input_Field_Email_1");

        if (email1 != null)
        {
            _inputTextEmail1 = email1.GetComponent <InputField>();
        }

        var email2 = GetChildCalled("Input_Field_Email_2");

        if (email2 != null)
        {
            _inputTextEmail2 = email2.GetComponent <InputField>();
        }

        AddressBuyRegionType();
        AddressInfoKeyedDialog();
        AddressCompleteQuest();
    }
Esempio n. 52
0
 public void AssignColorsToSelection(GameObject gameObject, ColorSet colorSet)
 {
     recursiveLevel++;
     if (gameObject.GetComponent <UnityEngine.UI.Button>())
     {
         UnityEngine.UI.Button button = gameObject.GetComponent <UnityEngine.UI.Button>();
         SetColorBlock(button, colorSet);
         SetDetailColor(gameObject, colorSet);
         EditorUtility.SetDirty(button);
     }
     else if (gameObject.GetComponent <UnityEngine.UI.InputField>())
     {
         UnityEngine.UI.InputField input = gameObject.GetComponent <UnityEngine.UI.InputField>();
         SetColorBlock(input, colorSet);
         input.selectionColor = colorSet.highlighted;
         Undo.RecordObject(input.textComponent, "Change Text color");
         input.textComponent.color = colorSet.pressed;
         Undo.RecordObject(input.placeholder, "Change Placeholder color");
         input.placeholder.color = colorSet.highlighted;
         EditorUtility.SetDirty(input);
         EditorUtility.SetDirty(input.textComponent);
         EditorUtility.SetDirty(input.placeholder);
     }
     else if (gameObject.GetComponent <UnityEngine.UI.Scrollbar>())
     {
         UnityEngine.UI.Scrollbar sb = gameObject.GetComponent <UnityEngine.UI.Scrollbar>();
         SetColorBlock(sb, colorSet);
         Undo.RecordObject(gameObject.GetComponent <UnityEngine.UI.Image>(), "Change Image color");
         gameObject.GetComponent <UnityEngine.UI.Image>().color = colorSet.disabled;
         EditorUtility.SetDirty(sb);
         EditorUtility.SetDirty(gameObject.GetComponent <UnityEngine.UI.Image>());
     }
     else if (gameObject.GetComponent <UnityEngine.UI.Slider>())
     {
         UnityEngine.UI.Slider slider = gameObject.GetComponent <UnityEngine.UI.Slider>();
         SetColorBlock(slider, colorSet);
         Undo.RecordObject(slider.fillRect.gameObject.GetComponent <UnityEngine.UI.Image>(), "Change Image color");
         slider.fillRect.gameObject.GetComponent <UnityEngine.UI.Image>().color = colorSet.normal;
         SetTextColorRecursive(gameObject, colorSet);
         EditorUtility.SetDirty(slider);
         EditorUtility.SetDirty(slider.fillRect.gameObject.GetComponent <UnityEngine.UI.Image>());
     }
     else if (gameObject.GetComponent <UnityEngine.UI.Toggle>())
     {
         UnityEngine.UI.Toggle toggle = gameObject.GetComponent <UnityEngine.UI.Toggle>();
         SetColorBlock(toggle, colorSet);
         Undo.RecordObject(toggle.graphic, "Change Image color");
         toggle.graphic.color = colorSet.normal;
         SetTextColorRecursive(gameObject, colorSet);
         EditorUtility.SetDirty(toggle);
         EditorUtility.SetDirty(toggle.graphic);
     }
     else if (gameObject.transform.childCount > 0) // Recursive search for components
     {
         for (int i = 0; i < gameObject.transform.childCount; i++)
         {
             AssignColorsToSelection(gameObject.transform.GetChild(i).gameObject, colorSet);
         }
     }
     else if (recursiveLevel == 1)
     {
         if (gameObject.GetComponent <UnityEngine.UI.Image>())
         {
             UnityEngine.UI.Image image = gameObject.GetComponent <UnityEngine.UI.Image>();
             Undo.RecordObject(image, "Change color");
             image.color = colorSet.normal;
             EditorUtility.SetDirty(image);
         }
         else if (gameObject.GetComponent <UnityEngine.UI.Text>())
         {
             UnityEngine.UI.Text text = gameObject.GetComponent <UnityEngine.UI.Text>();
             Undo.RecordObject(text, "Change color");
             text.color = colorSet.normal;
             EditorUtility.SetDirty(text);
         }
     }
 }
 public void Clear()
 {
     BtnClearCache = null;
     TextCache     = null;
 }
Esempio n. 54
0
        public override void ShowGUI(MenuSource source)
        {
            EditorGUILayout.BeginVertical("Button");

            if (source != AC.MenuSource.AdventureCreator)
            {
                uiButton = LinkedUiGUI <UnityEngine.UI.Button> (uiButton, "Linked Button:", source);
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical("Button");
            }

            label = EditorGUILayout.TextField("Label text:", label);

            if (source == MenuSource.AdventureCreator)
            {
                anchor      = (TextAnchor)EditorGUILayout.EnumPopup("Text alignment:", anchor);
                textEffects = (TextEffects)EditorGUILayout.EnumPopup("Text effect:", textEffects);
            }

            cycleType = (AC_CycleType)EditorGUILayout.EnumPopup("Cycle type:", cycleType);
            if (cycleType == AC_CycleType.CustomScript || cycleType == AC_CycleType.Variable)
            {
                int numOptions = optionsArray.Count;
                numOptions = EditorGUILayout.IntField("Number of choices:", optionsArray.Count);
                if (numOptions < 0)
                {
                    numOptions = 0;
                }

                if (numOptions < optionsArray.Count)
                {
                    optionsArray.RemoveRange(numOptions, optionsArray.Count - numOptions);
                }
                else if (numOptions > optionsArray.Count)
                {
                    if (numOptions > optionsArray.Capacity)
                    {
                        optionsArray.Capacity = numOptions;
                    }
                    for (int i = optionsArray.Count; i < numOptions; i++)
                    {
                        optionsArray.Add("");
                    }
                }

                for (int i = 0; i < optionsArray.Count; i++)
                {
                    optionsArray [i] = EditorGUILayout.TextField("Choice #" + i.ToString() + ":", optionsArray [i]);
                }

                if (cycleType == AC_CycleType.CustomScript)
                {
                    if (optionsArray.Count > 0)
                    {
                        selected = EditorGUILayout.IntField("Default option #:", selected);
                    }
                    ShowClipHelp();
                }
                else if (cycleType == AC_CycleType.Variable)
                {
                    varID = EditorGUILayout.IntField("Global Variable ID:", varID);
                }

                actionListOnClick = (ActionListAsset)EditorGUILayout.ObjectField("ActionList on click:", actionListOnClick, typeof(ActionListAsset), false);
            }
            EditorGUILayout.EndVertical();

            base.ShowGUI(source);
        }
Esempio n. 55
0
        protected override void ClearUIComponents()
        {
            BackBtn = null;

            mData = null;
        }
Esempio n. 56
0
    public void txtUpdate()
    {
        Txt_maintit.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(36.0f / varbank.Asp_scale.y);
        Txt_maintit.text     = langopts.Txt_maintit;
        Txt_maintit.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Pnl_menu.rectTransform.sizeDelta.x * 3 / 4);
        Txt_maintit.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_maintit.fontSize * 1.3f));
        Txt_maintit.rectTransform.anchoredPosition = new Vector2(0, Mathf.CeilToInt(-56.0f / varbank.Asp_scale.y));

        Txt_byme.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(-4.0f / varbank.Asp_scale.y);
        Txt_byme.text     = "Ozan Tayar";     // langopts.Txt_byme;
        Txt_byme.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Pnl_menu.rectTransform.sizeDelta.x * 2 / 5);
        Txt_byme.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_byme.fontSize * 1.3f));
        Txt_byme.rectTransform.anchoredPosition = new Vector2(0, Mathf.CeilToInt(24.0f / varbank.Asp_scale.y));

        RectTransform Rtr_strt = Btn_strt.gameObject.transform as RectTransform;

        UnityEngine.UI.Text Txt_strt = Rtr_strt.GetChild(0).GetComponent <UnityEngine.UI.Text>();
        Txt_strt.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(36.0f / varbank.Asp_scale.y);
        Txt_strt.text     = langopts.Btn_txt_strt;
        //Btn_strt.GetComponent<RectTransform> ().SetSizeWithCurrentAnchors (RectTransform.Axis.Horizontal, varbank.Cur_asp.x * 3 / 5);
        Rtr_strt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Pnl_menu.rectTransform.sizeDelta.x * 3 / 5);
        Rtr_strt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_strt.fontSize * 2f));
        Rtr_strt.anchoredPosition = new Vector2(0, Mathf.CeilToInt(24.0f / varbank.Asp_scale.y));

        RectTransform Rtr_quit = Btn_quit.gameObject.transform as RectTransform;

        UnityEngine.UI.Text Txt_quit = Rtr_quit.GetChild(0).GetComponent <UnityEngine.UI.Text>();
        Txt_quit.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(28.0f / varbank.Asp_scale.y);
        Txt_quit.text     = langopts.Btn_txt_quit;
        int lngt;

        if (25 + 25 + (Txt_quit.fontSize / 2f) * Txt_quit.text.Length < Txt_quit.fontSize * 1.25f)
        {
            lngt = Mathf.CeilToInt(Txt_quit.fontSize * 1.25f);
        }
        else
        {
            lngt = Mathf.CeilToInt(25 + 25 + (Txt_quit.fontSize / 2f) * Txt_quit.text.Length);
        }
        Rtr_quit.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, lngt);
        Rtr_quit.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_quit.fontSize * 1.25f));
        Rtr_quit.anchoredPosition = new Vector2(Mathf.CeilToInt(-16.0f / varbank.Asp_scale.x), Mathf.CeilToInt(16.0f / varbank.Asp_scale.y));

        RectTransform Rtr_opts = Btn_opts.gameObject.transform as RectTransform;

        UnityEngine.UI.Text Txt_opts = Rtr_opts.GetChild(0).GetComponent <UnityEngine.UI.Text>();
        Txt_opts.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(16.0f / varbank.Asp_scale.y);
        Txt_opts.text     = langopts.Btn_txt_opts;
        Rtr_opts.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Pnl_menu.rectTransform.sizeDelta.x * 2.65f / 5);
        Rtr_opts.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_opts.fontSize * 2f));
        Rtr_opts.anchoredPosition = new Vector2(0, Mathf.CeilToInt(-36.0f / varbank.Asp_scale.y));

        Txt_optstit.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(36.0f / varbank.Asp_scale.y);
        Txt_optstit.text     = langopts.Txt_optstit;
        Txt_optstit.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Pnl_opts.rectTransform.sizeDelta.x * 3 / 4);
        Txt_optstit.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_optstit.fontSize * 1.3f));
        Txt_optstit.rectTransform.anchoredPosition = new Vector2(0, Mathf.CeilToInt(-56.0f / varbank.Asp_scale.y));

        Txt_optlang.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(10.0f / varbank.Asp_scale.y);
        Txt_optlang.text     = langopts.Txt_optlang;
        Txt_optlang.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Pnl_opts.rectTransform.sizeDelta.x * 3 / 8);
        Txt_optlang.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_optlang.fontSize * 2.6f));
        Txt_optlang.rectTransform.anchoredPosition = new Vector2(Mathf.CeilToInt(-120.0f / varbank.Asp_scale.x), Mathf.CeilToInt(236.0f / varbank.Asp_scale.y));

        RectTransform Rtr_scrlangcont = Scr_lang.content.gameObject.transform as RectTransform;

        Rtr_scrlangcont.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt((20.0f + 260f * varbank.Lst_lang.Length) / varbank.Asp_scale.x));
        Rtr_scrlangcont.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(200.0f / varbank.Asp_scale.y));

        RectTransform Rtr_scrlang = Scr_lang.gameObject.transform as RectTransform;

        Rtr_scrlang.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt(600.0f / varbank.Asp_scale.x));
        Rtr_scrlang.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(200.0f / varbank.Asp_scale.y));
        Rtr_scrlang.anchoredPosition = new Vector2(Mathf.CeilToInt(500f / varbank.Asp_scale.x), Mathf.CeilToInt(236f / varbank.Asp_scale.y));

        for (int i = Scr_lang.content.childCount - 1; i >= 0; i--)
        {
            Destroy(Scr_lang.content.GetChild(i).gameObject);
        }

        for (int i = 0; i < varbank.Lst_lang.Length; i++)           //butt check
        {
            UnityEngine.UI.Button btn = Instantiate(Tmp_btn);
            btn.name = varbank.Lst_lang [i];
            btn.transform.SetParent(Scr_lang.content);

            if (btn.name == varbank.Sel_lang)
            {
                btn.interactable = false;
            }
            else
            {
                btn.interactable = true;
            }

            RectTransform       Rtr_btn = btn.gameObject.transform as RectTransform;
            UnityEngine.UI.Text Txt     = Rtr_btn.GetChild(0).GetComponent <UnityEngine.UI.Text>();
            Txt.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(36.0f / varbank.Asp_scale.y);
            Txt.text     = varbank.Lst_lang [i];
            Rtr_btn.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt(240.0f / varbank.Asp_scale.x));
            Rtr_btn.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(160.0f / varbank.Asp_scale.y));
            Rtr_btn.anchoredPosition = new Vector2(Mathf.CeilToInt((20.0f + 260f * i) / varbank.Asp_scale.x), 0);

//			if (!varbank.isGameInit) {
            btn.onClick.AddListener(() => Btnfuns.sel_lang(Txt.text, btn.transform.parent.gameObject));
//			}
        }

        Txt_optres.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(10.0f / varbank.Asp_scale.y);
        Txt_optres.text     = langopts.Txt_optres;
        Txt_optres.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Pnl_opts.rectTransform.sizeDelta.x * 3 / 8);
        Txt_optres.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(Txt_optres.fontSize * 2.6f));
        Txt_optres.rectTransform.anchoredPosition = new Vector2(Mathf.CeilToInt(-120.0f / varbank.Asp_scale.x), Mathf.CeilToInt(-24.0f / varbank.Asp_scale.y));

        RectTransform Rtr_scrrescont = Scr_res.content.gameObject.transform as RectTransform;

        Rtr_scrrescont.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt((20.0f + 360f * varbank.Lst_res.Length) / varbank.Asp_scale.x));
        Rtr_scrrescont.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(200.0f / varbank.Asp_scale.y));

        RectTransform Rtr_scrres = Scr_res.gameObject.transform as RectTransform;

        Rtr_scrres.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt(600.0f / varbank.Asp_scale.x));
        Rtr_scrres.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(200.0f / varbank.Asp_scale.y));
        Rtr_scrres.anchoredPosition = new Vector2(Mathf.CeilToInt(500f / varbank.Asp_scale.x), Mathf.CeilToInt(-24f / varbank.Asp_scale.y));

        for (int i = Scr_res.content.childCount - 1; i >= 0; i--)
        {
            Destroy(Scr_res.content.GetChild(i).gameObject);
        }

        for (int i = 0; i < varbank.Lst_res.Length; i++)           //butt check
        {
            UnityEngine.UI.Button btn = Instantiate(Tmp_btn);
            btn.name = varbank.Lst_res [i];
            btn.transform.SetParent(Scr_res.content);

            if (btn.name == varbank.Sel_res)
            {
                btn.interactable = false;
            }
            else
            {
                btn.interactable = true;
            }
            RectTransform       Rtr_btn = btn.gameObject.transform as RectTransform;
            UnityEngine.UI.Text Txt     = Rtr_btn.GetChild(0).GetComponent <UnityEngine.UI.Text>();
            Txt.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(36.0f / varbank.Asp_scale.y);
            Txt.text     = varbank.Lst_res[i];
            Rtr_btn.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt(340f / varbank.Asp_scale.x));
            Rtr_btn.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(160.0f / varbank.Asp_scale.y));
            Rtr_btn.anchoredPosition = new Vector2(Mathf.CeilToInt((20.0f + 360f * i) / varbank.Asp_scale.x), 0);

//			if (!varbank.isGameInit) {
            btn.onClick.AddListener(() => Btnfuns.sel_res(Txt.text, btn.transform.parent.gameObject));
//			}
        }

        RectTransform Rtr_optsave = Btn_optsave.gameObject.transform as RectTransform;

        UnityEngine.UI.Text Txt_optsave = Rtr_optsave.GetChild(0).GetComponent <UnityEngine.UI.Text>();
        Txt_optsave.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(16.0f / varbank.Asp_scale.y);
        Txt_optsave.text     = langopts.Btn_txt_optsave;
        Rtr_optsave.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt(360.0f / varbank.Asp_scale.x));
        Rtr_optsave.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(152.0f / varbank.Asp_scale.y));
        Rtr_optsave.anchoredPosition = new Vector2(Mathf.CeilToInt(-200.0f / varbank.Asp_scale.x), Mathf.CeilToInt(56.0f / varbank.Asp_scale.y));

        RectTransform Rtr_return = Btn_return.gameObject.transform as RectTransform;

        UnityEngine.UI.Text Txt_return = Rtr_return.GetChild(0).GetComponent <UnityEngine.UI.Text>();
        Txt_return.fontSize = varbank.Cur_fontsize + Mathf.CeilToInt(16.0f / varbank.Asp_scale.y);
        Txt_return.text     = langopts.Btn_txt_return;
        Rtr_return.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt(360.0f / varbank.Asp_scale.x));
        Rtr_return.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt(152.0f / varbank.Asp_scale.y));
        Rtr_return.anchoredPosition = new Vector2(Mathf.CeilToInt(200.0f / varbank.Asp_scale.x), Mathf.CeilToInt(56.0f / varbank.Asp_scale.y));
    }
 // Use this for initialization
 void Start()
 {
     transform.Find("TargetName").GetComponent <UnityEngine.UI.Text>().text = target.name;
     button = GetComponent <UnityEngine.UI.Button> ();
     button.onClick.AddListener(onClick);
 }
Esempio n. 58
0
        public override void ShowGUI(MenuSource source)
        {
            EditorGUILayout.BeginVertical("Button");

            if (source != MenuSource.AdventureCreator)
            {
                uiButton = LinkedUiGUI <UnityEngine.UI.Button> (uiButton, "Linked Button:", source);
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical("Button");
            }

            label = EditorGUILayout.TextField("Button text:", label);

            if (source == MenuSource.AdventureCreator)
            {
                anchor      = (TextAnchor)EditorGUILayout.EnumPopup("Text alignment:", anchor);
                textEffects = (TextEffects)EditorGUILayout.EnumPopup("Text effect:", textEffects);
            }

            hotspotLabel = EditorGUILayout.TextField("Hotspot label override:", hotspotLabel);

            if (source == MenuSource.AdventureCreator)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Click texture:", GUILayout.Width(145f));
                clickTexture = (Texture2D)EditorGUILayout.ObjectField(clickTexture, typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(30f));
                EditorGUILayout.EndHorizontal();
            }

            buttonClickType = (AC_ButtonClickType)EditorGUILayout.EnumPopup("Click type:", buttonClickType);

            if (buttonClickType == AC_ButtonClickType.TurnOffMenu)
            {
                doFade = EditorGUILayout.Toggle("Do transition?", doFade);
            }
            else if (buttonClickType == AC_ButtonClickType.Crossfade)
            {
                switchMenuTitle = EditorGUILayout.TextField("Menu to switch to:", switchMenuTitle);
            }
            else if (buttonClickType == AC_ButtonClickType.OffsetInventoryOrDialogue)
            {
                inventoryBoxTitle     = EditorGUILayout.TextField("Element to affect:", inventoryBoxTitle);
                shiftInventory        = (AC_ShiftInventory)EditorGUILayout.EnumPopup("Offset type:", shiftInventory);
                shiftAmount           = EditorGUILayout.IntField("Offset amount:", shiftAmount);
                onlyShowWhenEffective = EditorGUILayout.Toggle("Only show when effective?", onlyShowWhenEffective);
            }
            else if (buttonClickType == AC_ButtonClickType.OffsetJournal)
            {
                inventoryBoxTitle = EditorGUILayout.TextField("Journal to affect:", inventoryBoxTitle);
                shiftInventory    = (AC_ShiftInventory)EditorGUILayout.EnumPopup("Offset type:", shiftInventory);
                loopJournal       = EditorGUILayout.Toggle("Cycle pages?", loopJournal);
            }
            else if (buttonClickType == AC_ButtonClickType.RunActionList)
            {
                actionList = ActionListAssetMenu.AssetGUI("ActionList to run:", actionList);
            }
            else if (buttonClickType == AC_ButtonClickType.CustomScript)
            {
                allowContinuousClick = EditorGUILayout.Toggle("Accept held-down clicks?", allowContinuousClick);
                ShowClipHelp();
            }
            else if (buttonClickType == AC_ButtonClickType.SimulateInput)
            {
                simulateInput = (SimulateInputType)EditorGUILayout.EnumPopup("Simulate:", simulateInput);
                inputAxis     = EditorGUILayout.TextField("Input axis:", inputAxis);
                if (simulateInput == SimulateInputType.Axis)
                {
                    simulateValue = EditorGUILayout.FloatField("Input value:", simulateValue);
                }
            }
            EditorGUILayout.EndVertical();

            base.ShowGUI(source);
        }
 void AddListenerDownload(UnityEngine.UI.Button b, string value)
 {
     b.onClick.AddListener(() => OnDownloadClickedValue(value));
 }
Esempio n. 60
0
 public void registerActionSource(UnityEngine.UI.Button source, ApplicationManager.ApplicationEvent action)
 {
     source.onClick.AddListener(() => { handleApplicationEvent(action); });
 }