Inheritance: UnityEngine.UI.MaskableGraphic, ICanvasRaycastFilter, ISerializationCallbackReceiver, ILayoutElement
Beispiel #1
0
    void Start()
    {
        arCam = FindObjectOfType <CameraDeviceBehaviour>();
        transitionBackground         = transform.parent.GetComponentInParent <RawImage>();
        transitionBackground.enabled = false;
        snapshooter = FindObjectOfType <SnapshotMaker>();

        // загрузка спрайтов для разных состояний кнопки
        const string rotateBackSpritePath = "buttons/rotate_back";

        rotateBackSprite = Resources.Load <Sprite>(rotateBackSpritePath);
        const string rotateFrontSpritePath = "buttons/rotate_front";

        rotateFrontSprite = Resources.Load <Sprite>(rotateFrontSpritePath);

        image  = GetComponent <UnityEngine.UI.Image>();
        toggle = GetComponent <Toggle>();
        toggle.onValueChanged.AddListener(delegate {
            // смена спрайта
            image.sprite = toggle.isOn ? rotateBackSprite : rotateFrontSprite;
            // выключение ui на время переключения камеры
            SetUiActive(false);
            // показ заглушки на время переключения камеры
            snapshooter.ScreenTexMade += OnCreenshotMade;
            snapshooter.RefreshScreenshotRenderTex();
            snapshooter.Screenshoot(); // шаг 1: скриним экран, ставим на заглушку
        });
    }
Beispiel #2
0
 void Start()
 {
     _xform  = GetComponent <RectTransform>();
     _parent = (RectTransform)_xform.parent;
     _panel  = GetComponent <UI.Image>();
     _label  = GetComponentInChildren <UI.Text>();
 }
Beispiel #3
0
        private void Start()
        {
            _gcVision = GCVision.Instance;
            _gcVision.AnnotateSuccessEvent += AnnotateSuccessEventHandler;
            _gcVision.AnnotateFailedEvent  += AnnotateFailedEventHandler;

            _fileManager = _gcVision.ServiceLocator.Get <IFileManager>();


            _workingState = transform.Find("Canvas/Image_RecordState").GetComponent <UnityEngine.UI.Image>();

            _imageUrlInputField = transform.Find("Canvas/InputField_Url").GetComponent <InputField>();

            _selectedImageText = transform.Find("Canvas/Text_ImageName").GetComponent <Text>();

            _annotateButton    = transform.Find("Canvas/Button_Annotate").GetComponent <Button>();
            _chooseImageButton = transform.Find("Canvas/Button_ChooseImage").GetComponent <Button>();

            _parentOfHeadersGroup = transform.Find("Canvas/Panel_Content/Group_Header");
            _parentOfContentGroup = transform.Find("Canvas/Panel_Content/Group_Content/Group");

            _annotateButton.onClick.AddListener(AnnotateButtonOnClickHandler);
            _chooseImageButton.onClick.AddListener(ChooseImageButtonOnClickHandler);

            _selectedImageData      = string.Empty;
            _selectedImageText.text = "No Image selected.";
            _workingState.color     = UnityEngine.Color.green;
        }
 void Awake()
 {
     ToggleGameOverPanel(false);
     recognitionBoard = GetComponent<RecognitionBoard>();
     RecognitionBoard.GestureRecognized += OnGestureRecognized;
     indicatorImage = roundTimeIndicator.GetComponentInChildren<Image>();
 }
Beispiel #5
0
 /// <summary>
 /// It's pretty simple here
 /// When we enable, we register our button in the input system
 /// </summary>
 private void OnEnable()
 {
     _virtualButton = _virtualButton ?? new VirtualButton(ButtonName);
     CnInputManager.RegisterVirtualButton(_virtualButton);
     img             = GetComponent <Image>();
     unpressedSprite = img.sprite;
 }
        /// <summary>
        /// Generic create sort button.
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="templateButtonName"></param>
        /// <param name="buttonText"></param>
        /// <param name="iconName"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="action"></param>
        public static SongSortButton CreateSortButton(RectTransform parent, Button buttonTemplate, Sprite iconSprite, Sprite borderSprite, string buttonText, float fontSize, float x, float y, float w, float h, SongSortMode sortMode, System.Action <SongSortMode> onClickEvent)
        {
            SongSortButton sortButton = new SongSortButton();
            Button         newButton  = UIBuilder.CreateUIButton(parent, buttonTemplate);

            newButton.interactable = true;
            (newButton.transform as RectTransform).anchoredPosition = new Vector2(x, y);
            (newButton.transform as RectTransform).sizeDelta        = new Vector2(w, h);

            UIBuilder.SetButtonText(newButton, buttonText);
            UIBuilder.SetButtonIconEnabled(newButton, false);
            UIBuilder.SetButtonIcon(newButton, iconSprite);
            UIBuilder.SetButtonTextSize(newButton, fontSize);

            Image stroke = newButton.GetComponentsInChildren <Image>().First(btn => btn.name == "Stroke");

            stroke.sprite = borderSprite;
            //stroke.rectTransform.localScale = new Vector2(0.9f, 0.9f);

            newButton.GetComponentsInChildren <HorizontalLayoutGroup>().First(btn => btn.name == "Content").padding = new RectOffset(2, 2, 2, 2);

            newButton.onClick.RemoveAllListeners();
            newButton.onClick.AddListener(delegate()
            {
                onClickEvent(sortMode);
            });

            sortButton.Button   = newButton;
            sortButton.SortMode = sortMode;

            return(sortButton);
        }
