Пример #1
0
 protected override void OnInit()
 {
     ComUtil.GetTransformInChild(mTranNames, CacheTransform, ref mTransforms);
     foreach (Transform tran in mTransforms)
     {
         if (tran.name.Equals(mTranNames[0]))
         {
             Button btn = tran.GetComponent<Button>();
             btn.onClick.AddListener(ButtonClickMenu);
         }
         else if (tran.name.Equals(mTranNames[1]))
         {
             Button btn = tran.GetComponent<Button>();
             btn.onClick.AddListener(ButtonClickTask);
         }
         else if (tran.name.Equals(mTranNames[2]))
         {
             Button btn = tran.GetComponent<Button>();
             btn.onClick.AddListener(ButtonClickFigure);
         }
         else if (tran.name.Equals(mTranNames[3]))
         {
             mExpBar = tran.GetComponent<Scrollbar>();
         }
         else
         {
             mExpText = tran.GetComponent<Text>();
         }
     }
 }
Пример #2
0
	// Use this for initialization
	void Start () 
	{
		myTransform = GetComponent<Transform> ();
		targetTransform = myTransform.FindChild ("Target").GetComponent<Transform> ();
		target2Transform = myTransform.FindChild ("Target2").GetComponent<Transform> ();
		myRenderer = GetComponent<Renderer> ();
		lastPosition = myTransform.position;
		if (isLocalPlayer) 
		{
			myTransform.FindChild("camera4player").GetComponent<Camera>().enabled = true;// activer camera joueur local uniquement 
			myRenderer.material.color = new Color (1, 0, 0); // colorer en rouge le joueur local
			TransmitPosition ();
			TransmitRotation ();
			scoreText = GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("ScoreTxt").GetComponent<Text>();
			lifeText = GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("HealthTxt").GetComponent<Text>();
			manaText = GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("ManaTxt").GetComponent<Text>();
			weaponText =GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("WeaponTxt").GetComponent<Text>();
			staminaText =GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("StaminaTxt").GetComponent<Text>();
			//Debug.Log(GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").GetComponent<Scrollbar>());
			healthBar = GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").GetComponent<Scrollbar>();
			healthColor = GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").FindChild("Mask").FindChild("Sprite").GetComponent<Image>();
			//Debug.Log(GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").FindChild("Mask").FindChild("Sprite").GetComponent<Image>());
			manaBar =GameObject.Find("ManabarHUD").GetComponent<Transform>().FindChild("Manabar").GetComponent<Scrollbar>();
			staminaBar =GameObject.Find("StaminabarHUD").GetComponent<Transform>().FindChild("Staminabar").GetComponent<Scrollbar>();

		}


		//idTest = GetComponent<NetworkIdentity> ().netId.Value;
	}
Пример #3
0
    public override void Awake()
    {
        base.Awake();
        gameObject.SetActive(false);
        contentPanel = (RectTransform)transform.Find("ContentPanel");
        scroller = transform.Find("Scrollbar").GetComponent<Scrollbar>();
        messageBox = new MessageBox(transform.Find("MessageBox"));

        scroller.onValueChanged.AddListener(delegate(float value)
        {
            float screenHeight = Screen.height;
            float screenWidth = Screen.width;
            float allHeight = contentPanel.rect.height - screenHeight + 50f;
            float allWidth = contentPanel.rect.width;
            float yPos = value * -allHeight + allHeight / 2f + screenHeight / 2f;
            float xPos = (screenWidth - allWidth) / 2f + allWidth / 2;
            contentPanel.position = new UnityEngine.Vector2(xPos, yPos);
        });

        RectTransform userInfoPanel = (RectTransform)contentPanel.Find("UserInfoPanel");
        firstNameText = userInfoPanel.Find("UserNameText").GetComponent<Text>();
        secondNameText = userInfoPanel.Find("UserLavelText").GetComponent<Text>();
        userIconImage = userInfoPanel.Find("UserIcon").GetComponent<Image>();

        avalableGamesPanel = (RectTransform)contentPanel.Find("AvalableGamesPanel");
    }
Пример #4
0
	// Use this for initialization
	void Start () {
		PlayerProfile.profile.load();
		uploadedPhotoScreen = GameObject.FindGameObjectWithTag ("postedscreen");
		uploadQueueScreen = GameObject.Find ("PanelUploads");
		photoPanel = GameObject.FindGameObjectWithTag ("photopanel");
		blogNameText = GameObject.FindGameObjectWithTag ("blogname").GetComponent<Text>();
		namePrompt = GameObject.FindGameObjectWithTag ("blogprompt");
		nameChangeScreen = GameObject.FindGameObjectWithTag ("changenamescreen");
		name_field = namePrompt.GetComponentInChildren<InputField> ();
		seenSecondScreen = PlayerProfile.profile.blogNameChangeTipSeen;
		blogSource = GetComponent<AudioSource> ();
		scrollBarPostedPhotos = GameObject.Find ("ScrollViewPostedPhotos").GetComponentInChildren<Scrollbar> ();
		postedPhotosSR = GameObject.Find ("ScrollViewPostedPhotos").GetComponentInChildren<ScrollRect> ();
		postedPhotosSR.movementType = ScrollRect.MovementType.Clamped;
		scrollBarPostedPhotos.value = 1f;

		if (!PlayerProfile.profile.blogNamed) {
			namePrompt.SetActive(true);
			nameChangeScreen.SetActive (false);
		} else {
			namePrompt.SetActive (false);
			nameChangeScreen.SetActive (false);
		}

		photoPanel.SetActive (false);
		blogSource.ignoreListenerPause = true;
		blogSource.Play();

		pathToPostedPhotos = Application.dataPath + "/Resources/PostedImages/";
		pathToUploadQueue = Application.dataPath + "/Resources/UploadQueue/";

		if (nothingToUpload ()) {
			uploadQueueScreen.SetActive (false);
		}
	}
Пример #5
0
	public void Volume() {
		scrollBar = GetComponent<Scrollbar> ();

		volume = scrollBar.value;
		
		Audio.GetComponent<AudioSource>().volume = volume;
	}
Пример #6
0
		public ScrollbarSample ()
		{
			WidthRequest = 300;
			HeightRequest = 300;

			canvas = new Canvas ();
			label = new Label ("Use the scrollbars\nto move this label");
			canvas.AddChild (label);

			Add (canvas, 0, 0, hexpand:true, vexpand:true);

			vscroll = new VScrollbar () {
				LowerValue = 0,
				UpperValue = 300,
				PageIncrement = 10,
				PageSize = 50,
				StepIncrement = 1
			};
			Add (vscroll, 1, 0, vexpand:true);
			
			hscroll = new HScrollbar () {
				LowerValue = 0,
				UpperValue = 300,
				PageIncrement = 10,
				PageSize = 50,
				StepIncrement = 1
			};
			Add (hscroll, 0, 1, hexpand:true);

			vscroll.ValueChanged += HandleValueChanged;
			hscroll.ValueChanged += HandleValueChanged;
		}
Пример #7
0
 protected override void OnInit()
 {
     ComUtil.GetTransformInChild(mTranNames, CacheTransform, ref mTransforms);
     foreach (Transform tran in mTransforms)
     {
         if (tran.name.Equals(mTranNames[0]))
         {
             Button btn = tran.GetComponent<Button>();
             btn.onClick.AddListener(ButtonClickContinue);
         }
         else if (tran.name.Equals(mTranNames[1]))
         {
             Button btn = tran.GetComponent<Button>();
             btn.onClick.AddListener(ButtonClickExit);
         }
         else if (tran.name.Equals(mTranNames[2]))
         {
             mMusicBar = tran.GetComponent<Scrollbar>();
             mMusicBar.onValueChanged.AddListener(OnMusicValueChange);
         }
         else
         {
             mSoundBar = tran.GetComponent<Scrollbar>();
             mSoundBar.onValueChanged.AddListener(OnSoundValueChange);
         }
     }
 }
Пример #8
0
    public void MakeButtons()
    {
        List<Feat_Class> FeatsTemp = new List<Feat_Class>();
        int j = 0;

        DeleteList();
        ScrollBar = FeatScrollView.gameObject.transform.GetChild(1).GetComponent<Scrollbar>();
        ScrollBar.value = 1;
        FeatsTemp = Load_Feats_from_ID.FeatsList;

        if (FeatParentRectDefault != null)
        {
            ParentRect.sizeDelta = new Vector2(FeatParentRectDefault.rect.width, 0);
            FeatScrollView.transform.position = new Vector3(FeatScrollView.transform.position.x, FeatScrollView.transform.position.y, 250);
            int posBehind = 0;
            for (int i = 0; i < FeatsTemp.Count; i++)
            {
                GameObject ItemButton = (GameObject)Instantiate(Select_Item_Button);
                GameObject itemNameText = ItemButton.gameObject.transform.GetChild(0).gameObject;
                ItemButton.transform.SetParent(FeatParentButton, false);
                ItemButton.transform.localScale = new Vector3(0.18f, 0.1f, 0);
                itemNameText.transform.localScale = new Vector3(1, 1, 1);

                if (j == 0 || j == 1)
                {
                    ItemButton.transform.position = new Vector3(FeatParentText.transform.position.x + (j * 150 * screenRatioW), FeatParentText.transform.position.y, 250);
                }
                else
                {
                    int mod = j % 2;
                    int pos = 0;
                    if (mod == 0)
                    {
                        pos = 0;
                        posBehind++;
                    }
                    else
                    {
                        pos = 1;
                    }

                    ItemButton.transform.position = new Vector3(FeatParentText.transform.position.x + (pos * 150 * screenRatioW), FeatParentText.transform.position.y - (50 * (j - pos - posBehind) * screenRatio), 250);
                }

                dynamicObjects.Add(ItemButton);
                Button tempButton = ItemButton.gameObject.GetComponent<Button>();
                int position = i;
                itemNameText.GetComponent<Text>().text = FeatsTemp[position].featName;
                tempButton.onClick.AddListener(() => EditMode(position));
                j++;
            }
        }

        if (dynamicObjects.Count > 0)
        {
            ParentRect.sizeDelta = new Vector2(FeatParentRectDefault.rect.width, screenRatio * (ParentRectHeight - (dynamicObjects[j - 1].transform.position.y - (dynamicObjects[j - 1].GetComponent<RectTransform>().rect.height))));
            ScrollBar.value = 1;
        }
    }
Пример #9
0
 void Start()
 {
     carController = GameObject.Find("MB300SL").GetComponent<CarController>();
     scroll = GetComponentInChildren<Scrollbar>();
     txt1 = GameObject.Find("Text_LeftRMP").GetComponent<Text>();
     txt2 = GameObject.Find("Text_RightRMP").GetComponent<Text>();
     but_rest = GameObject.Find("Restart").GetComponent<Button>();
 }
