GUITexture adn GUIText are obsolete - Standard Assets,GUITexture and GUIText are obsolete

I downloaded Unity today and when I click on the play button I get these errors. How can I fix it? I saw a few similar problems online but nothing was applicable to this.

Assets\Standard Assets\Utility\ForcedReset.cs(6,27): error CS0619: ‘GUITexture’ is obsolete: ‘GUITexture has been removed. Use UI.Image instead.’

Assets\Standard Assets\Utility\SimpleActivatorMenu.cs(10,16): error CS0619: ‘GUIText’ is obsolete: ‘GUIText has been removed. Use UI.Text instead.’

Thank you,I downloaded Unity today and when I click on the play button I get these errors. How can I fix it? I saw a few similar problems online but nothing was applicable to this.

Assets\Standard Assets\Utility\ForcedReset.cs(6,27): error CS0619: ‘GUITexture’ is obsolete: ‘GUITexture has been removed. Use UI.Image instead.’

Assets\Standard Assets\Utility\SimpleActivatorMenu.cs(10,16): error CS0619: ‘GUIText’ is obsolete: ‘GUIText has been removed. Use UI.Text instead.’

Thank you

@Athullya I WAS (this is an update I just fixed it!!) having the exact same problem. When I was opening up those files - SimpleActivatorMenu.cs and ForcedReset.cs, and making the suggested changes of GUITexture to UI.Texture and GUIText to UI.Text i was getting the following errors

  • Exception thrown while invoking [OnOpenAssetAttribute] method ‘Unity.CodeEditor.CodeEditor:OnOpenAsset (int,int,int)’ : InvalidOperationException: Cannot start process because a file name has not been provided.

  • InvalidOperationException: Cannot start process because a file name has not been provided.

  • Assets/Standard Assets/Utility/SimpleActivatorMenu.cs(10,16): error CS0246: The type or namespace name ‘UI’ could not be found (are you missing a using directive or an assembly reference?)

  • Assets/Standard Assets/Utility/ForcedReset.cs(6,27): error CS0246: The type or namespace name ‘UI’ could not be found (are you missing a using directive or an assembly reference?)


– then I found this post! - The Type Or Namespace UI could not be found - Trying to create a clickable button - Questions & Answers - Unity Discussions


– so here is my solution

  • in both SimpleActivatorMenu.cs and ForcedReset.cs paste the following at the top “using UnityEngine.UI;”

  • where the originally suggested changes from GUITexture to UI.Texture and GUIText to UI.Text, I just removed the UI, as in the post link above!

now my game mode will play!!!

    //ForcedReset.cs

    using System;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    using UnityStandardAssets.CrossPlatformInput;
    using UnityEngine.UI;
    //change GUITexture to Image
    [RequireComponent(typeof (Image))]
    
    public class ForcedReset : MonoBehaviour
    {
        private void Update()
        {
            // if we have forced a reset ...
            if (CrossPlatformInputManager.GetButtonDown("ResetObject"))
            {
                //... reload the scene
                SceneManager.LoadScene(SceneManager.GetSceneAt(0).name);
            }
        }
    }


//////////////////////////////////
//SimpleActivatorMenu.cs

using System;
using UnityEngine;
using UnityEngine.UI;

namespace UnityStandardAssets.Utility
{
    public class SimpleActivatorMenu : MonoBehaviour
    {
//// change GUIText to TEXT
        public Text camSwitchButton;
        
        
        public GameObject[] objects;


        private int m_CurrentActiveObject;


        private void OnEnable()
        {
            // active object starts from first in array
            m_CurrentActiveObject = 0;
            camSwitchButton.text = objects[m_CurrentActiveObject].name;
        }


        public void NextCamera()
        {
            int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1;

            for (int i = 0; i < objects.Length; i++)
            {
                objects*.SetActive(i == nextactiveobject);*

}

m_CurrentActiveObject = nextactiveobject;
camSwitchButton.text = objects[m_CurrentActiveObject].name;
}
}
}

Search for SimpleActivatorMenu.cs

And change the code to this below.

I had this error today.

I added:

using UnityEngine.UI;

and then changed:

public GUIText camSwitchButton;

to:

 public Text camSwitchButton;

@Athullya I had this same problem. I tried copying and pasting from the comment by @ktduffyinc_unity but it just threw me more warnings and the errors stayed. I just ended up deleting them. When I clicked “play”, Unity re-downloaded those assets again and it works fine now.

For users looking for the answer:

Add

using UnityEngine.UI;
using UnityEngine.UIElements;

to the the top of the script then change:

GUITexture to UI.Texture and GUIText to UI.Text

So, if you have something like:

[RequireComponent(typeof (GUITexture))] 

change it to

[RequireComponent(typeof(UnityEngine.UI.Image))]

This really help.

So my question is how about these:

Image guiTex = gameObject.GetComponent();

        if (guiTex == null)
        {
            gameObject.transform.position = Vector3.zero;
            gameObject.transform.localScale = new Vector3(100, 100, 100);

            Image texture = gameObject.AddComponent<Image>();

            texture.enabled = false;
	
            texture.texture = new Texture2D(1, 1);
			texture.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
			texture.color = Color.clear;
        }
    }

What should i change in order as solution to

  1. GUITexture.pixelInset and
  2. GUITexture.texture

Thanks

problem fixed here : Fix GUIText is obsolete GUIText has been removed in Unity - YouTube

I do two changes

fist1

using UnityEngine.UI;

2**.public GUIText camSwitchButton;**

to:

public Text camSwitchButton;