Beispiel #7
0
    void OnStageWin(object p1, object p2)
    {
        List <Item> items   = (List <Item>)p1;
        Transform   content = _winNode.GetRef("Content");

        content.DestroyChildren();
        foreach (Item item in items)
        {
            GameObject newNodeObj = Instantiate(_modelNode.GetNode("RewardItem").gameObject, content);

            UINode newNode = newNodeObj.GetComponent <UINode>();
            Image  bg      = newNode.GetRef("Bg").GetComponent <Image>();
            bg.sprite = GameResSys.Instance.GetFrame(item.Lv.Value);
            Image icon = newNode.GetRef("Icon").GetComponent <Image>();
            icon.sprite = GameResSys.Instance.GetItem(item.Icon);
            Text itemName = newNode.GetRef("Name").GetComponent <Text>();
            itemName.text = item.Name;
            if (item.Count.Value > 1)
            {
                itemName.text = item.Name + " * " + item.Count.Value;
            }
            Text itemDes = newNode.GetRef("Des").GetComponent <Text>();
            itemDes.text = item.Description;

            newNodeObj.SetActive(true);
        }

        _winNode.gameObject.SetActive(true);
    }
Beispiel #8
0
	// Use this for initialization
	void Start () {
		anim = GetComponent<Animator> ();
		BarVie = GameObject.Find("MainCamera").transform.FindChild("Canvas").FindChild("BarVie").GetComponent<Image>();
		SetColor (1);


	}
Beispiel #9
0
        /// <summary>Tweens an Image's alpha color to the given value.
        /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
        public static TweenerCore <Color, Color, ColorOptions> DOFade(this Image target, float endValue, float duration)
        {
            TweenerCore <Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);

            t.SetTarget(target);
            return(t);
        }
Beispiel #10
0
 // Use this for initialization
 void Start()
 {
     image = gameObject.GetComponent<UnityEngine.UI.Image>();
     index = 0;
     total = loadingSprites.Count;
     t = loopInterval;
 }
 void Start()
 {
     fadingIn = fadingOut = false;
     myImage = this.GetComponent<Image>();
     myColor = myImage.color;
     Invoke ("fadeIn", timeBeforeFadeIn);
 }
 // Use this for initialization
 public void Init(float CdTime)
 {
     m_CdTime = 0.0f;
     m_MaxCdTime = CdTime;
     m_CdImg = transform.FindChild("cdImg").GetComponent<Image>();
     m_CdText = transform.FindChild("cdTime").GetComponent<Text>();
 }
Beispiel #13
0
 // Use this for initialization
 void Awake()
 {
     m_Img = GetComponent<Image>();
     m_OriginSpr = m_Img.sprite;
     m_Type = DungonType.DT_WOLF;
     m_IsSelected = false;
 }
Beispiel #14
0
	void Start ()
	{
		// Set up and assign variables.
		occlusion_image = occlusion_panel.GetComponent<UnityEngine.UI.Image> ();
		sidebar_transform = this.gameObject.GetComponent<RectTransform> ();
		sidebar_height = sidebar_transform.offsetMax.y - sidebar_transform.offsetMin.y;
	}