Пример #10
0
        private void Start()
        {
            scrollBar = GetComponentInChildren<Scrollbar>();

            if (scrollBar == null)
            {
                Debug.LogError("Couldnt find scrollbar under " + gameObject.name);
            }
        }
    // Use this for initialization
    void Awake()
    {
        this.scroll = transform.Find("Value").GetComponent<Scrollbar>();
        this.image = scroll.transform.Find("Mask").Find("Image").GetComponent<Image>();
        this.textValue = transform.Find("Text").GetComponent<Text>();
        this.title = transform.Find("Title").GetComponent<Text>();

        this.textValue.text = string.Empty;
        this.scroll.interactable = false;
    }
Пример #12
0
		protected override void Init()
		{
			uiScrollbar = GetComponent<Scrollbar>();
			uiScrollbar.onValueChanged.AddListener(OnValueChanged);
			AddUpdater(enabledName, UpdateEnabled);
			AddUpdater(interactableName, UpdateInteractable);
			AddUpdater(valueName, UpdateValue);
			AddUpdater(sizeName, UpdateSize);
			AddUpdater(stepsName, UpdateStep);
		}
Пример #13
0
 protected void initScroll()
 {
     myScrollRect = GetComponent<ScrollRect> ();
     myscrollBar = myScrollRect.horizontalScrollbar;
     ((SkyScrollRect)myScrollRect).mySkyOnEndDrag = new SkyScrollRect.SkyOnEndDrag (onEndDrag);
     ((SkyScrollRect)myScrollRect).mySkyOnBeginDrag = new SkyScrollRect.SkyOnBeginDrag (onBeginDrag);
     ((SkyScrollRect)myScrollRect).mySkyOnDrag = new SkyScrollRect.SkyOnDrag (onDrag);
     myScrollList = GameObject.Find (SCROLL_LIST);
     myGridLayoutGroup = myScrollList.GetComponent<GridLayoutGroup> ();
 }
 //private float scrollSize;
 // FIX SCROLL SIZE SOMEHOW
 void Start()
 {
     GameObject SB = GameObject.FindWithTag("Scroll");
     GameObject Log = GameObject.FindWithTag("Log");
     scroll = SB.GetComponent<Scrollbar>();
     log = Log.GetComponent<LogScript>();
     scrollValue =  1f; // very arbitrary value...
     scroll.size = 1f;
     offset = 0; // used for division by 0 purposes
 }
Пример #15
0
    void Awake()
    {
        GameObject heroState = GameObject.Find ("HeroState");
        health = heroState.transform.Find("Health");
        food = heroState.transform.Find("Food");
        water = heroState.transform.Find("Water");

        healthBar = health.GetComponent<Scrollbar> ();
        foodBar = food.GetComponent<Scrollbar> ();
        waterBar = water.GetComponent<Scrollbar> ();
    }
Пример #16
0
        public void Init()
        {
            m_ScrollBar = GetComponent<Scrollbar>();
            m_Content = m_ScrollBar.handleRect.gameObject.GetComponent<Image>();
            m_ValText = gameObject.GetComponentInChildren<Text>();

            // 加载遮罩材质,并设置参数
            Material mat = Resources.Load("Material/MaskMat") as Material;
            m_Content.material = Instantiate(mat) as Material;
            m_Content.material.SetFloat("_MaskWidth", initVal);
            m_Content.material.SetTexture("_MainTex", m_Content.sprite.texture);
            m_Content.material.SetColor("_Color", m_Content.color);
        }
Пример #17
0
    public void SetLayout()
    {
        int num_of_notes = 0;
        DeleteList ();
        foreach (var item in Note_List_Info.noteTitles) {
            num_of_notes++;
        }
        ScrollBar = ScrollView.gameObject.transform.GetChild(1).GetComponent<Scrollbar>();
        ScrollBar.value = 0;
        if (ParentRectDefault != null)
        {
            ParentRect.sizeDelta = new Vector2(ParentRectDefault.rect.width, 0);
            if (num_of_notes > 0)
            {
                ScrollView.transform.position = new Vector3(ScrollView.transform.position.x, ScrollView.transform.position.y, 250);

                for (int i = 0; i < num_of_notes; i++)
                {
                    GameObject noteButton = (GameObject)Instantiate(Select_Note_Button);
                    GameObject titleText = noteButton.gameObject.transform.GetChild(0).gameObject;
                    GameObject dateText = noteButton.gameObject.transform.GetChild(1).gameObject;
                    noteButton.transform.SetParent(ParentButton, false);
                    noteButton.transform.localScale = new Vector3(0.18f, 0.1f, 0);
                    titleText.transform.localScale = new Vector3(1, 1, 1);
                    titleText.GetComponent<Text>().text = PeekAtTitle(i);
                    dateText.GetComponent<Text>().text = PeekAtDate(i);
                    if (i == 0)
                    {
                        noteButton.transform.position = new Vector3(ParentText.transform.position.x, ParentText.transform.position.y, 250);
                    }
                    else
                    {
                        noteButton.transform.position = new Vector3(ParentText.transform.position.x, ParentText.transform.position.y - (40 * i * screenRatio), 250);
                    }

                    dynamicObjects.Add(noteButton);
                    Button tempButton = noteButton.gameObject.GetComponent<Button>();
                    int position = i;

                    tempButton.onClick.AddListener(() => SelectNote(position));
                }
            }

            if (dynamicObjects.Count > 0)
            {
                ParentRect.sizeDelta = new Vector2(ParentRectDefault.rect.width, screenRatio * (ParentRectHeight - (dynamicObjects[num_of_notes - 1].transform.position.y - (dynamicObjects[num_of_notes - 1].GetComponent<RectTransform>().rect.height))));
                ScrollBar.value = 1;
            }
        }
    }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        var scrollbarGO = GameObject.Find("LevelScrollbar");
        scrollBar = scrollbarGO.GetComponent<Scrollbar>();

        float levelsHeight = (ScenesParameters.LevelsNumber / 2 + 2) * Screen.width * 0.25f;

        var cameraGO = GameObject.Find("BottomCamera");
        camera = cameraGO.GetComponent<Camera>();

        if (levelsHeight < Screen.height)
        {
            GameObject.Find("UserUICanvas").SetActive(false);
        } else
        {
            scrollBar.size = 0.33f/*Screen.height / levelsHeight*/;
        }
    }
Пример #19
0
 /// <summary>
 /// 初始化
 /// </summary>
 public void Init(int _index)
 {
     Index = _index;
     MyChara = FightScene.PCharaList[Index];
     //抓取圖像&物件
     Ani_Icon = transform.FindChild("IconMask").FindChild("icon").GetComponent<Animator>();
     Image_Icon = Ani_Icon.transform.GetComponent<Image>();
     Ani_Hit = transform.FindChild("hit").GetComponent<Animator>();
     Ani_IconCover = transform.FindChild("iconCover").GetComponent<Animator>();
     SB_Health = transform.FindChild("Health").GetComponent<Scrollbar>();
     SB_Vitality = transform.FindChild("Vitality").GetComponent<Scrollbar>();
     //抓取SpellUI
     SpellUIs = new SpellUI[2];
     for (int i = 0; i < SpellUIs.Length; i++)
     {
         SpellUIs[i] = transform.FindChild(string.Format("Spell{0}", i)).GetComponent<SpellUI>();
         SpellUIs[i].Init(MyChara.ActivitySpells[i]);
     }
     IsInit = true;
 }
Пример #20
0
 public void Init()
 {
     MyTransform = transform;
     MyGameobject = gameObject;
     Text_Name = MyTransform.FindChild("Name").FindChild("name").GetComponent<Text>();
     SB_Health = MyTransform.FindChild("Health").GetComponent<Scrollbar>();
     SB_Vitality = MyTransform.FindChild("Vitality").GetComponent<Scrollbar>();
     Text_Lv = MyTransform.FindChild("Level").FindChild("Title").GetComponent<Text>();
     Text_Exp = MyTransform.FindChild("Level").FindChild("Text").GetComponent<Text>();
     Text_Constitution = MyTransform.FindChild("Constitution").FindChild("Text").GetComponent<Text>();
     Text_Mind = MyTransform.FindChild("Mind").FindChild("Text").GetComponent<Text>();
     Text_Strength = MyTransform.FindChild("Strength").FindChild("Text").GetComponent<Text>();
     Text_Faith = MyTransform.FindChild("Faith").FindChild("Text").GetComponent<Text>();
     Text_Will = MyTransform.FindChild("Will").FindChild("Text").GetComponent<Text>();
     Text_Alert = MyTransform.FindChild("Alert").FindChild("Text").GetComponent<Text>();
     Text_Skill = MyTransform.FindChild("Skill").FindChild("Text").GetComponent<Text>();
     Text_Agile = MyTransform.FindChild("Agile").FindChild("Text").GetComponent<Text>();
     Text_Point = MyTransform.FindChild("Point").FindChild("Text").GetComponent<Text>();
     Text_Talent = MyTransform.FindChild("Talent").FindChild("Text").GetComponent<Text>();
     Image_Talent = MyTransform.FindChild("Talent").FindChild("Icon").GetComponent<Image>();
 }
Пример #21
0
 private void Apply(Scrollbar item) {
     if(item == null) return;
     
     if(_handleImageSettings != null) _handleImageSettings.CopyTo(item.targetGraphic as Image);
     if(_backgroundImageSettings != null) _backgroundImageSettings.CopyTo(item.GetComponent<Image>());
 }
 void Start()
 {
     scrollBar = transform.Find("Scrollbar").GetComponent <Scrollbar>();
     ensureReferences();
 }
