- Home /
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
Answer by ktduffyinc_unity · Jun 09, 2019 at 02:01 PM
@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! - https://answers.unity.com/questions/1087908/the-type-or-namespace-ui-could-not-be-found-trying.html
-- 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[i].SetActive(i == nextactiveobject);
}
m_CurrentActiveObject = nextactiveobject;
camSwitchButton.text = objects[m_CurrentActiveObject].name;
}
}
}
This problem seems to occur in the latest versions of unity above unity 2019, they changed the scripts! Thanks, $$anonymous$$uch Appreciated.
Other people take note: this is what a perfect technical forum answer looks like. Explain the the issue and explain exactly how to fix with clear examples. Thank you.
Answer by GerardGrundy23 · Apr 10, 2020 at 07:45 AM
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;
Answer by AngelaEngle12 · Feb 02, 2020 at 08:33 PM
@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.
THANK YOU. I'll only add that I had to reload my project before I saw changes.
Answer by Menatombo · Aug 15, 2020 at 02:43 PM
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))]
Answer by nanditho · Sep 16, 2020 at 10:52 AM
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
Your answer
Follow this Question
Related Questions
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Slide GUITexture/GameObject into view? 1 Answer
Android: How do you position GUITexture and GUIText according to different screen sizes (JS)? 2 Answers
Problem touching the Guitexture and Texture 2D simultaneously 0 Answers
GUITexture Position 1 Answer