Search Unity

GUItexture is obsolete...? again...

Discussion in 'General Graphics' started by RuneShiStorm, Jan 18, 2018.

Thread Status:
Not open for further replies.
  1. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    I know this have been asked 100 times and I've seen some answers that seem to solve it.
    But, a beginner like myself cant wrap my head around it.
    I've seen an answer like "Make it equal something else"... But know what that means.

    The bald text has green error lines underneath it. The game works but its just annoying with the error message all the time :p

    Code (csharp):
    1.  
    2.  [SerializeField]
    3.     private Texture2D popupImage;
    4.     private GUITexture triangleTexture;
    5.     public GUITexture Triangle { get; private set; }
    6.     // Use this for initialization
    7.     void Start()
    8.     {
    9.         theTextBox = FindObjectOfType<TextExamineManager>();
    10.         triangleTexture = GameObject.Find("TriangleExamine").GetComponent<GUITexture>();
    11.     }
    12.  
    Thanks in advance if anyone can help :)
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    This feels like deja-vu :)

    The manual suggests that you use the new UI system.
     
    RuneShiStorm likes this.
  3. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    and how do I use that? Its not upgraded automatiacly?
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Nope, not automatically. Different things, but for the same 'task'.
    You want an image? Create -> UI -> Image
    in code, add "using UnityEngine.UI;"
    and change the GUITexture to 'Image'

    Images are scripts that use Sprites to display (stuff) :)
    Check it out =)
     
  5. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    ah, I see.. I think.
    So I have to change something inside "iUnity" as well?
    Changing in Code is not enough? I did that UI tutorial ages ago and I'm scared to go back and mess with it :p
    But i will give a shoot if thats the case :Z
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Ya, hope you get it working. Usually if something is deprecated and you want to keep doing what you were doing, it doesn't hurt to read up & use the replacement. The old stuff might be there for a while, but you know that it could go some time in the future.. :)
     
    RuneShiStorm likes this.
  7. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    I finally tackled this problem and its working.. Expect the Textrue2D...
    Any idea what it has to be replaced by?
     
  8. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Sorry, it's been a while since this thread. Is this for a UI image you're talking about?
    Texture2D isn't deprecated, but may not be what you need if you're looking for a UI image. For that, you can use a sprite?

    Let me know if that's what you're talking about .. :)
     
  9. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    Yup, its a Image... I made it work on 2 of the images. Like, "Press A to open" and "Press A to talk". But when I open a conversation-box, I want a head to pop up behind it (it changes depending on who you talk to...) Problem with Image is that I cant decide what layer it should appear on.. I managed to access this head through code "Textrue2D" up until this point, but when I change it to Image, the head wont appear on the scene at all, OR i have to make another UI-> Image and drop it into the NPC,s Inspector window.. When I used Texture2D I just had to drag an PNG image straight into the NPC's inspector and it worked. :/
    I Think Sprite is the way to go but no success... I will attempt again. Its a kind of complicated function I want...
    It looks like this... I will try again today thoguh,



    Its basically 2 scripts talking to each other...

    Script attached to NPC:
    Code (csharp):
    1.  
    2.  
    3.     [SerializeField]
    4.     private Texture2D popupImage;
    5.     private Image triangleTexture;
    6.     public Image Triangle { get; private set; }
    7.     // Use this for initialization
    8.     void Start()
    9.     {
    10.         theTextBox = FindObjectOfType<TextBoxManager>();
    11.         triangleTexture = GameObject.Find("TriangleTalk").GetComponent<Image>();
    12.     }
    13.     // Update is called once per frame
    14.     void Update()
    15.     {
    16.         if (waitForPress && Input.GetKeyDown(KeyCode.Joystick1Button3))
    17.         {
    18.             if (!theTextBox.isActive)
    19.             {
    20.                 if (!theTextBox.isBeingDisabled)
    21.                 {
    22.                     theTextBox.ReloadScript(theText);
    23.                     theTextBox.currentLine = startLine;
    24.                     theTextBox.endAtLine = endLine;
    25.                     theTextBox.theImage.texture = popupImage;
    26.                     theTextBox.EnableTextBox();
    27.                 }
    28.                 else
    29.                 {
    30.                     theTextBox.isBeingDisabled = false;
    31.                     theTextBox.theImage.texture = null;
    32.                 }
    33.             }
    34.             if (destroyWhenActivated)
    35.             {
    36.                 theTextBox.isBeingDisabled = false;
    37.                 Destroy(gameObject);
    38.             }
    39.         }
    40.     }
    41.  



    And another Script attacked to the TextBox Manager:

    Code (csharp):
    1.  
    2.  public GUITexture theImage;
    3.  
    4.  public void EnableTextBox()
    5.     {
    6.         textBox.SetActive(true);
    7.         isActive = true;
    8.         if(theImage.texture != null)
    9.         {
    10.             theImage.enabled = true;
    11.         }
    12.         Player.GetComponent<PlayerController>().enabled = false;
    13.         StartCoroutine(TextScroll(textLines[currentLine]));
    14.     }
    15.     public void DisableTextBox()
    16.     {
    17.         textBox.SetActive(false);
    18.         isActive = false;
    19.         theImage.enabled = false;
    20.         isBeingDisabled = true;
    21.         Player.GetComponent<PlayerController>().enabled = true;
    22.     }
    23.  

    A friend helped me with it so Im not 100% sure where to connection lies.. I think "theImage" is what makes the textBoxManager fetch the NPC's popup image (the face of the NPC)

    I will try Sprite again and see if I make it work..
    Thanks though!
     
  10. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Alright, well hope you can figure it out.

    Generally, from the sounds of what you wrote, you just need a reference to the image and then anytime you're talking to someone, apply the sprite of their head to that image's sprite (so you see it there in the corner).

    Feel free to write back if you get it working... or if you get stuck :)
     
  11. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    thanks!
    I will get back to this problem when I have time... I think I need a good 2-3 hours un-disturbed to make it work :p
     
  12. membantu

    membantu

    Joined:
    Oct 18, 2015
    Posts:
    3
    guys what the heck is this unity engine.... its getting more and more annoying
     
  13. Deleted User

    Deleted User

    Guest

    What's your point exactly? If you have an Ui problem what about asking your question in a new thread instead of posting a useless comment in a dead one?
     
  14. realgamingart

    realgamingart

    Joined:
    Apr 10, 2014
    Posts:
    20
    Assets\Game Scripts\iTween.cs(6083,4): error CS0619: 'GUITexture.color' is obsolete: 'GUITexture has been removed. Use UI.Image instead.'


    cameraFade.GetComponent<GUITexture>().color = new Color(.5f,.5f,.5f,0);
     
  15. ImranAli239

    ImranAli239

    Joined:
    Apr 7, 2022
    Posts:
    1
    men also
     
Thread Status:
Not open for further replies.