Пример #23
0
        /// <summary>
        /// Create "scrollView" node. If children supported - GameObject container for them should be returned.
        /// </summary>
        /// <param name="widget">Ui widget.</param>
        /// <param name="node">Xml node.</param>
        /// <param name="container">Markup container.</param>
        public static RectTransform Create(RectTransform widget, XmlNode node, MarkupContainer container)
        {
#if UNITY_EDITOR
            widget.name = "scrollView";
#endif
            float     amount;
            string    attrValue;
            Scrollbar horScroll = null;
            Scrollbar verScroll = null;

            var anchorMin     = Vector2.zero;
            var anchorMax     = Vector2.one;
            var offsetMin     = Vector3.zero;
            var offsetMax     = Vector3.zero;
            var needHorScroll = true;
            var needVerScroll = true;

            var theme = MarkupUtils.GetTheme(node, container);

            var scrollView = widget.gameObject.AddComponent <ScrollRect> ();

            // viewport.
            var viewport = MarkupUtils.CreateUiObject(ViewportName, widget);
            viewport.gameObject.AddComponent <RectMask2D> ();
            viewport.gameObject.AddComponent <NonVisualWidget> ().raycastTarget = false;
            viewport.anchorMin = Vector2.zero;
            viewport.anchorMax = Vector2.one;
            viewport.sizeDelta = Vector2.zero;
            viewport.pivot     = Vector2.up;

            // content.
            var content = MarkupUtils.CreateUiObject(ContentName, viewport);
            attrValue = node.GetAttribute(HashedContentSize);
            if (!string.IsNullOrEmpty(attrValue))
            {
                var parts = MarkupUtils.SplitAttrValue(attrValue);
                if (parts.Length > 0 && !string.IsNullOrEmpty(parts[0]))
                {
                    if (float.TryParse(parts[0], NumberStyles.Float, NumberFormatInfo.InvariantInfo, out amount))
                    {
                        amount     *= 0.5f;
                        offsetMin.x = -amount;
                        offsetMax.x = amount;
                        anchorMin.x = 0.5f;
                        anchorMax.x = 0.5f;
                    }
                }
                if (parts.Length > 1 && !string.IsNullOrEmpty(parts[1]))
                {
                    if (float.TryParse(parts[1], NumberStyles.Float, NumberFormatInfo.InvariantInfo, out amount))
                    {
                        amount     *= 0.5f;
                        offsetMin.y = -amount;
                        offsetMax.y = amount;
                        anchorMin.y = 0.5f;
                        anchorMax.y = 0.5f;
                    }
                }
            }
            content.anchorMin = anchorMin;
            content.anchorMax = anchorMax;
            content.offsetMin = offsetMin;
            content.offsetMax = offsetMax;

            attrValue = node.GetAttribute(HashedClamp);
            if (string.CompareOrdinal(attrValue, "true") == 0)
            {
                scrollView.movementType = ScrollRect.MovementType.Clamped;
            }

            attrValue = node.GetAttribute(HashedDrag);
            if (!string.IsNullOrEmpty(attrValue))
            {
                var parts = MarkupUtils.SplitAttrValue(attrValue);
                if (parts.Length > 0 && string.CompareOrdinal(parts[0], "false") == 0)
                {
                    scrollView.horizontal = false;
                }
                if (parts.Length > 1 && string.CompareOrdinal(parts[1], "false") == 0)
                {
                    scrollView.vertical = false;
                }
            }

            attrValue = node.GetAttribute(HashedBar);
            if (!string.IsNullOrEmpty(attrValue))
            {
                var parts = MarkupUtils.SplitAttrValue(attrValue);
                if (parts.Length > 0 && string.CompareOrdinal(parts[0], "false") == 0)
                {
                    needHorScroll = false;
                }
                if (parts.Length > 1 && string.CompareOrdinal(parts[1], "false") == 0)
                {
                    needVerScroll = false;
                }
            }

            if (needHorScroll)
            {
                horScroll = CreateScrollbar(widget, theme, true);
                MarkupUtils.SetNav(horScroll, node, container.UseNavigation);
            }
            if (needVerScroll)
            {
                verScroll = CreateScrollbar(widget, theme, false);
                MarkupUtils.SetNav(verScroll, node, container.UseNavigation);
            }

            attrValue = node.GetAttribute(HashedOnChange);
            if (!string.IsNullOrEmpty(attrValue))
            {
                widget.gameObject.AddComponent <NonVisualWidget> ();
                widget.gameObject.AddComponent <UiScrollViewAction> ().SetGroup(attrValue);
            }

            scrollView.content  = content;
            scrollView.viewport = viewport;
            scrollView.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
            scrollView.verticalScrollbarVisibility   = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
            scrollView.horizontalScrollbar           = horScroll;
            scrollView.verticalScrollbar             = verScroll;
            scrollView.decelerationRate = 0.01f;

            MarkupUtils.SetSize(widget, node);
            MarkupUtils.SetRotation(widget, node);
            MarkupUtils.SetOffset(widget, node);
            MarkupUtils.SetHidden(widget, node);

            scrollView.normalizedPosition = Vector2.up;

            return(content);
        }
Пример #24
0
 void Start()
 {
     _button    = GameObject.Find("Canvas/Button").GetComponent <Button>();
     _scrollbar = GameObject.Find("Canvas/Scrollbar").GetComponent <Scrollbar>();
     _button.onClick.AddListener(delegate() { ShowP("Scene02"); });
 }
Пример #25
0
    private float decreaseValue = 0.1f / 30f; // 10msで減らすゲージの割合

    private void Start()
    {
        timerUi = this.GetComponent <Scrollbar> ();
    }
    // Process is called by UI system to process events
    public override void Process()
    {
        _singleton = this;

        // send update events if there is a selected object - this is important for InputField to receive keyboard events
        SendUpdateEventToSelectedObject();

        // see if there is a UI element that is currently being looked at
        PointerEventData lookData = GetLookPointerEventData();

        currentLook = lookData.pointerCurrentRaycast.gameObject;

        // deselect when look away
        if (deselectWhenLookAway && currentLook == null)
        {
            ClearSelection();
        }

        // handle enter and exit events (highlight)
        // using the function that is already defined in BaseInputModule
        HandlePointerExitAndEnter(lookData, currentLook);

        // update cursor
        UpdateCursor(lookData);

        if (!ignoreInputsWhenLookAway || ignoreInputsWhenLookAway && currentLook != null)
        {
            // button down handling
            _buttonUsed = false;
            if (Input.GetButtonDown(submitButtonName))
            {
                ClearSelection();
                lookData.pressPosition       = lookData.position;
                lookData.pointerPressRaycast = lookData.pointerCurrentRaycast;
                lookData.pointerPress        = null;
                if (currentLook != null)
                {
                    currentPressed = currentLook;
                    GameObject newPressed = null;
                    if (mode == Mode.Pointer)
                    {
                        newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.pointerDownHandler);
                        if (newPressed == null)
                        {
                            // some UI elements might only have click handler and not pointer down handler
                            newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.pointerClickHandler);
                            if (newPressed != null)
                            {
                                currentPressed = newPressed;
                            }
                        }
                        else
                        {
                            currentPressed = newPressed;
                            // we want to do click on button down at same time, unlike regular mouse processing
                            // which does click when mouse goes up over same object it went down on
                            // reason to do this is head tracking might be jittery and this makes it easier to click buttons
                            ExecuteEvents.Execute(newPressed, lookData, ExecuteEvents.pointerClickHandler);
                        }
                    }
                    else if (mode == Mode.Submit)
                    {
                        newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.submitHandler);
                        if (newPressed == null)
                        {
                            // try select handler instead
                            newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.selectHandler);
                        }
                    }
                    if (newPressed != null)
                    {
                        lookData.pointerPress = newPressed;
                        currentPressed        = newPressed;
                        Select(currentPressed);
                        _buttonUsed = true;
                    }
                    if (mode == Mode.Pointer)
                    {
                        if (useLookDrag)
                        {
                            bool useLookTest = true;
                            if (!useLookDragSlider && currentPressed.GetComponent <Slider>())
                            {
                                useLookTest = false;
                            }
                            else if (!useLookDragScrollbar && currentPressed.GetComponent <Scrollbar>())
                            {
                                useLookTest = false;
                                // the following is for scrollbars to work right
                                // apparently they go into an odd drag mode when pointerDownHandler is called
                                // a begin/end drag fixes that
                                if (ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler))
                                {
                                    ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.endDragHandler);
                                }
                            }
                            if (useLookTest)
                            {
                                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler);
                                lookData.pointerDrag = currentPressed;
                                currentDragging      = currentPressed;
                            }
                        }
                        else if (currentPressed.GetComponent <Scrollbar>())
                        {
                            // the following is for scrollbars to work right
                            // apparently they go into an odd drag mode when pointerDownHandler is called
                            // a begin/end drag fixes that
                            if (ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler))
                            {
                                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.endDragHandler);
                            }
                        }
                    }
                }
            }
        }

        // have to handle button up even if looking away
        if (Input.GetButtonUp(submitButtonName))
        {
            if (currentDragging)
            {
                ExecuteEvents.Execute(currentDragging, lookData, ExecuteEvents.endDragHandler);
                if (currentLook != null)
                {
                    ExecuteEvents.ExecuteHierarchy(currentLook, lookData, ExecuteEvents.dropHandler);
                }
                lookData.pointerDrag = null;
                currentDragging      = null;
            }
            if (currentPressed)
            {
                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.pointerUpHandler);
                lookData.rawPointerPress = null;
                lookData.pointerPress    = null;
                currentPressed           = null;
            }
        }

        // drag handling
        if (currentDragging != null)
        {
            ExecuteEvents.Execute(currentDragging, lookData, ExecuteEvents.dragHandler);
        }

        if (!ignoreInputsWhenLookAway || ignoreInputsWhenLookAway && currentLook != null)
        {
            // control axis handling
            _controlAxisUsed = false;
            if (eventSystem.currentSelectedGameObject && controlAxisName != null && controlAxisName != "")
            {
                float newVal = Input.GetAxis(controlAxisName);
                if (newVal > 0.01f || newVal < -0.01f)
                {
                    if (useSmoothAxis)
                    {
                        Slider sl = eventSystem.currentSelectedGameObject.GetComponent <Slider>();
                        if (sl != null)
                        {
                            float mult = sl.maxValue - sl.minValue;
                            sl.value        += newVal * smoothAxisMultiplier * mult;
                            _controlAxisUsed = true;
                        }
                        else
                        {
                            Scrollbar sb = eventSystem.currentSelectedGameObject.GetComponent <Scrollbar>();
                            if (sb != null)
                            {
                                sb.value        += newVal * smoothAxisMultiplier;
                                _controlAxisUsed = true;
                            }
                        }
                    }
                    else
                    {
                        _controlAxisUsed = true;
                        float time = Time.unscaledTime;
                        if (time > nextAxisActionTime)
                        {
                            nextAxisActionTime = time + 1f / steppedAxisStepsPerSecond;
                            AxisEventData axisData = GetAxisEventData(newVal, 0.0f, 0.0f);
                            if (!ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisData, ExecuteEvents.moveHandler))
                            {
                                _controlAxisUsed = false;
                            }
                        }
                    }
                }
            }
        }
    }
Пример #27
0
 /// <summary>
 /// Set the value of a Scrollbar
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="value"></param>
 /// <param name="sendCallback">Whether to trigger events</param>
 public static void Set(this Scrollbar instance, float value, bool sendCallback = false)
 {
     ScrollbarSetMethod.Invoke(instance, new object[] { value, sendCallback });
 }