Beispiel #15
0
        static void Postfix(LevelListTableCell __instance, TableCell.TransitionType transitionType)
        {
            try
            {
                if (!PluginConfig.enableSongIcons)
                {
                    return;
                }

                UnityEngine.UI.Image[] images = __instance.transform.GetComponentsInChildren <UnityEngine.UI.Image>(true);
                UnityEngine.UI.Image   icon   = null;

                if (images.Any(x => x.name == "ExtraIcon"))
                {
                    icon = images.First(x => x.name == "ExtraIcon");
                    if (icon.enabled)
                    {
                        if (__instance.selected)
                        {
                            icon.color = Color.black;
                        }
                        else
                        {
                            icon.color = Color.white;
                        }
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #16
0
    public static Image RetornarObjImageBattle(bool TwovsTwo, string QuienAtaca)
    {
        UnityEngine.UI.Image ImagenPersonaje = null;
        libreriaDeScrips     libreriaS       = GameObject.FindObjectOfType <libreriaDeScrips>();

        if (TwovsTwo == false)
        {
            //ataca de espalda
            if (QuienAtaca == "Player")
            {
                ImagenPersonaje = libreriaS.Batalla.GetComponent <animationScritpBatle>().ImagenEnemigo;
                libreriaS.Batalla.imagenePlayer.sprite = libreriaS.informacionCrewild.CrewillInstancia[libreriaS.Batalla.ActualSelNumPlayer].animaCrewildEspalda[2];
            }
            //ataca de frente
            else if (QuienAtaca == "Enemy")
            {
                //   animationBrawler.AddClip(this.animaBattle[1], "Attack");
                ImagenPersonaje = libreriaS.Batalla.GetComponent <animationScritpBatle>().imagenePlayer;
                libreriaS.Batalla.ImagenEnemigo.sprite = libreriaS.Batalla.EnemigosBatalla[libreriaS.Batalla.ActualSeNumEnemy].animaCrewildFrentre[2];
            }
        }

        else if (TwovsTwo == true)
        {
            // sin implementaciontodavia
        }
        return(ImagenPersonaje);
    }
        private void Awake()
        {
            characterRectTransform = GetComponent<RectTransform>();
            image = GetComponent<Image>();

            currentLookDirection = 0;
        }
Beispiel #18
0
    public static Image RetornarObjImageBattleInversa(bool TwovsTwo, string QuienAtaca)
    {
        UnityEngine.UI.Image ImagenPersonaje = null;
        libreriaDeScrips     libreriaS       = GameObject.FindObjectOfType <libreriaDeScrips>();

        if (TwovsTwo == false)
        {
            //ataca de espalda
            if (QuienAtaca == "Enemy")
            {
                ImagenPersonaje = libreriaS.Batalla.GetComponent <animationScritpBatle>().ImagenEnemigo;
            }
            //ataca de frente
            else if (QuienAtaca == "Player")
            {
                //   animationBrawler.AddClip(this.animaBattle[1], "Attack");
                ImagenPersonaje = libreriaS.Batalla.GetComponent <animationScritpBatle>().imagenePlayer;
            }
        }

        else if (TwovsTwo == true)
        {
            // sin implementaciontodavia
        }
        return(ImagenPersonaje);
    }
Beispiel #19
0
    /// <summary>
    /// 地图上的英雄node的实例化
    /// </summary>
    /// <param name="heroData"></param>
    /// <param name="setDragIcon"></param>
    /// <returns></returns>
    GameObject InsHeroNode(HeroData heroData, bool setDragIcon)
    {
        GameObject go        = Instantiate(_heroNodeModel);
        UINode     uiNode    = go.GetComponent <UINode>();
        Image      nodeImage = uiNode.GetRef("Image").GetComponent <Image>();

        nodeImage.sprite = GameResSys.Instance.GetCard(heroData.Icon);

        Button btn = uiNode.GetRef("Image").GetComponent <Button>();

        if (btn == null)
        {
            btn = uiNode.GetRef("Image").gameObject.AddComponent <Button>();
        }
        btn.onClick.AddListener(() => { OnHerNodeClicked(heroData.Id); });

        Dragable drag = uiNode.GetRef("Image").gameObject.AddComponent <Dragable>();

        drag.ActionId    = heroData.Id;
        drag.OnDragStart = OnDrag;
        drag.Canv        = _stageCanvas;
        if (setDragIcon)
        {
            drag.DragIcon = GameResSys.Instance.GetItem(heroData.FightIcon);
        }
        drag.HasTail       = true;
        drag.TailSprite    = GameResSys.Instance.GetMask(GameConstants.CommonDragTail);
        drag.TailColor     = heroData.TheColor;
        drag.TailWidth     = 20;
        drag.IsDisableGray = true;

        return(go);
    }
Beispiel #20
0
 public void Create(Image beatImage)
 {
     _beatImage = beatImage;
     Vector3 p = GetPosition();
     p.y = startPosition;
     UpdatePosition(p);
 }
Beispiel #21
0
    // Use this for initialization
    void Start()
    {
        textDisplay       = GetComponentInChildren <Text>();
        backgroundDisplay = GetComponent <Image>();
//		historyDisplay = GameObject.Find("History");
        historyText = GameObject.Find("History Text").GetComponent <Text>();
    }
Beispiel #22
0
 // Use this for initialization
 private void Start()
 {
     _normalColor = new Color(0.5f, 0.5f, 0.5f, 0.5f);
     _underwaterColor = new Color(0.22f, 0.45f, 0.77f, 0.5f);
     _controller = FindObjectOfType<FirstPersonController>();
     _breathBar = GameObject.FindGameObjectWithTag("BreathBar").GetComponent<Image>();
 }
Beispiel #23
0
 public static void Fade(Image element, float fadeTo, float fadeAfter, float timeToFade)
 {
     DOTween.Sequence()
         .AppendInterval(fadeAfter)
         .Append(element.DOFade(fadeTo, timeToFade)
         .SetEase(Ease.InOutExpo));
 }
Beispiel #24
0
 // Use this for initialization
 void Start()
 {
     if (Image == null)
     {
         Image = gameObject.GetComponent <Image>();
     }
 }
Beispiel #25
0
 void SetColor(Transform _transform, Color _color)
 {
     mText = _transform.GetComponent<Text> ();
     if (mText != null){
         mText.color = _color;
     }
     mLight = _transform.GetComponent<Light>();
     if (mLight != null){
         mLight.color = _color;
     }
     mImage = _transform.GetComponent<Image> ();
     if (mImage != null) {
         mImage.color = _color;
     }
     mSpriteRender = _transform.GetComponent<SpriteRenderer> ();
     if (mSpriteRender != null) {
         mSpriteRender.color = _color;
     }
     if (_transform.GetComponent<Renderer>() != null) {
         mMat = _transform.GetComponent<Renderer>().material;
         if (mMat != null) {
             mMat.color = _color;
         }
     }
     if (includeChilds) {
         for (int i = 0; i < _transform.childCount; ++i) {
             Transform child = _transform.GetChild(i);
             SetColor(child, _color);
         }
     }
 }
Beispiel #26
0
    void SetVuMarkInfoForCanvas(VuMarkBehaviour vumarkBehaviour)
    {
        Text canvasText = vumarkBehaviour.gameObject.GetComponentInChildren <Text>();

        UnityEngine.UI.Image canvasImage = vumarkBehaviour.gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2];

        Texture2D vumarkInstanceTexture = RetrieveStoredTextureForVuMarkTarget(vumarkBehaviour.VuMarkTarget);
        Rect      rect = new Rect(0, 0, vumarkInstanceTexture.width, vumarkInstanceTexture.height);

        string vuMarkId       = GetVuMarkId(vumarkBehaviour.VuMarkTarget);
        string vuMarkDesc     = GetVuMarkDataType(vumarkBehaviour.VuMarkTarget);
        string vuMarkDataType = GetNumericVuMarkDescription(vumarkBehaviour.VuMarkTarget);

        canvasText.text =
            "<color=yellow>VuMark Instance Id: </color>" +
            "\n" + vuMarkId + " - " + vuMarkDesc +
            "\n\n<color=yellow>VuMark Type: </color>" +
            "\n" + vuMarkDataType;

        if (vumarkInstanceTexture.width == 0 || vumarkInstanceTexture.height == 0)
        {
            canvasImage.sprite = null;
        }
        else
        {
            canvasImage.sprite = Sprite.Create(vumarkInstanceTexture, rect, new Vector2(0.5f, 0.5f));
        }
    }
Beispiel #27
0
 // Use this for initialization
 void Start()
 {
     _underWater = FindObjectOfType<UnderWater>();
     _healthBar = GameObject.FindGameObjectWithTag("HealthBar").GetComponent<Image>();
     _damageFlash = GameObject.FindGameObjectWithTag("DamageFlash").GetComponent<Image>();
     _currentHealth = _maxHealth;
 }
Beispiel #28
0
    public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
    {
        Panel_Info.SetActive(false);
        Image_Scanner.SetActive(true);

        if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
        {
            Debug.Log("1");

            Panel_Info.SetActive(true);
            Image_Scanner.SetActive(false);
            Image_Background        = Image_UI.GetComponent <UnityEngine.UI.Image> ();
            Image_Background.sprite = Image_Info;

            //Aqui cambio el texto que quiero que aparezca cuando le muestre el activador,
            Titulo.text      = "Hello World";
            Descripcion.text = "Esto es un simulacro, no corra";
        }
        else
        {
            Panel_Info.SetActive(false);
            Image_Scanner.SetActive(true);
            Titulo.text      = " ";
            Descripcion.text = " ";



            // Update is called once per frame
        }
    }
Beispiel #29
0
 private void Awake()
 {
     uiImage   = GetComponent <Image>();
     uiOutline = GetComponent <Outline>();
     Mathf.Clamp01(enabledAlpha);
     UpdateAlpha(0f);
 }
Beispiel #30
0
        void Start()
        {
            //We keep it in game to be able to disconnect/have info on server
            DontDestroyOnLoad (gameObject);

            panelImage = GetComponent<Image> ();
        }
Beispiel #31
0
        //Initializes the game for each level.
        public void InitGame()
        {
            Instantiate (canvas);
            mainCamera = GameObject.Find ("Main Camera 2");
            //set Level number
            levelNumber = GameObject.Find ("LevelNumber").GetComponent<Text> ();
            levelNumber.text = "Level "+ level;
            //player reference and lifeText setup
            playerRef = GameObject.Find ("Player");
            playerController = playerRef.GetComponent<PlayerController>();
            playerController.score = score;
            prePlayerLife = playerController.life;
            levelImage = GameObject.Find ("LevelImage");
            faderScreen = GameObject.Find ("FaderScreen");
            Color.TryParseHexString ("#870000E4", out redSplashColor);
            Color.TryParseHexString ("#001187E4", out blueSplashColor);
            screenSplash = faderScreen.GetComponent<Image> ();
            screenSplash.color = redSplashColor;
            levelImage.SetActive (false);
            faderScreen.SetActive (false);
            playerLifeText = GameObject.Find ("LifePlayer").GetComponent<Text>();
            playerScoreText = GameObject.Find ("ScorePlayer").GetComponent<Text>();
            //Call the SetupScene function of the BoardManager script, pass it current level number.
            boardScript.SetupScene(level);
            allBlocks = GameObject.Find ("Blocks");
            isGameOver=false;

            InitLights();
        }
Beispiel #32
0
 // Token: 0x06002375 RID: 9077 RVA: 0x0009AEBC File Offset: 0x000990BC
 private void Rebuild()
 {
     this.SetStripCount(this.leaderboardInfoList.Count);
     for (int i = 0; i < this.leaderboardInfoList.Count; i++)
     {
         LeaderboardController.LeaderboardInfo leaderboardInfo = this.leaderboardInfoList[i];
         int    num  = Mathf.FloorToInt(leaderboardInfo.timeInSeconds / 60f);
         float  num2 = leaderboardInfo.timeInSeconds - (float)(num * 60);
         string text = string.Format("{0:0}:{1:00.00}", num, num2);
         this.stripList[i].rankLabel.text            = leaderboardInfo.rank.ToString();
         this.stripList[i].usernameLabel.userSteamId = leaderboardInfo.userSteamID;
         this.stripList[i].timeLabel.text            = text;
         this.stripList[i].classIcon.texture         = SurvivorCatalog.GetSurvivorPortrait(leaderboardInfo.survivorIndex);
         this.stripList[i].isMeImage.enabled         = (leaderboardInfo.userSteamID == Client.Instance.SteamId);
         this.stripList[i].usernameLabel.Refresh();
     }
     if (this.animateImageAlpha)
     {
         UnityEngine.UI.Image[] array = new UnityEngine.UI.Image[this.stripList.Count];
         for (int j = 0; j < this.stripList.Count; j++)
         {
             array[this.stripList.Count - 1 - j] = this.stripList[j].GetComponent <UnityEngine.UI.Image>();
         }
         this.animateImageAlpha.ResetStopwatch();
         this.animateImageAlpha.images = array;
     }
 }
Beispiel #33
0
    public virtual void SendImageToServer(UnityEngine.UI.Image x)
    {
        if (socketConnection == null)
        {
            return;
        }
        try
        {
            // Get a stream object for writing.
            NetworkStream stream = socketConnection.GetStream();
            StreamWriter  writer = new StreamWriter(socketConnection.GetStream());
            writer.AutoFlush = true; //Either this, or you Flush manually every time you send something.

            //ImageConverter _imageConverter = new ImageConverter();
            //byte[] xByte = (byte[])_imageConverter.ConvertTo(x, typeof(byte[]));

            if (stream.CanWrite)
            {
                //stream.Write(xByte, 0, xByte.Length);
            }
        }
        catch (SocketException socketException)
        {
            Debug.Log("Socket exception: " + socketException);
        }
    }
Beispiel #34
0
        /// <summary>
        /// If there's an item in this slot, draws its icon inside.
        /// </summary>
        /// <param name="item">Item.</param>
        /// <param name="index">Index.</param>
        public virtual void DrawIcon(InventoryItem item, int index)
        {
            if (ParentInventoryDisplay != null)
            {
                if (!InventoryItem.IsNull(item))
                {
                    GameObject itemIcon = new GameObject("Icon", typeof(RectTransform));
                    itemIcon.transform.SetParent(this.transform);
                    UnityEngine.UI.Image itemIconImage = itemIcon.AddComponent <Image>();
                    itemIconImage.sprite = item.Icon;
                    RectTransform itemRectTransform = itemIcon.GetComponent <RectTransform>();
                    itemRectTransform.localPosition = Vector3.zero;
                    itemRectTransform.localScale    = Vector3.one;
                    GUIHelper.SetSize(itemRectTransform, ParentInventoryDisplay.IconSize);

                    // if there's more than one of this item in this slot, we draw the associated quantity
                    if (item.Quantity > 1)
                    {
                        GameObject textObject = new GameObject("Slot " + index + " Quantity", typeof(RectTransform));
                        textObject.transform.SetParent(this.transform);
                        Text textComponent = textObject.AddComponent <Text>();
                        textComponent.text      = item.Quantity.ToString();
                        textComponent.font      = ParentInventoryDisplay.QtyFont;
                        textComponent.fontSize  = ParentInventoryDisplay.QtyFontSize;
                        textComponent.color     = ParentInventoryDisplay.QtyColor;
                        textComponent.alignment = ParentInventoryDisplay.QtyAlignment;
                        RectTransform textObjectRectTransform = textObject.GetComponent <RectTransform>();
                        textObjectRectTransform.localPosition = Vector3.zero;
                        textObjectRectTransform.localScale    = Vector3.one;
                        GUIHelper.SetSize(textObjectRectTransform, (ParentInventoryDisplay.SlotSize - Vector2.one * ParentInventoryDisplay.QtyPadding));
                    }
                }
            }
        }
        //Handle the Down event
        protected virtual void HandleDown()
        {
            inventorySpt = GetComponent<VRInteractiveItem>().inventoryScript;
            selectionRadial = GetComponent<VRInteractiveItem>().radial;
            // User must press A to interact with the object, negates the case of user holding A previous to interaction
            if (Input.GetButtonDown("aButton") && inventorySpt.retrieveObjectFromInventory(inventorySpt.activeItem).name.Contains(gateItemName))
            {
                holding = true;
                selectionRadial.enabled = true;
                Debug.Log("Show down state");
                //m_Renderer.material = m_DownMaterial;
            }
            if (holding)
            {
                selectionRadial.fillAmount = timer / holdTime;
                timer += Time.deltaTime;
                if (timer >= holdTime || holdTime == 0)
                {
                    selectionRadial.enabled = false;
                    holdSuccess();
                }
            }

            //START HERE FOR RADIAL FADING
            if (!holding) {
                selectionRadial.fillAmount = 0;
                selectionRadial.enabled = false;
                timer = 0;
            }
        }
    public void Start()
    {
        _image = GetComponent <Image>();

        Texture2D tex = _image.sprite.texture as Texture2D;

        bool isInvalid = false;

        if (tex != null)
        {
            try
            {
                tex.GetPixels32();
            }
            catch (UnityException e)
            {
                Debug.LogError(e.Message);
                isInvalid = true;
            }
        }
        else
        {
            isInvalid = true;
        }

        if (isInvalid)
        {
            Debug.LogError("This script need an Image with a readbale Texture2D to work.");
        }
    }
Beispiel #37
0
        private void SetStat(Text text, Image icon, int statValue)
        {
            string statText = "";

            if (statValue > 0)
            {
                statText = "+" + statValue.ToString();
                SetColor(text, colorPositive);
                SetColor(icon, colorPositive);
            }
            else if (statValue < 0)
            {
                statText = statValue.ToString();
                SetColor(text, colorNegative);
                SetColor(icon, colorNegative);
            }
            else
            {
                statText = "0";

                SetColor(text, colorNeutral);
                SetColor(icon, colorNeutral);
            }

            SetText(text, statText);
        }
Beispiel #38
0
    // Use this for initialization
    void Start()
    {
        WebCamDevice[] devices     = WebCamTexture.devices;
        int            cameraCount = devices.Length;

        if (cameraCount == 0)
        {
            Image <Bgr, Byte> img = new Image <Bgr, byte>(640, 240);
            CvInvoke.PutText(img, String.Format("{0} camera found", devices.Length), new System.Drawing.Point(10, 60),
                             Emgu.CV.CvEnum.FontFace.HersheyDuplex,
                             1.0, new MCvScalar(0, 255, 0));
            Texture2D texture = TextureConvert.ImageToTexture2D(img, FlipType.Vertical);

            RenderTexture(texture);
            ResizeTexture(texture);
            //this.GetComponent<GUITexture>().texture = texture;
            //this.GetComponent<GUITexture>().pixelInset = new Rect(-img.Width/2, -img.Height/2, img.Width, img.Height);
        }
        else
        {
            webcamTexture = new WebCamTexture(devices[0].name);

            baseRotation = transform.rotation;
            webcamTexture.Play();
            //data = new Color32[webcamTexture.width * webcamTexture.height];
            CvInvoke.CheckLibraryLoaded();
        }
    }
Beispiel #39
0
    public void AddSpellList(string spellName, int cost, Sprite image)
    {
        Transform item = SpellListBox.Add();

        UnityEngine.UI.Text s = item.GetChild(0).GetComponent <UnityEngine.UI.Text>();
        s.text = spellName;

        UnityEngine.UI.Text c = item.GetChild(1).GetComponent <UnityEngine.UI.Text>();
        if (cost > 0)
        {
            c.text = cost.ToString();
        }
        else
        {
            c.text = "";
        }

        UnityEngine.UI.Image i = item.GetChild(2).GetComponent <UnityEngine.UI.Image>();
        i.sprite = image;
        i.name   = spellName;

        // Add the callback so we know we've been selected
        EventTrigger trigger = item.GetChild(2).GetComponent <EventTrigger>();

        EventTrigger.Entry entry = new EventTrigger.Entry();
        entry.eventID = EventTriggerType.PointerClick;
        entry.callback.AddListener((eventData) => { SelectSpell((PointerEventData)eventData); });
        trigger.triggers.Add(entry);
    }
		public void Start()
		{
			// Resource Manager Component
			_ResourceManager = GameObject.FindGameObjectWithTag("DataManager").GetComponent<ResourceControll.ResourceManager>();

			// Image Component
			_Icon = this.transform.FindChild("Icon").GetComponent<Image>();
			
			// Text Component
			_CountText = this.transform.FindChild("Count Text").GetComponent<Text>();

			// Text Component
			_DescribedText = this.transform.FindChild("Described").GetComponent<Text>();


			// SETTING
			_Icon.sprite = Resources.Load<Sprite>("Sprites/Icon/" + _Index.ToString());

			if(_Article > 0)
				_CountText.text = ": " + "+ " + _Article.ToString();
			else
				_CountText.text = ": " + _Article.ToString();

			_DescribedText.text = _Described;

			this.transform.localScale = new Vector3(3.0f, 3.0f, 3.0f);
		}
        //Handle the Down event
        protected virtual void HandleDown()
        {
            selectionRadial = GetComponent<VRInteractiveItem_Single>().radial;
            // User must press A to interact with the object, negates the case of user holding A previous to interaction
            if (Input.GetButtonDown("aButton"))
            {
                holding = true;
                selectionRadial.enabled = true;
                //m_Renderer.material = m_DownMaterial;
            }
            if (holding)
            {
                selectionRadial.fillAmount = timer / holdTime;
                timer += Time.deltaTime;
                if (timer >= holdTime || holdTime == 0)
                {
                    selectionRadial.enabled = false;
                    holdSuccess();
                }
            }

            //START HERE FOR RADIAL FADING
            if (!holding)
            {
                selectionRadial.fillAmount = 0;
                selectionRadial.enabled = false;
                timer = 0;
            }
        }
Beispiel #42
0
 protected override void Awake()
 {
     base.Awake();
     this.image   = GetComponent <UnityEngine.UI.Image>();
     Segements    = 10;
     BlurDistance = 1.5f;
 }
Beispiel #43
0
 void Start()
 {
     background = transform.GetChild (0);
     sprite = transform.GetChild (1).GetComponent<UnityEngine.UI.Image> ();
     inventory_ui = transform.parent.parent.parent.GetComponent<InventoryScript> ();
     data = null;
 }
Beispiel #44
0
	// Use this for initialization
	void Start () {
    spriteTable = new Dictionary<string, Sprite>();

    spriteTable.Add("OffenseItem", (Resources.Load("Sprites/Item/item_O", (typeof(Sprite))) as Sprite));
    spriteTable.Add("DefenseItem", (Resources.Load("Sprites/Item/item_D", (typeof(Sprite))) as Sprite));
    spriteTable.Add("SpeedItem", (Resources.Load("Sprites/Item/item_S", (typeof(Sprite))) as Sprite));
    spriteTable.Add("OffenseOffenseItem", (Resources.Load("Sprites/Item/item_OO", (typeof(Sprite))) as Sprite));
    spriteTable.Add("DefenseDefenseItem", (Resources.Load("Sprites/Item/item_DD", (typeof(Sprite))) as Sprite));
    spriteTable.Add("SpeedSpeedItem", (Resources.Load("Sprites/Item/item_SS", (typeof(Sprite))) as Sprite));
    spriteTable.Add("OffenseSpeedItem", (Resources.Load("Sprites/Item/item_OS", (typeof(Sprite))) as Sprite));
    spriteTable.Add("OffenseDefenseItem", (Resources.Load("Sprites/Item/item_OD", (typeof(Sprite))) as Sprite));
    spriteTable.Add("SpeedDefenseItem", (Resources.Load("Sprites/Item/item_SD", (typeof(Sprite))) as Sprite));
    emptySprite = Resources.Load("Sprites/Item/item_Empty", (typeof(Sprite))) as Sprite;
    spriteTable.Add("default", emptySprite);

    image = gameObject.GetComponent<UnityEngine.UI.Image>();
    maskImage = transform.parent.gameObject.GetComponent<UnityEngine.UI.Image>();
    image.sprite = emptySprite;

    if (Instances.ContainsKey(playerNum)){
      Instances[playerNum] = this;
    }else{
      Instances.Add(playerNum, this);
    }

    semiWhite.a = 0.5f;
    image.color = semiWhite;
    maskImage.color = semiWhite;
	}
Beispiel #45
0
        public IEnumerator NormalizedSize()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerStack
            UIContainerStack uiContainerStack =
                TestHelpers.SharedComponentCreate <UIContainerStack, UIContainerStack.Model>(scene,
                                                                                             CLASS_ID.UI_CONTAINER_STACK,
                                                                                             new UIContainerStack.Model
            {
                parentComponent = screenSpaceShape.id,
                width           = new UIValue(50, UIValue.Unit.PERCENT),
                height          = new UIValue(30, UIValue.Unit.PERCENT)
            });

            yield return(uiContainerStack.routine);

            UnityEngine.UI.Image image = uiContainerStack.childHookRectTransform.GetComponent <UnityEngine.UI.Image>();

            // Check updated properties are applied correctly
            Assert.AreEqual(screenSpaceShape.childHookRectTransform.rect.width * 0.5f,
                            uiContainerStack.childHookRectTransform.rect.width, 0.01f);
            Assert.AreEqual(screenSpaceShape.childHookRectTransform.rect.height * 0.3f,
                            uiContainerStack.childHookRectTransform.rect.height, 0.01f);

            screenSpaceShape.Dispose();
            yield return(null);
        }
        void Update()
        {
            if (!thisImage)
            {
                thisImage = gameObject.GetComponent<Image>();
            }

            if (!scaler)
            {
                scaler = gameObject.GetComponentInParent<Canvas>().GetComponent<MaterialUIScaler>();
            }
            else
            {
                if (scaleFactor != scaler.scaleFactor)
                {
                    scaleFactor = scaler.scaleFactor;

                    if (scaleFactor > 2f && sprite4x)
                        thisImage.sprite = sprite4x;
                    else if (scaleFactor > 1f && sprite2x)
                        thisImage.sprite = sprite2x;
                    else
                        thisImage.sprite = sprite1x;
                }
            }
        }
Beispiel #47
0
    Text jetext;                      // Reference to the Text component.

    void Awake()
    {
        // Set up the reference.
        //     allthefunctions = GameObject.FindGameObjectWithTag("Game");
        jetext      = GetComponent <Text>();
        progressbar = GameObject.Find("progressbarimage").GetComponent <Image>();
    }
    public void friendsRightArrow()
    {
        /*
         * La imagen 2 pasa a la imagen 3
         * La imagen 3 pasa a la imagen 1
         * La imagen 1 pasa a la imagen 2
         *
         */
        UnityEngine.UI.Image image1    = this.transform.Find("Canvas/0").GetComponent <UnityEngine.UI.Image>();
        UnityEngine.UI.Image image2    = this.transform.Find("Canvas/1").GetComponent <UnityEngine.UI.Image>();
        UnityEngine.UI.Image image3    = this.transform.Find("Canvas/2").GetComponent <UnityEngine.UI.Image>();
        UnityEngine.UI.Image image2Aux = GameObject.Instantiate(this.transform.Find("Canvas/1").GetComponent <UnityEngine.UI.Image>());
        image2.sprite = image3.sprite;
        image3.sprite = image1.sprite;
        image1.sprite = image2Aux.sprite;
        Destroy(image2Aux);
        resetUserImages();
        for (int i = 0; i < this.top[1].usersUrl.Count; i++)
        {
            StartCoroutine(cargaImagen((string)this.top[1].usersUrl[i], this.transform.Find("Canvas/0/Friend" + (i + 1)).GetComponent <UnityEngine.UI.Image>()));
            double puntuacion = (Double)this.top[1].ratings[i];
            this.transform.Find("Canvas/0/Friend" + (i + 1) + "/Gauge").GetComponent <UnityEngine.UI.Image>().sprite = Resources.Load <Sprite>("Gauge/gauge" + Math.Round(puntuacion) * 10);
        }
        Dictionary <int, plan_info> newDictionary = new Dictionary <int, plan_info>();

        newDictionary.Add(0, this.top[1]);
        newDictionary.Add(1, this.top[2]);
        newDictionary.Add(2, this.top[0]);
        this.top = newDictionary;
    }
Beispiel #49
0
 void Awake()
 {
     m_ColorCycleImage = gameObject.transform.Find("ColorCycleImage").gameObject as GameObject;
     SetupColourCycle();
     m_ColorCycleImage.SetActive(false);
     m_GameManager     = GameObject.Find("GameManagerObject").GetComponent <GameManager>();
     m_Canvas          = gameObject.GetComponent <Canvas>();
     m_BackgroundImage = gameObject.GetComponent <UnityEngine.UI.Image>();
     m_JoinImage       = gameObject.transform.Find("JoinImage").gameObject as GameObject;
     m_JoinImage.SetActive(false);
     m_ReadyImage = gameObject.transform.Find("ReadyImage").gameObject as GameObject;
     m_ReadyImage.SetActive(false);
     m_LeaveImage = gameObject.transform.Find("LeaveImage").gameObject as GameObject;
     m_LeaveImage.SetActive(false);
     m_HatCycleImage = gameObject.transform.Find("HatCycleImage").gameObject as GameObject;
     m_HatCycleImage.SetActive(false);
     m_BackImage = gameObject.transform.Find("BackImage").gameObject as GameObject;
     m_BackImage.SetActive(false);
     m_Camera              = GameObject.Find("Main Camera").GetComponent <Camera>();
     m_Player_Name         = gameObject.transform.Find("Player_Name").GetComponent <Text>();
     m_Player_Name.enabled = false;
     Align_Agent();
     SetState(PanelState.Empty);
     CreateHatList();
 }
Beispiel #50
0
    // Start is called before the first frame update
    void Start()
    {
        textBoi = transform.Find("Text").GetComponent <UnityEngine.UI.Text>();



        EnemyOneImage   = transform.Find("EnemyOneImage").GetComponent <UnityEngine.UI.Image>();
        EnemyTwoImage   = transform.Find("EnemyTwoImage").GetComponent <UnityEngine.UI.Image>();
        EnemyThreeImage = transform.Find("EnemyThreeImage").GetComponent <UnityEngine.UI.Image>();
        MCImage         = transform.Find("MCimage").GetComponent <UnityEngine.UI.Image>();
        RatKingImage    = transform.Find("RatKingImage").GetComponent <UnityEngine.UI.Image>();
        NathanImage     = transform.Find("NathanImage").GetComponent <UnityEngine.UI.Image>();


        EnemyOneOb   = transform.Find("EnemyOne").GetComponent <UnityEngine.GameObject>();
        EnemyTwoOb   = transform.Find("EnemyTwo").GetComponent <UnityEngine.GameObject>();
        EnemyThreeOb = transform.Find("EnemyThree").GetComponent <UnityEngine.GameObject>();
        MCOb         = transform.Find("Mitch").GetComponent <UnityEngine.GameObject>();
        RatKingOb    = transform.Find("RatKingImage").GetComponent <UnityEngine.GameObject>();
        NathanOb     = transform.Find("NathanImage").GetComponent <UnityEngine.GameObject>();

        gatorBite = transform.Find("GatorBite0000").GetComponent <UnityEngine.GameObject>();


        gatorAttack = this.gameObject.GetComponent <AbilityHolder>().gatorAttack;
    }
Beispiel #51
0
 private void Awake()
 {
     border        = transform.Find("Border").GetComponent <UnityEngine.UI.Image>();
     background    = transform.Find("Background").GetComponent <UnityEngine.UI.Image>();
     IDtext        = transform.Find("IDText").GetComponent <TextMeshProUGUI>();
     remainingText = transform.Find("RemainingText").GetComponent <TextMeshProUGUI>();
 }
    // Use this for initialization
    void Start()
    {
        cursorImages = GameObject.FindGameObjectWithTag("CursorImages").GetComponent <CursorImageManager>();
        camera       = Camera.main;
        GameObject newUICursor = Instantiate(cursorPrefab);
        GameObject uiCanvas    = GameObject.Find("Canvas");

        //uiCanvas.GetComponent<Canvas>().worldCamera.
        newUICursor.transform.SetParent(uiCanvas.transform);
        cursorPosition            = newUICursor.GetComponent <RectTransform>();
        cursorPosition.localScale = Vector3.one;
        cursorImage        = newUICursor.GetComponent <Image>();
        cursorImage.sprite = cursorImages.GetNewCursorImage();
        cursorColor        = cursorImage.sprite.name;
        offset             = new Vector3(0.0f, 0.0f, 0.0f);
        RectTransform canvasSize = uiCanvas.GetComponent <RectTransform>();

        screenDimensions = new Vector2(canvasSize.rect.width, canvasSize.rect.height);
        SetupCursorColor(webSocket);

        GameObject plusOne = Instantiate(plusOnePrefab);

        plusOne.transform.SetParent(uiCanvas.transform);
        plusOnePosition            = plusOne.GetComponent <RectTransform>();;
        plusOnePosition.localScale = Vector3.one;
        plusOneText = plusOne.GetComponent <Text>();
        plusOneText.CrossFadeAlpha(0.0f, 0.0f, false);

        soundMaker = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundEffectScripts>();
    }
	public override void Awake()
	{
		base.Awake();
		
		_UiSpriteReceiver = GetComponent<UISprite>();
		_uiImage = GetComponent<UnityEngine.UI.Image>();
	}
Beispiel #54
0
    // Loads a sprite from Asset list
    public void loadPaperDocument(string docName)
    {
        //For the script to work, we need "docName" to be "InteractiblePaper_(sprite asset name)"
        //The asset needs to be into the Assets/Resources folder, or it will not work

        //Cut the beginning of the string to isolate (sprite asset name). Uses "_" as the separator
        string[] AssetName = docName.Split(new char[] { '_' });

        //Create an "Image" (UI element) from the void. Fill it with the correct sprite using the string created previously
        paperPieceObj = new GameObject();
        paperPiece = paperPieceObj.AddComponent<UnityEngine.UI.Image>();

        Debug.Log(AssetName[1]);

        paperPiece.sprite = Resources.Load(AssetName[1], typeof(Sprite)) as Sprite;

        //Set sprite as child of canvas interface
        paperPiece.transform.SetParent(thisCanvas.transform);

        //Read original sprite texture size
        Vector2 dimensionsImage = new Vector2(paperPiece.sprite.texture.width, paperPiece.sprite.texture.height);

        //Read format of the canvas
        RectTransform canvasRect = thisCanvas.GetComponent<RectTransform>();
        Vector2 dimensionsCanvas = new Vector2(canvasRect.rect.width, canvasRect.rect.height);

        //Center the sprite in the middle of the screen
        paperPiece.transform.position = new Vector3( dimensionsCanvas.x / 2, dimensionsCanvas.y / 2 );

        //Calculate the size we want to display it (biggest dimension = 80% of canvas)
        float resizeRatio;
        desiredImageSize = dimensionsImage;

        if (desiredImageSize.x >= desiredImageSize.y )
        {
            if (desiredImageSize.x > 0.95f*dimensionsCanvas.x)
            {
                resizeRatio = (0.95f * dimensionsCanvas.x) / desiredImageSize.x;
                desiredImageSize *= resizeRatio;
            }
        }
        else
        {
            if (desiredImageSize.y > 0.95f * dimensionsCanvas.y)
            {
                resizeRatio = (0.95f * dimensionsCanvas.y) / dimensionsImage.y;
                desiredImageSize *= resizeRatio;
            }
        }

        Debug.Log("Canvas Size :" + dimensionsCanvas + "- Desired Size :" + desiredImageSize );

        //Disable normal FPS Controls
        refPlayer.GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().enabled = false;
        refPlayer.transform.GetChild(0).GetComponent<DetectInteractibles>().enabled = false;

        //Launch the coroutine which will make the paper appear
        StartCoroutine("FadePaperSpriteIn");
    }
Beispiel #55
0
        // Use this for initialization
        void Start()
        {
            styling = FindObjectOfType<Styling>();
            image = GetComponent<Image>();

            if (styling != null){

                // Change Style by type
                switch (styleType)
                {
                case StyleTypes.button:

                    var button = GetComponent<Button>();
                    if (button != null) {
                        button.colors = styling.regularButtonCB;
                        button.targetGraphic.color = Color.white;
                    }

                    break;

                case StyleTypes.buttonText:

                    var text = GetComponent<Text>();
                    if (text != null){
                        text.color = styling.buttonText;
                    }

                    break;

                case StyleTypes.characterType:
                    image.color = styling.characterColor;

                    break;

                case StyleTypes.primaryWeaponType:
                    image.color = styling.primaryColor;
                    break;

                case StyleTypes.specialWeappnType:
                    image.color = styling.specialColor;
                    break;

                case StyleTypes.tossableType:
                    image.color = styling.tossableColor;
                    break;

                case StyleTypes.jetPackType:
                    image.color = styling.jetPackColor;
                    break;

                case StyleTypes.parent:
                    StartCoroutine (DelaySetParentStyling());

                    break;

                }

            }
        }
Beispiel #56
0
	void Awake()
	{
		image_ = transform.Find("Image").GetComponent<UnityEngine.UI.Image>();
		image_selected_ = transform.Find("ImageSelected").GetComponent<UnityEngine.UI.Image>();
		text_ = transform.Find("Text").GetComponent<UnityEngine.UI.Text>();
		setActive(true);
		setActive(false);
	}
		public override void OnEnter ()
		{
			component = gameObject.Value.GetComponent<Image>();
			DoSetImageProperties ();
			if (!everyFrame) {
				Finish ();
			}
		}
Beispiel #58
0
 /**
  * The default Constructor.
  */
 public UISlot()
 {
     uiButton = null;
     uiButtonID = 0;
     uiText = null;
     uiImage = null;
     sprite = null;
 }
Beispiel #59
0
        /**
         * Gets the attached Image component
         */
        public Image GetImage()
        {
            if(this.image == null) {
                this.image = this.gameObject.GetComponent<Image>();
            }

            return this.image;
        }
 void Awake()
 {
     this.background = transform.Find("Background").GetComponent<Image>();
     this.round = transform.Find("Handle Slide Area").Find("Handle").GetComponent<Image>();
     this.slider = GetComponent<Slider>();
     this.slider.onValueChanged.AddListener(delegate { OnValueChange(); });
     setUpColor();
 }