Пример #28
0
        public static GameObject CreateDropdown(Resources resources)
        {
            GameObject root = CreateUIElementRoot("Dropdown", s_ThickElementSize);

            GameObject label          = CreateUIObject("Label", root);
            GameObject arrow          = CreateUIObject("Arrow", root);
            GameObject template       = CreateUIObject("Template", root);
            GameObject viewport       = CreateUIObject("Viewport", template);
            GameObject content        = CreateUIObject("Content", viewport);
            GameObject item           = CreateUIObject("Item", content);
            GameObject itemBackground = CreateUIObject("Item Background", item);
            GameObject itemCheckmark  = CreateUIObject("Item Checkmark", item);
            GameObject itemLabel      = CreateUIObject("Item Label", item);

            // Sub controls.

            GameObject scrollbar = CreateScrollbar(resources);

            scrollbar.name = "Scrollbar";
            SetParentAndAlign(scrollbar, template);

            Scrollbar scrollbarScrollbar = scrollbar.GetComponent <Scrollbar>();

            scrollbarScrollbar.SetDirection(Scrollbar.Direction.BottomToTop, true);

            RectTransform vScrollbarRT = scrollbar.GetComponent <RectTransform>();

            vScrollbarRT.anchorMin = Vector2.right;
            vScrollbarRT.anchorMax = Vector2.one;
            vScrollbarRT.pivot     = Vector2.one;
            vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0);

            // Setup item UI components.

            Text itemLabelText = itemLabel.AddComponent <Text>();

            SetDefaultTextValues(itemLabelText);
            itemLabelText.alignment = TextAnchor.MiddleLeft;

            Image itemBackgroundImage = itemBackground.AddComponent <Image>();

            itemBackgroundImage.color = new Color32(245, 245, 245, 255);

            Image itemCheckmarkImage = itemCheckmark.AddComponent <Image>();

            itemCheckmarkImage.SetSprite("common_white");
            itemCheckmarkImage.color = Color.gray;

            Toggle itemToggle = item.AddComponent <Toggle>();

            itemToggle.targetGraphic = itemBackgroundImage;
            itemToggle.graphic       = itemCheckmarkImage;
            itemToggle.isOn          = true;

            // Setup template UI components.

            Image templateImage = template.AddComponent <Image>();

            templateImage.SetSprite("common_white");

            ScrollRect templateScrollRect = template.AddComponent <ScrollRect>();

            templateScrollRect.content                     = (RectTransform)content.transform;
            templateScrollRect.viewport                    = (RectTransform)viewport.transform;
            templateScrollRect.horizontal                  = false;
            templateScrollRect.movementType                = ScrollRect.MovementType.Clamped;
            templateScrollRect.verticalScrollbar           = scrollbarScrollbar;
            templateScrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
            templateScrollRect.verticalScrollbarSpacing    = -3;

            Mask scrollRectMask = viewport.AddComponent <Mask>();

            scrollRectMask.showMaskGraphic = false;

            Image viewportImage = viewport.AddComponent <Image>();

            viewportImage.SetSprite("common_white");
            viewportImage.type = UnityEngine.UI.Image.Type.Sliced;

            // Setup dropdown UI components.

            Text labelText = label.AddComponent <Text>();

            SetDefaultTextValues(labelText);
            labelText.alignment = TextAnchor.MiddleLeft;

            Image arrowImage = arrow.AddComponent <Image>();

            arrowImage.SetSprite("common_white");
            arrowImage.color = Color.black;

            Image backgroundImage = root.AddComponent <Image>();

            backgroundImage.SetSprite("common_white");
            backgroundImage.color = s_DefaultSelectableColor;
            backgroundImage.type  = Image.Type.Sliced;

            Dropdown dropdown = root.AddComponent <Dropdown>();

            dropdown.targetGraphic = backgroundImage;
            SetDefaultColorTransitionValues(dropdown);
            dropdown.template    = template.GetComponent <RectTransform>();
            dropdown.captionText = labelText;
            dropdown.itemText    = itemLabelText;
            labelText.color      = Color.black;
            itemLabelText.color  = Color.blue;

            // Setting default Item list.
            itemLabelText.text = "Option A";
            dropdown.options.Add(new Dropdown.OptionData {
                text = "Option A"
            });
            dropdown.options.Add(new Dropdown.OptionData {
                text = "Option B"
            });
            dropdown.options.Add(new Dropdown.OptionData {
                text = "Option C"
            });
            dropdown.RefreshShownValue();

            // Set up RectTransforms.

            RectTransform labelRT = label.GetComponent <RectTransform>();

            labelRT.anchorMin = Vector2.zero;
            labelRT.anchorMax = Vector2.one;
            labelRT.offsetMin = new Vector2(10, 6);
            labelRT.offsetMax = new Vector2(-25, -7);

            RectTransform arrowRT = arrow.GetComponent <RectTransform>();

            arrowRT.anchorMin        = new Vector2(1, 0.5f);
            arrowRT.anchorMax        = new Vector2(1, 0.5f);
            arrowRT.sizeDelta        = new Vector2(20, 20);
            arrowRT.anchoredPosition = new Vector2(-15, 0);

            RectTransform templateRT = template.GetComponent <RectTransform>();

            templateRT.anchorMin        = new Vector2(0, 0);
            templateRT.anchorMax        = new Vector2(1, 0);
            templateRT.pivot            = new Vector2(0.5f, 1);
            templateRT.anchoredPosition = new Vector2(0, 2);
            templateRT.sizeDelta        = new Vector2(0, 150);

            RectTransform viewportRT = viewport.GetComponent <RectTransform>();

            viewportRT.anchorMin = new Vector2(0, 0);
            viewportRT.anchorMax = new Vector2(1, 1);
            viewportRT.sizeDelta = new Vector2(-18, 0);
            viewportRT.pivot     = new Vector2(0, 1);

            RectTransform contentRT = content.GetComponent <RectTransform>();

            contentRT.anchorMin        = new Vector2(0f, 1);
            contentRT.anchorMax        = new Vector2(1f, 1);
            contentRT.pivot            = new Vector2(0.5f, 1);
            contentRT.anchoredPosition = new Vector2(0, 0);
            contentRT.sizeDelta        = new Vector2(0, 28);

            RectTransform itemRT = item.GetComponent <RectTransform>();

            itemRT.anchorMin = new Vector2(0, 0.5f);
            itemRT.anchorMax = new Vector2(1, 0.5f);
            itemRT.sizeDelta = new Vector2(0, 20);

            RectTransform itemBackgroundRT = itemBackground.GetComponent <RectTransform>();

            itemBackgroundRT.anchorMin = Vector2.zero;
            itemBackgroundRT.anchorMax = Vector2.one;
            itemBackgroundRT.sizeDelta = Vector2.zero;

            RectTransform itemCheckmarkRT = itemCheckmark.GetComponent <RectTransform>();

            itemCheckmarkRT.anchorMin        = new Vector2(0, 0.5f);
            itemCheckmarkRT.anchorMax        = new Vector2(0, 0.5f);
            itemCheckmarkRT.sizeDelta        = new Vector2(20, 20);
            itemCheckmarkRT.anchoredPosition = new Vector2(10, 0);

            RectTransform itemLabelRT = itemLabel.GetComponent <RectTransform>();

            itemLabelRT.anchorMin = Vector2.zero;
            itemLabelRT.anchorMax = Vector2.one;
            itemLabelRT.offsetMin = new Vector2(20, 1);
            itemLabelRT.offsetMax = new Vector2(-10, -2);

            template.SetActive(false);

            return(root);
        }
Пример #29
0
 void Awake()
 {
     bar = GetComponent <Scrollbar>();
 }
Пример #30
0
 // Use this for initialization
 void Start()
 {
     topSand     = Utility.FindChildByName("TopSand", transform).GetComponent <Scrollbar>();
     botSand     = Utility.FindChildByName("BotSand", transform).GetComponent <Scrollbar>();
     fallingSand = Utility.FindChildByName("FallingSand", transform).GetComponent <Scrollbar>();
 }
Пример #31
0
        //-----------------------------------------------------------

        // XR用
        private void ProcessForXR()
        {
            // 選択中のオブジェクトの状態を更新する
            SendUpdateEventToSelectedObject();                  // デフォルトのものを使用する

            // レイキャストでヒットしたUIの情報を取得する(VR限定)
            PointerEventData tLookData = GetLookPointerEventData(UnityEngine.XR.XRSettings.eyeTextureWidth / 2, UnityEngine.XR.XRSettings.eyeTextureHeight / 2);

            m_CurrentLook = tLookData.pointerCurrentRaycast.gameObject;

            // deselect when look away
            if (m_CurrentLook == null)
            {
                // 選択中のUIを非選択状態にする
                ClearSelection();
            }

            // UIの領域に入ったまたは出た際の処理を実行する
            HandlePointerExitAndEnter(tLookData, m_CurrentLook);

            //----------------------------------

            bool tIsPressAction = false;

            if (m_OnPressAction != null)
            {
                // アクションボタン指定あり
                tIsPressAction = m_OnPressAction(m_CurrentLook);
            }

            //----------------------------------

            // 押された判定
            bool tDown = false;

            if (m_OnPressAction == null)
            {
                if (Input.GetMouseButtonDown(0) == true)
                {
                    tDown = true;
                }
            }
            else
            {
                if (m_IsPressAction == false && tIsPressAction == true)
                {
                    m_IsPressAction = true;
                    tDown           = true;
                }
            }

            if (m_CurrentLook != null)
            {
                // UIの上にある

                //---------------------------------

                if (tDown == true)
                {
                    // 押された

                    // 選択中のUIの表示を非選択状態に戻す
                    ClearSelection();

                    tLookData.pressPosition       = tLookData.position;
                    tLookData.pointerPressRaycast = tLookData.pointerCurrentRaycast;
                    tLookData.pointerPress        = null;

                    // プレス判定
                    m_CurrentPressed = ExecuteEvents.ExecuteHierarchy(m_CurrentLook, tLookData, ExecuteEvents.pointerDownHandler);

                    if (m_CurrentPressed != null)
                    {
                        // 階層上にプレスに反応するものがある

                        // 新規プレス
                        tLookData.pointerPress = m_CurrentPressed;

                        // 表示状態を変更する
                        ClearSelection();                               // 古い方の状態を解除

                        // フォーカスを当てられるか判定する
                        if (ExecuteEvents.GetEventHandler <ISelectHandler>(m_CurrentPressed) != null)
                        {
                            // フォーカスをあてる
                            eventSystem.SetSelectedGameObject(m_CurrentPressed);
                        }
                    }

                    // ドラッグ開始
                    ExecuteEvents.Execute(m_CurrentPressed, tLookData, ExecuteEvents.beginDragHandler);

                    tLookData.pointerDrag = m_CurrentPressed;
                    m_CurrentDragging     = m_CurrentPressed;
                }
            }

            //----------------------------------------------------------

            // 離された判定
            bool tUp = false;

            if (m_OnPressAction == null)
            {
                if (Input.GetMouseButtonUp(0) == true)
                {
                    tUp = true;
                }
            }
            else
            {
                if (m_IsPressAction == true && tIsPressAction == false)
                {
                    m_IsPressAction = false;
                    tUp             = true;
                }
            }

            //----------------------------------

            if (tUp == true)
            {
                // 離された

                if (m_CurrentDragging != null)
                {
                    // ドラッグ中ならドラッグを終了する

                    // ドラッグ終了
                    ExecuteEvents.Execute(m_CurrentDragging, tLookData, ExecuteEvents.endDragHandler);

                    if (m_CurrentLook != null)
                    {
                        // ドロップ実行
                        ExecuteEvents.ExecuteHierarchy(m_CurrentLook, tLookData, ExecuteEvents.dropHandler);
                    }

                    tLookData.pointerDrag = null;
                    m_CurrentDragging     = null;
                }

                if (m_CurrentPressed != null)
                {
                    // プレス中ならプレスを終了する

                    // プレス終了
                    ExecuteEvents.Execute(m_CurrentPressed, tLookData, ExecuteEvents.pointerUpHandler);

                    tLookData.rawPointerPress = null;
                    tLookData.pointerPress    = null;

                    if (m_CurrentLook != null)
                    {
                        // クリックを判定する
                        if (ExecuteEvents.GetEventHandler <IPointerDownHandler>(m_CurrentLook) == m_CurrentPressed)
                        {
                            // クリックされた
                            ExecuteEvents.Execute(m_CurrentPressed, tLookData, ExecuteEvents.pointerClickHandler);
                        }
                    }

                    m_CurrentPressed = null;
                }
            }

            // drag handling
            if (m_CurrentDragging != null)
            {
                // ドラッグ実行
                ExecuteEvents.Execute(m_CurrentDragging, tLookData, ExecuteEvents.dragHandler);
            }

            //----------------------------------------------------------

            if (m_CurrentLook != null)
            {
                // 方向キー操作
                if (eventSystem.currentSelectedGameObject != null && string.IsNullOrEmpty(horizontalAxis) == false)
                {
                    float tNewValue = Input.GetAxis(horizontalAxis);
                    if (tNewValue > 0.01f || tNewValue < -0.01f)
                    {
                        if (useSmoothAxis == true)
                        {
                            // スムース動作有効
                            Slider sl = eventSystem.currentSelectedGameObject.GetComponent <Slider>();
                            if (sl != null)
                            {
                                // 対象はスライダー
                                float tMulti = sl.maxValue - sl.minValue;
                                sl.value += tNewValue * smoothAxisMultiplier * tMulti;
                            }
                            else
                            {
                                Scrollbar sb = eventSystem.currentSelectedGameObject.GetComponent <Scrollbar>();
                                if (sb != null)
                                {
                                    // 対象はスクロールバー
                                    sb.value += tNewValue * smoothAxisMultiplier;
                                }
                                ScrollbarWrapper sbw = eventSystem.currentSelectedGameObject.GetComponent <ScrollbarWrapper>();
                                if (sbw != null)
                                {
                                    // 対象はスクロールバー
                                    sbw.value += tNewValue * smoothAxisMultiplier;
                                }
                            }
                        }
                        else
                        {
                            // スムース動作はしない
                            float tTime = Time.unscaledTime;

                            if (tTime > m_NextAxisActionTime)
                            {
                                m_NextAxisActionTime = tTime + (1f / inputActionsPerSecond);
                                AxisEventData tAxisData = GetAxisEventData(tNewValue, 0.0f, 0.0f);
                                if (ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, tAxisData, ExecuteEvents.moveHandler) == false)
                                {
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #32
0
 void Start()
 {
     s       = GameObject.Find("Scrollbar").GetComponent <Scrollbar>();
     s.value = 1;
 }
 private void Start()
 {
     sb   = GetComponentInChildren <Scrollbar>();
     life = _monster.life;
 }
Пример #34
0
 void Start()
 {
     healthBar = GetComponent <Scrollbar> ();
     alive     = GetComponentInParent <Alive> ();
 }
    public void InitializeStuff()
    {
        //Initialize Canvas items...
        GameObject canvas = GameObject.FindGameObjectWithTag (Tags.canvas);
        Text[] allText = canvas.GetComponentsInChildren<Text> ();
        foreach (Text txt in allText){
            if(txt.tag == Tags.dialogueText){
                dialogueTextField = txt;
            }
            else if(txt.tag == Tags.characterNameText){
                characterNameText = txt;
            }
        }
        Scrollbar[] allScrollBars = canvas.GetComponentsInChildren<Scrollbar> ();
        foreach (Scrollbar sb in allScrollBars){
            if(sb.tag == Tags.scrollBar){
                scrollBar = sb;
            }
        }

        //Initialize particle system for Interaction Indicator...
        indicatorParticleSystem = GetComponentInChildren<ParticleSystem> ();

        cursorGO = GameObject.FindGameObjectWithTag (Tags.cursor);

        //Initialize interaction collider on awake...
        col = GetComponent<SphereCollider>();
        SetColliderPosition ();

        //Parse the text file into the array, dialogueTextParsed...
        dialogueTextParsed = dialogueText.text.Split('\n');

        if(messageIsUrgent && !noMessageJustMove){
            indicatorParticleSystem.Play ();
        }
        playerTransform = GameObject.FindGameObjectWithTag (Tags.player).transform;

        playerRB = playerTransform.GetComponent<Rigidbody>();

        //Initialize NPC NavMeshAgent and EnemyAI...
        nav = gameObject.GetComponentInParent<NavMeshAgent> ();
        enemyAI = gameObject.GetComponentInParent<EnemyAI> ();

        //Get interaction rate from Player..
        interactionRate = GameObject.FindGameObjectWithTag (Tags.player).GetComponent<PlayerInteraction> ().interactionRate;

        //Get animator info...
        animatorArrayNPC = transform.parent.GetComponentsInChildren<Animator> ();

        //Initialize dialoguePanelOpenClose...
        dialoguePanelOpenClose = canvas.GetComponentInChildren<DialoguePanelOpenClose> ();
    }
Пример #36
0
 void Start()
 {
     scrollbar = playerSelectionScrollBar.GetComponent <Scrollbar>();
 }
Пример #37
0
 // Use this for initialization
 void Start()
 {
     ParentButtonDefault = ParentButton;
     ParentRectDefault = ParentButtonDefault.GetComponent<RectTransform>();
     ParentRectHeight = ParentRectDefault.rect.height;
     ParentRect = ParentRectDefault;
     ScrollBar = ScrollView.gameObject.transform.GetChild(1).GetComponent<Scrollbar>();
 }
Пример #38
0
    private static void Anchor(RectTransform rectTransform)
    {
        Slider slider = null;

        if (rectTransform.GetComponentsInParent <Slider>(true).Length != 0)
        {
            slider = rectTransform.GetComponentsInParent <Slider>(true)[0];
        }
        Scrollbar scrollbar = null;

        if (rectTransform.GetComponentsInParent <Scrollbar>(true).Length != 0)
        {
            scrollbar = rectTransform.GetComponentsInParent <Scrollbar>(true)[0];
        }
        Dropdown dropdown = null;

        if (rectTransform.GetComponentsInParent <Dropdown>(true).Length != 0)
        {
            dropdown = rectTransform.GetComponentsInParent <Dropdown>(true)[0];
        }
        InputField inputField = null;

        if (rectTransform.GetComponentsInParent <InputField>(true).Length != 0)
        {
            inputField = rectTransform.GetComponentsInParent <InputField>(true)[0];
        }
        ScrollRect scrollRect = null;

        if (rectTransform.GetComponentsInParent <ScrollRect>(true).Length != 0)
        {
            scrollRect = rectTransform.GetComponentsInParent <ScrollRect>(true)[0];
        }

        RectTransform parentRectTransform = null;

        if (rectTransform.transform.parent)
        {
            parentRectTransform = rectTransform.transform.parent.GetComponent <RectTransform>();
        }

        if (!parentRectTransform)
        {
            return;
        }
        else
        {
            if (rectTransform.GetComponent <ContentSizeFitter>() || rectTransform.transform.parent.GetComponent <LayoutGroup>())
            {
                return;
            }
            else if (slider && (rectTransform.transform == slider.handleRect.parent || rectTransform == slider.handleRect || rectTransform.transform == slider.fillRect.parent || rectTransform == slider.fillRect))
            {
                return;
            }
            else if (scrollbar && (rectTransform.transform == scrollbar.handleRect.parent || rectTransform == scrollbar.handleRect))
            {
                return;
            }
            else if (dropdown && (rectTransform == dropdown.template || rectTransform == dropdown.captionText.rectTransform))
            {
                return;
            }
            else if (inputField && (rectTransform == inputField.textComponent.rectTransform || rectTransform == inputField.placeholder.rectTransform || rectTransform.gameObject.name.Equals("InputField Input Caret")))
            {
                return;
            }
            else if (scrollRect && (rectTransform == scrollRect.viewport || rectTransform == scrollRect.content || (scrollRect.horizontalScrollbar && rectTransform.gameObject == scrollRect.horizontalScrollbar.gameObject) || (scrollRect.verticalScrollbar && rectTransform.gameObject == scrollRect.verticalScrollbar.gameObject)))
            {
                return;
            }
        }

        Undo.RecordObject(rectTransform, "Anchor UI Object");
        Rect parentRect = parentRectTransform.rect;

        rectTransform.anchorMin = new Vector2(rectTransform.anchorMin.x + (rectTransform.offsetMin.x / parentRect.width), rectTransform.anchorMin.y + (rectTransform.offsetMin.y / parentRect.height));
        rectTransform.anchorMax = new Vector2(rectTransform.anchorMax.x + (rectTransform.offsetMax.x / parentRect.width), rectTransform.anchorMax.y + (rectTransform.offsetMax.y / parentRect.height));
        rectTransform.offsetMin = Vector2.zero;
        rectTransform.offsetMax = Vector2.zero;
        rectTransform.pivot     = new Vector2(0.5f, 0.5f);
        rectTransform.pivot     = new Vector2(0.5f, 0.5f);
    }
Пример #39
0
 // Use this for initialization
 void Start()
 {
     VerScroll = GetComponent <Scrollbar> ();
 }
Пример #40
0
        public static GameObject NewScrollView(Vector2 size = default(Vector2), BarType barType = BarType.None, ContentType contentType = ContentType.VerticalLayout, Vector2 spacing = default(Vector2), Vector2 gridSize = default(Vector2))
        {
            //创建ScrollRect
            GameObject go1 = new GameObject("ScrollView", new System.Type[]
                                            { typeof(RectTransform), typeof(ScrollRect) });

            go1.layer = Main.Layer;
            RectTransform tf1 = go1.GetComponent <RectTransform>();

            tf1.anchoredPosition = new Vector2(0, 0);
            tf1.sizeDelta        = size == default(Vector2) ? new Vector2(100, 100) : size;
            ScrollRect scrollRect = go1.GetComponent <ScrollRect>();

            scrollRect.horizontal = false;

            //创建Viewport
            GameObject go2 = new GameObject("Viewport", new System.Type[]
                                            { typeof(RectTransform), typeof(Mask),
                                              typeof(Image) });

            go2.layer = Main.Layer;
            RectTransform tf2 = go2.GetComponent <RectTransform>();

            tf2.SetParent(tf1, false);
            tf2.anchorMin        = new Vector2(0, 0);
            tf2.anchorMax        = new Vector2(1, 1);
            tf2.anchoredPosition = new Vector2(0, 0);
            tf2.sizeDelta        = new Vector2(-17, -17);
            tf2.pivot            = new Vector2(0, 1);
            Image image2 = go2.GetComponent <Image>();

            image2.color = new Color(0.5568628f, 0.5568628f, 0.5568628f);
            Mask mask = go2.GetComponent <Mask>();

            mask.showMaskGraphic = false;

            //创建Content
            GameObject go3 = new GameObject("Content", new System.Type[]
                                            { typeof(RectTransform), typeof(ContentSizeFitter) });

            go3.layer = Main.Layer;
            RectTransform tf3 = go3.GetComponent <RectTransform>();

            tf3.SetParent(tf2, false);
            tf3.anchorMin        = new Vector2(0, 1);
            tf3.anchorMax        = new Vector2(1, 1);
            tf3.anchoredPosition = new Vector2(0, 0);
            tf3.sizeDelta        = new Vector2(0, 0);
            tf3.pivot            = new Vector2(0.5f, 1);
            ContentSizeFitter contentSizeFitter = tf3.GetComponent <ContentSizeFitter>();

            contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
            switch (contentType)
            {
            case ContentType.Grid:
                GridLayoutGroup gridLayoutGroup = go3.AddComponent <GridLayoutGroup>();
                gridLayoutGroup.cellSize = gridSize == default(Vector2) ? new Vector2(100, 100) : gridSize;
                gridLayoutGroup.spacing  = spacing;
                break;

            case ContentType.VerticalLayout:
                VerticalLayoutGroup verticalLayoutGroup = go3.AddComponent <VerticalLayoutGroup>();
                verticalLayoutGroup.spacing                = spacing.y;
                verticalLayoutGroup.childControlHeight     = false;
                verticalLayoutGroup.childControlWidth      = false;
                verticalLayoutGroup.childForceExpandHeight = false;
                verticalLayoutGroup.childForceExpandWidth  = false;
                verticalLayoutGroup.childAlignment         = TextAnchor.UpperCenter;
                break;

            default:
                break;
            }

            //关联控件
            scrollRect.viewport = tf2;
            scrollRect.content  = tf3;
            switch (barType)
            {
            case BarType.Vertical:
                GameObject go4 = new GameObject("ScrollbarVertical", new System.Type[]
                                                { typeof(RectTransform), typeof(Image), typeof(Scrollbar) });
                go4.layer = Main.Layer;
                RectTransform tf4 = go4.GetComponent <RectTransform>();
                tf4.SetParent(tf1, false);
                tf4.anchorMin        = new Vector2(1, 0);
                tf4.anchorMax        = new Vector2(1, 1);
                tf4.anchoredPosition = new Vector2(0, 0);
                tf4.sizeDelta        = new Vector2(Main.settings.handWidth, 0);
                tf4.pivot            = new Vector2(1, 1);
                Image image4 = go4.GetComponent <Image>();
                image4.sprite = default(Sprite);
                image4.color  = new Color(Main.settings.bgR, Main.settings.bgG, Main.settings.bgB);
                Scrollbar scrollbar = go4.GetComponent <Scrollbar>();
                scrollbar.direction = Scrollbar.Direction.BottomToTop;

                GameObject go5 = new GameObject("SlidingArea", new System.Type[]
                                                { typeof(RectTransform) });
                go5.layer = Main.Layer;
                RectTransform tf5 = go5.GetComponent <RectTransform>();
                tf5.SetParent(tf4, false);
                tf5.anchorMin        = new Vector2(0, 0);
                tf5.anchorMax        = new Vector2(1, 1);
                tf5.anchoredPosition = new Vector2(0, 0);
                tf5.sizeDelta        = new Vector2(-20, -20);
                tf5.pivot            = new Vector2(0.5f, 0.5f);

                GameObject go6 = new GameObject("Handle", new System.Type[]
                                                { typeof(RectTransform), typeof(Image) });
                go6.layer = Main.Layer;
                RectTransform tf6 = go6.GetComponent <RectTransform>();
                tf6.SetParent(tf5, false);
                tf6.anchorMin        = new Vector2(0, 0.5f);
                tf6.anchorMax        = new Vector2(1, 1);
                tf6.anchoredPosition = new Vector2(0, 0);
                tf6.sizeDelta        = new Vector2(20, 20);
                tf6.pivot            = new Vector2(0.5f, 0.5f);
                Image image6 = go6.GetComponent <Image>();
                image6.sprite = default(Sprite);
                image6.color  = new Color(Main.settings.handR, Main.settings.handG, Main.settings.handB);

                scrollbar.targetGraphic                = image6;
                scrollbar.handleRect                   = tf6;
                scrollRect.verticalScrollbar           = scrollbar;
                scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
                scrollRect.verticalScrollbarSpacing    = -3;

                Main.hands.Add(new Main.HandData(image4, image6, tf4, tf6));
                break;

            default:
                break;
            }
            return(go1);
        }
Пример #41
0
 // Use this for initialization
 void Start()
 {
     scrollbar = GetComponent <Scrollbar>();
     initializeScrollBar(4);
 }
Пример #42
0
 // Use this for initialization
 void Start()
 {
     scrollRect = this.gameObject.GetComponent<ScrollRect>();
     scrollbar = scrollRect.verticalScrollbar;
 }
Пример #43
0
 public BarMeter(Scrollbar _bar, float _init, float _end)
 {
     this.barMeter     = _bar;
     this.initialValue = _init;
     this.endValue     = _end;
 }
Пример #44
0
 // Use this for initialization
 void Start()
 {
     //parent = transform.parent.gameObject;
     //contents = transform.Find("Contents").gameObject;
     pageButtonsContens = transform.Find("PageButtonsContents").gameObject;
     contents = transform.Find("Ranking View").Find("Contents").gameObject;
     if(scrollbarContainer != null)
         scrollbar = scrollbarContainer.GetComponent<Scrollbar>();
     dataManager = DataManager.Instace;
     dataManager.OnHttpRequest += OnHttpRequest;
     queryState = QueryState.All;
     GetTargetIndexInAllRanking(0);
 }
Пример #45
0
    void Start()
    {
        HealthSeed1 = new float[5];
        HealthSeed2 = new float[5];
        HealthSeed3 = new float[5];

        Afactor = Random.Range(1, 8) + Random.Range(0, 1) - Random.Range(0, 1); // Life encounters of disease riden or hazardus places places (0 = none 9 = its where you live)
        Bfactor = Random.Range(1, 8) + Random.Range(0, 1) - Random.Range(0, 1); // Genetic occurences of mutations (0 = none 9 = very damaged DNA)
        Cfactor = Random.Range(1, 8) + Random.Range(0, 1) - Random.Range(0, 1); // Life encounters of STDs (0 = none 9 = regularly)
        Dfactor = Random.Range(1, 8) + Random.Range(0, 1) - Random.Range(0, 1); // Immune system strength (0 = almost no immune system 9 = increadibly strong immune system)
        Efactor = Random.Range(1, 8) + Random.Range(0, 1) - Random.Range(0, 1); // Immune system reactiveness (attacking self -> functioning properly -> attacking nothing)

        Randomize(false, true);

        //HealthSeed = new float[5];
        //HealthSeed[0] = Afactor;
        //HealthSeed[1] = Bfactor;
        //HealthSeed[2] = Cfactor;
        //HealthSeed[3] = Dfactor;
        //HealthSeed[4] = Efactor;

        int GChance = Random.Range(0, 100);

        if (GChance >= 0 && GChance < 60)
        {
            UnitGender = "Male"; ReproductiveOrgans = "Male";
        }
        if (GChance >= 60 && GChance < 90)
        {
            UnitGender = "Female"; ReproductiveOrgans = "Female";
        }
        if (GChance >= 90 && GChance <= 100)
        {
            UnitGender = "LGBTQ"; if (GChance >= 90 && GChance < 95)
            {
                ReproductiveOrgans = "Male";
            }
            if (GChance >= 95 && GChance < 100)
            {
                ReproductiveOrgans = "Female";
            }
        }
        if (Random.Range(0, 50) < 48)
        {
            ReproductiveOrgans = "Sterile";
        }                                                              //if (GChance >= 80 && GChance < 85) { UnitGender = "Female"; } if (GChance >= 85 && GChance < 90) { UnitGender = "Female"; }

        Unit_Image       = UnitImageContainer.transform.GetChild(0).gameObject.GetComponent("Image") as Image;
        Private_Image    = UnitImageContainer.transform.GetChild(1).gameObject.GetComponent("Image") as Image;
        Officer_Image    = UnitImageContainer.transform.GetChild(2).gameObject.GetComponent("Image") as Image;
        General_Image    = UnitImageContainer.transform.GetChild(3).gameObject.GetComponent("Image") as Image;
        UnitTypeDropdown = UnitImageContainer.transform.GetChild(4).gameObject.GetComponent("Dropdown") as Dropdown;

        UnitNameInput = UnitNameLable.transform.GetChild(0).gameObject.GetComponent("TMP_InputField") as TMP_InputField;

        TankSlider   = TrainingContainer.transform.GetChild(1).gameObject.GetComponent("Scrollbar") as Scrollbar;
        RangerSlider = TrainingContainer.transform.GetChild(3).gameObject.GetComponent("Scrollbar") as Scrollbar;
        MentalSlider = TrainingContainer.transform.GetChild(5).gameObject.GetComponent("Scrollbar") as Scrollbar;

        LifeDropdown     = BackStoryDropdownsText.transform.GetChild(0).gameObject.GetComponent("TMP_Dropdown") as TMP_Dropdown;
        TrainingDropdown = BackStoryDropdownsText.transform.GetChild(1).gameObject.GetComponent("TMP_Dropdown") as TMP_Dropdown;

        //StatisticsPannel
        HealthStatText    = StatisticsPannel.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        LifeSpanText      = HealthStatText.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        DietGradeText     = HealthStatText.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;
        SleepGradeText    = HealthStatText.transform.GetChild(2).gameObject.GetComponent("TMP_Text") as TMP_Text;
        IllnessResistText = HealthStatText.transform.GetChild(3).gameObject.GetComponent("TMP_Text") as TMP_Text;
        IllnessesText     = HealthStatText.transform.GetChild(4).gameObject.GetComponent("TMP_Text") as TMP_Text;
        InjuriesText      = HealthStatText.transform.GetChild(5).gameObject.GetComponent("TMP_Text") as TMP_Text;

        MentalStatText  = StatisticsPannel.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;
        EngineeringText = MentalStatText.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        MedicalText     = MentalStatText.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;
        ScienceText     = MentalStatText.transform.GetChild(2).gameObject.GetComponent("TMP_Text") as TMP_Text;
        StratagyText    = MentalStatText.transform.GetChild(3).gameObject.GetComponent("TMP_Text") as TMP_Text;

        StrengthText      = StatisticsPannel.transform.GetChild(2).gameObject.GetComponent("TMP_Text") as TMP_Text;
        SwordsmanText     = StrengthText.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        BowmanText        = StrengthText.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;
        CarryCapacityText = StrengthText.transform.GetChild(2).gameObject.GetComponent("TMP_Text") as TMP_Text;

        PerseptionStatText = StatisticsPannel.transform.GetChild(3).gameObject.GetComponent("TMP_Text") as TMP_Text;
        SightDistanceText  = PerseptionStatText.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        SightAccuracyText  = PerseptionStatText.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;

        StaminaStatText  = StatisticsPannel.transform.GetChild(4).gameObject.GetComponent("TMP_Text") as TMP_Text;
        SpeedRangeText   = StaminaStatText.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        SustainedRunText = StaminaStatText.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;

        MoralStatText    = StatisticsPannel.transform.GetChild(5).gameObject.GetComponent("TMP_Text") as TMP_Text;
        MoralCapText     = MoralStatText.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        TraumaResistText = MoralStatText.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;
        StressResistText = MoralStatText.transform.GetChild(2).gameObject.GetComponent("TMP_Text") as TMP_Text;

        LearningText   = StatisticsPannel.transform.GetChild(6).gameObject.GetComponent("TMP_Text") as TMP_Text;
        LearnSpeedText = LearningText.transform.GetChild(0).gameObject.GetComponent("TMP_Text") as TMP_Text;
        RetainText     = LearningText.transform.GetChild(1).gameObject.GetComponent("TMP_Text") as TMP_Text;

        ResetCancelFinishPannel = StatisticsPannel.transform.GetChild(8).gameObject;
        FinishButton            = ResetCancelFinishPannel.transform.GetChild(0).gameObject.GetComponent("Button") as Button;
        CancelButton            = ResetCancelFinishPannel.transform.GetChild(1).gameObject.GetComponent("Button") as Button;
        ResetButton             = ResetCancelFinishPannel.transform.GetChild(2).gameObject.GetComponent("Button") as Button;
        CostText      = ResetCancelFinishPannel.transform.GetChild(3).gameObject.GetComponent("TMP_Text") as TMP_Text;
        AvailibleText = ResetCancelFinishPannel.transform.GetChild(4).gameObject.GetComponent("TMP_Text") as TMP_Text;

        //RectTransform BlankRect = new RectTransform();
        //Update_Unit_Creator_UI(BlankRect);
        Update_Stats();
    }
Пример #46
0
        private void Start()
        {
            LayoutGroup = GetComponentInChildren<HorizontalLayoutGroup>();
            UiScripts = GameObject.FindObjectOfType<IngameFunctions>();
            //Achievements = GameObject.FindObjectOfType<AchievementsRecord>();
            Ads = GameObject.FindObjectOfType<FullScreenAds>();
            Dialogs = GameObject.FindObjectOfType<DialogBox>();
            scrollBar = gameObject.GetComponentInChildren<Scrollbar>();

            TotalSize = BasicPalette.Count + 1; //1 for rainbow

            PaletteList = new List<Image>(TotalSize);
            WasColorUsed = new List<bool>(BasicPalette.Count);

            AddColors();

            OnSelectNewColor(1);
        }
Пример #47
0
    public int DataGridType = -1; //类型。用来区分使用同一类型Data的不同滚动列表


    /// <summary>
    /// 初始化datagrid信息
    /// </summary>
    /// <param name="itemPath">item的prefab位置</param>
    /// <param name="itemScriptName">item上的script的名字</param>
    /// <param name="startPostion">content</param>
    /// <param name="scrollRect">scrollrect,固定数量不可拖动不用去设置scroll</param>
    /// <param name="direction">设置方向 none设置不可拖动</param>
    /// <param name="isNeedSetMaxItemNum">使用wrapContent策略</param>
    public void InitDataGrid(string itemPath, string itemScriptName, GameObject content, ScrollRect scrollRect = null, Direction direction = Direction.Horizontal, bool isNeedSetMaxItemNum = false)
    {
        _itemScript          = Type.GetType(itemScriptName);
        _prefabPath          = itemPath;
        _direction           = direction;
        _scrollRect          = scrollRect;
        _content             = content;
        _contTransform       = _content.GetRectTransform();
        _isNeedSetMaxItemNum = isNeedSetMaxItemNum;
        _gridGroup           = _content.GetComponent <GridLayoutGroup>();
        if (_scrollRect != null)
        {
            _uiCenterOnChild = _scrollRect.GetComponent <UICenterOnChild>();
            switch (direction)
            {
            case Direction.Horizontal:
                _scrollRect.horizontal = true;
                _scrollRect.vertical   = false;
                _bar = _scrollRect.horizontalScrollbar;
                break;

            case Direction.Vertical:
                _scrollRect.horizontal = false;
                _scrollRect.vertical   = true;
                _bar = _scrollRect.verticalScrollbar;
                break;

            case Direction.none:
                _scrollRect.horizontal = false;
                _scrollRect.vertical   = false;
                break;
            }
            RectTransform viewRect;
            if ((UnityEngine.Object)_scrollRect.viewport == (UnityEngine.Object)null)
            {
                viewRect = _scrollRect.gameObject.GetRectTransform();
            }
            else
            {
                viewRect = _scrollRect.viewport;
            }
            if (_gridGroup.constraint == GridLayoutGroup.Constraint.FixedColumnCount)
            {
                int num = Mathf.FloorToInt((viewRect.rect.height - _gridGroup.padding.vertical + _gridGroup.spacing.y + 1.0f / 1000.0f) / (_gridGroup.cellSize.y + _gridGroup.spacing.y));
                _fullNum = num * _gridGroup.constraintCount;
            }
            else if (_gridGroup.constraint == GridLayoutGroup.Constraint.FixedRowCount)
            {
                int num = Mathf.FloorToInt((viewRect.rect.width - _gridGroup.padding.horizontal + _gridGroup.spacing.x + 1.0f / 1000.0f) / (_gridGroup.cellSize.x + _gridGroup.spacing.x));
                _fullNum = num * _gridGroup.constraintCount;
            }
            else
            {
                int num1 = Mathf.FloorToInt((viewRect.rect.height - _gridGroup.padding.vertical + _gridGroup.spacing.y + 1.0f / 1000.0f) / (_gridGroup.cellSize.y + _gridGroup.spacing.y));
                int num2 = Mathf.FloorToInt((viewRect.rect.width - _gridGroup.padding.horizontal + _gridGroup.spacing.x + 1.0f / 1000.0f) / (_gridGroup.cellSize.x + _gridGroup.spacing.x));
                _fullNum = num1 * num2;
            }
        }
        else
        {
            _fullNum = -1;
        }
    }
Пример #48
0
 void SetScrollbarUI(Scrollbar scroll)
 {
     scrollbarUI.scrollbar  = scroll;
     scrollbarUI.background = GetComponent <Image>();
     scrollbarUI.handle     = scroll.handleRect.GetComponent <Image>();
 }
Пример #49
0
    void Start()
    {
        if (txtDescricao == null)
        {
            txtDescricao = GameObject.
                Find("_txtDescricaoEmpreendimentos").
                    GetComponent<Text>();
        }
        if (btComprar == null)
        {
            btComprar = GameObject.
                Find("_btComprarEmpreendimento").
                    GetComponent<Button>();
            txtComprar = btComprar.
                GetComponentInChildren<Text>();
        }
        if (posicaoLocalDinheiro == null)
        {
            posicaoLocalDinheiro =
                GameObject.Find("pnlMoeda").transform;
        }
        if (scrollBar == null)
        {
            scrollBar = GameObject.Find("BarraDescricao").GetComponent<Scrollbar>();
        }

        textoLocal = GetComponentInChildren<Text>();
        AjeitarTexto();
        AjeitarBotaoComprar();
    }
Пример #50
0
    private void Init()
    {
        if (tempCell == null)
        {
            Debug.LogError("tempCell不能为空!");
            return;
        }
        this.inited = true;
        this.tempCell.SetActive(false);

        //创建ScrollRect下的viewpoint和content节点。
        this.scrollRect                   = gameObject.AddComponent <ScrollRect>();
        this.scrollRect.vertical          = true;
        this.scrollRect.horizontal        = false;
        this.scrollRect.verticalScrollbar = verticalScrollbar;
        this.scrollRect.scrollSensitivity = 30;
        GameObject viewport = new GameObject("viewport", typeof(RectTransform));

        viewport.transform.SetParent(transform);
        this.scrollRect.viewport = viewport.GetComponent <RectTransform>();
        GameObject content = new GameObject("content", typeof(RectTransform));

        content.transform.SetParent(viewport.transform);
        this.scrollRect.content = content.GetComponent <RectTransform>();

        //设置视野viewport的宽高和根节点一致。
        this.scrollRect.viewport.localScale = Vector3.one;
        this.scrollRect.viewport.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 0);
        this.scrollRect.viewport.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0);
        this.scrollRect.viewport.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0, 0);
        this.scrollRect.viewport.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0, 0);
        this.scrollRect.viewport.anchorMin          = Vector2.zero;
        this.scrollRect.viewport.anchorMax          = Vector2.one;
        this.scrollRect.viewport.anchoredPosition3D = Vector3.zero;
        //设置viewpoint的mask。
        this.scrollRect.viewport.gameObject.AddComponent <Mask>().showMaskGraphic = false;
        Image image    = this.scrollRect.viewport.gameObject.AddComponent <Image>();
        Rect  viewRect = this.scrollRect.viewport.rect;

        image.sprite = Sprite.Create(new Texture2D(1, 1), new Rect(Vector2.zero, Vector2.one), Vector2.zero);

        //获取模板cell的宽高。
        Rect tempRect = tempCell.GetComponent <RectTransform>().rect;

        this.cellWidth  = tempRect.width;
        this.cellHeight = tempRect.height;

        //设置viewpoint约束范围内的cell的GameObject的行列数。
        this.col = (int)(this.scrollRect.viewport.rect.width / this.cellWidth);
        this.col = Mathf.Max(1, this.col);
        this.row = Mathf.CeilToInt(this.scrollRect.viewport.rect.height / this.cellHeight);

        //初始化content。
        this.scrollRect.content.localScale = Vector3.one;
        this.scrollRect.content.offsetMax  = new Vector2(0, 0);
        this.scrollRect.content.offsetMin  = new Vector2(0, 0);
        this.scrollRect.content.anchorMin  = Vector2.zero;
        this.scrollRect.content.anchorMax  = Vector2.one;
        this.scrollRect.onValueChanged.AddListener(this.OnValueChange);
        this.CreateCells();
    }
Пример #51
0
    // Use this for initialization
    public void Start()
    {
        FeatParentButtonDefault = FeatParentButton;
        FeatParentRectDefault = FeatParentButtonDefault.GetComponent<RectTransform>();
        ParentRectHeight = FeatParentRectDefault.rect.height;
        ParentRect = FeatParentRectDefault;
        ScrollBar = FeatScrollView.gameObject.transform.GetChild(1).GetComponent<Scrollbar>();

        XML_Loader xmlLoader = ScriptableObject.CreateInstance<XML_Loader> ();//load xml
        List<string> XmlResult  = new List<string> ();
        if (Settings_Screen.is_online == true)
        {
            XmlResult = xmlLoader.LoadInnerXml("https://raw.githubusercontent.com/theslimreaper/DnD/master/XML%20Files/Character Features/feats.xml", "feat");
        }
        else
        {
            XmlResult = xmlLoader.LoadInnerXmlFromFile("..\\XML Files/Character Features/feats.xml", "feat");
        }

        foreach(var item in XmlResult)//loop through the spell list and sort the spells based off of spell level (if character class is correct)
        {
            var idLine = item.Substring(item.IndexOf("<id>") + 4,(item.IndexOf("</id>")-item.IndexOf("<id>")) - 4);
            bool cont = true;

            List<string> IDList = new List<string> ();
            IDList = Character_Info.characterFeats;
            foreach(var id in IDList)
            {
                if (idLine.Contains (id))
                {
                    cont = false;
                }
            }
            if (cont == true)
            {
                Feat_Class FeatsSet = new Feat_Class();
                FeatsSet.featName = item.Substring((item.IndexOf("<name>") + 6),((item.IndexOf("</name>")-item.IndexOf("<name>")) - 6));
                FeatsSet.featPrereq = item.Substring(item.IndexOf("<prerequisite>") + 14,(item.IndexOf("</prerequisite>")-item.IndexOf("<prerequisite>")) - 14);
                if (item.IndexOf("<modifier>") != -1)
                {
                    FeatsSet.featModifier = item.Substring(item.IndexOf("<modifier>") + 10,(item.IndexOf("</modifier>")-item.IndexOf("<modifier>")) - 10);
                }
                FeatsSet.featID = item.Substring(item.IndexOf("<id>") + 4,(item.IndexOf("</id>")-item.IndexOf("<id>")) - 4);

                FeatsSet.featDescription = item.Substring(item.IndexOf("<text>") + 6,(item.IndexOf("</text>")-item.IndexOf("<text>")) - 6);
                FeatsList.Add(FeatsSet);
            }
        }

        MakeButtons();
    }
Пример #52
0
 private void Awake()
 {
     sb       = GetComponent <Scrollbar>();
     sb.value = 1f;
 }
Пример #53
0
        private static void AddBinder(MenuCommand command)
        {
            Scrollbar context = (Scrollbar)command.context;

            context.GetOrAddComponent <ScrollbarBinder>();
        }
Пример #54
0
        void Awake()
        {
            if (autoHideTime == 0f)
            {
                autoHideTime = 1f;
            }

            _Scrollbar             = GetComponent <Scrollbar>();
            _InitialScale          = _Scrollbar.transform.localScale;
            _LastValue             = _Scrollbar.value;
            _TimeOnLastValueChange = Time;
            _HorizontalScrollBar   = _Scrollbar.direction == Scrollbar.Direction.LeftToRight || _Scrollbar.direction == Scrollbar.Direction.RightToLeft;

            if (externalScrollRectProxy == null)
            {
                if (!scrollRect)
                {
                    scrollRect = GetComponentInParent <ScrollRect>();
                    //if (!scrollRect)
                    //    throw new UnityException("Please provide a ScrollRect for ScrollbarFixer8 to work");
                }
            }

            if (scrollRect)
            {
                _ScrollViewRT = scrollRect.transform as RectTransform;
                if (_HorizontalScrollBar)
                {
                    if (!scrollRect.horizontal)
                    {
                        throw new UnityException("ScrollbarFixer8: Can't use horizontal scrollbar with non-horizontal scrollRect");
                    }

                    if (scrollRect.horizontalScrollbar)
                    {
                        Debug.Log("ScrollbarFixer8: setting scrollRect.horizontalScrollbar to null (the whole point of using ScrollbarFixer8 is to NOT have any scrollbars assigned)");
                        scrollRect.horizontalScrollbar = null;
                    }
                    if (scrollRect.verticalScrollbar == _Scrollbar)
                    {
                        Debug.Log("ScrollbarFixer8: Can't use the same scrollbar for both vert and hor");
                        scrollRect.verticalScrollbar = null;
                    }
                }
                else
                {
                    if (!scrollRect.vertical)
                    {
                        throw new UnityException("Can't use vertical scrollbar with non-vertical scrollRect");
                    }

                    if (scrollRect.verticalScrollbar)
                    {
                        Debug.Log("ScrollbarFixer8: setting scrollRect.verticalScrollbar to null (the whole point of using ScrollbarFixer8 is to NOT have any scrollbars assigned)");
                        scrollRect.verticalScrollbar = null;
                    }
                    if (scrollRect.horizontalScrollbar == _Scrollbar)
                    {
                        Debug.Log("ScrollbarFixer8: Can't use the same scrollbar for both vert and hor");
                        scrollRect.horizontalScrollbar = null;
                    }
                }
            }
            else
            {
            }

            if (scrollRect)
            {
                scrollRect.onValueChanged.AddListener(ScrollRect_OnValueChangedCalled);

                // May be null
                externalScrollRectProxy = scrollRect.GetComponent(typeof(IScrollRectProxy)) as IScrollRectProxy;
            }
            else
            {
                if (externalScrollRectProxy == null)
                {
                    // Start with directly with the parent when searching for IScrollRectProxy, as the scrollbar itself is a IScrollRectProxy and needs to be avoided;
                    externalScrollRectProxy = transform.parent.GetComponentInParent(typeof(IScrollRectProxy)) as IScrollRectProxy;
                    if (externalScrollRectProxy == null)
                    {
                        // Try starting from the viewport, as the scrollbar might not be a child of the target ScrollView
                        if (viewport)
                        {
                            externalScrollRectProxy = viewport.GetComponentInParent(typeof(IScrollRectProxy)) as IScrollRectProxy;
                        }

                        if (externalScrollRectProxy == null)
                        {
                            if (enabled)
                            {
                                Debug.Log(GetType().Name + ": no scrollRect provided and found no " + typeof(IScrollRectProxy).Name + " component among ancestors. Disabling...");
                                enabled = false;
                            }
                            return;
                        }
                    }
                }

                _ScrollViewRT = externalScrollRectProxy.gameObject.transform as RectTransform;
            }

            if (!viewport)
            {
                viewport = _ScrollViewRT;
            }

            if (autoHide)
            {
                UpdateStartingValuesForAutoHideEffect();
            }
        }
    // Use this for initialization
    void Start()
    {
        p1 = GameObject.Find ("A1").GetComponent<Scrollbar>();
        p2 = GameObject.Find ("A2").GetComponent<Scrollbar>();
        p3 = GameObject.Find ("A3").GetComponent<Scrollbar>();
        p4 = GameObject.Find ("A4").GetComponent<Scrollbar>();
        MainPower = GameObject.Find ("Main").GetComponent<Scrollbar>();
        Kp = GameObject.Find ("Kp").GetComponent<Scrollbar>();

        StartBtn = GameObject.Find ("StartBtn").GetComponent<Button>();
        StartBtnText = StartBtn.GetComponentInChildren<Text>();

        jc=new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        jo=jc.GetStatic<AndroidJavaObject>("currentActivity");
    }
    IEnumerator ApplyScrollPosition(Scrollbar sr, float verticalPos)
    {
        yield return(new WaitForEndOfFrame());

        scrollbar.value = verticalPos;
    }
Пример #57
0
	// Use this for initialization
	void Start () {
		sb =GetComponent<Scrollbar>();
	}
Пример #58
0
        /// <summary>
        /// Initialize GUI component.
        /// </summary>
        private void InitGUIComponent()
        {
            switch (mGUIType)
            {
            case JCS_GUIType.NONE:
                JCS_Debug.LogError("Setting with no meaning...");
                return;

            case JCS_GUIType.TOGGLE:
            {
                this.mToggle = this.GetComponent <Toggle>();
                if (mToggle == null)
                {
                    JCS_Debug.LogError("Toggle with no corrosdoing component...");
                    return;
                }
            }
            break;

            case JCS_GUIType.SLIDER:
            {
                this.mSlider = this.GetComponent <Slider>();
                if (mSlider == null)
                {
                    JCS_Debug.LogError("Slider with no corrosdoing component...");
                    return;
                }
                // assign value;
                this.mSlider.value = mSettingValue;
            }
            break;

            case JCS_GUIType.SCROLL_BAR:
            {
                this.mScrollbar = this.GetComponent <Scrollbar>();
                if (mScrollbar == null)
                {
                    JCS_Debug.LogError("Scrollbar with no corrosdoing component...");
                    return;
                }
            }
            break;

            case JCS_GUIType.DROP_DOWN:
            {
                this.mDropdown = this.GetComponent <Dropdown>();
                if (mDropdown == null)
                {
                    JCS_Debug.LogError("Dropdown with no corrosdoing component...");
                    return;
                }
            }
            break;

            case JCS_GUIType.INPUT_FIELD:
            {
                this.mInputField = this.GetComponent <InputField>();
                if (mInputField == null)
                {
                    JCS_Debug.LogError("InputField with no corrosdoing component...");
                    return;
                }
            }
            break;
            }
        }
Пример #59
0
 void Start()
 {
     m_Scrollbar = GameObject.Find("SongProgressBar").GetComponent <Scrollbar>();
     //使用监听事件需要先持有组件的引用
     m_Scrollbar.onValueChanged.AddListener(OnValueChangedPrivate);
 }
        // Use this for initialization
        void Start()
        {
            if (gazeTimeForSelection == 0)
            {
                gazeTimeForSelection = 1;                               //defaults to 1
            }
            if (this.GetComponent <VRInteractiveItem> () != null)
            {
                m_InteractiveItem = this.GetComponent <VRInteractiveItem> ();
            }
            else
            {
                Debug.Log("Attaching VR Interactive Script to this GameObject, it's required");
                this.gameObject.AddComponent(typeof(VRInteractiveItem));
                m_InteractiveItem = this.GetComponent <VRInteractiveItem> ();
            }

            if (this.GetComponent <BoxCollider>() == null)
            {
                this.gameObject.AddComponent(typeof(BoxCollider));
                GetComponent <BoxCollider> ().size = new Vector3(this.GetComponent <RectTransform> ().rect.width, this.GetComponent <RectTransform> ().rect.height, 1);
                Debug.Log("Attaching Box collider to this GameObject, it's required");
            }

            if (this.GetComponent <Scrollbar> () != null)
            {
                vScale = this.GetComponent <Scrollbar> ();
            }
            else
            {
                Debug.Log("No Scrollbar component attached to this GameObject, it's required");
            }

            if (this.GetComponent <Scrollbar>().handleRect.gameObject != null)
            {
                sliderHandle = this.GetComponent <Scrollbar>().handleRect.gameObject;
            }
            else
            {
                Debug.Log("No child Handle (GameObject) attached to this GameObject, it's required");
            }

            if (Camera.main.gameObject.GetComponent <SelectionRadial>() != null)
            {
                m_SelectionRadial = Camera.main.gameObject.GetComponent <SelectionRadial>();
            }
            else
            {
                Debug.Log("No SelectionRadial Script attached to the VR Interactive Camera, it's required");
            }

            if (Camera.main.gameObject.GetComponent <SelectionRadial>() != null)
            {
                reticlePosition = Camera.main.gameObject.GetComponent <Reticle>().ReticleTransform;
            }
            else
            {
                Debug.Log("No Reticle Script attached to the VR Interactive Camera, it's required with it's references");
            }

            //sliderHandle.SetActive(false);
        }