- Home /
Problem with texture to reset and re-enter the same texture
Well guys my english is not very good to write, read only, so sorry if some error writing this, I'm even using the google translator to make my life easier.
Well my problem is this, in my code I have an object that plan to use viewer textures, then apply to other objects, and I'm using GUI buttons to change the texture, there is a button that I use to reset the changes made texture in this view object to reset the value I set the texture of the object to null, and this is not exactly the problem, the problem occurs after clicking the reset button, when I insert a new texture or the texture that was earlier working, the preview image is all white or the texture appears blurry, I am not able to understand why this is happening, I tried moving the code several times but not able to understand what the problem is, now hear in that forum textures to use instantiate. syntax error does not appear, only this same problem that should be something same semantics.
I'll try to put the code down here so that it is easy to understand.
// variables
var tam = 10;
var Text_Parede : Texture[] = new Texture[tam];
var Text_Piso : Texture[] = new Texture[tam];
var Textura : Texture;
var PreviewText : Texture;
/*
...
other functions and variables that do not have to do with the problem//other functions variables
....
*/
// Screen To Textures Buttons
scrollPosition = GUILayout.BeginScrollView (scrollPosition,GUILayout.Width(235),GUILayout.Height(140));
GUILayout.BeginHorizontal();
for(cont=1;cont<=maior;cont++)
{
if(j >= 3)
{
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
j = 0;
i++;
}
if(Text_Parede[cont-1] && BtnParede)
{
if(GUILayout.Button(Text_Parede[cont-1],GUILayout.Width(Btn),GUILayout.Height(Btn)))
{
Textura = new Texture();
Textura = Instantiate(Text_Parede[cont-1]);
showExampleModel = true;
PreviewText = Textura;
GameObject.FindWithTag("FollowMouse").renderer.material.mainTexture = Textura;
preto = 255;
vermelho = 255;
azul = 255;
verde = 255;
tipo = "Parede";
// Para Rotacionar a Textura usando Shaders
//GameObject.FindWithTag("FollowMouse").renderer.material = NewMaterial(Text_Parede[cont-1]);
}
}
if(Text_Piso[cont-1] && BtnPiso)
{
if(GUILayout.Button(Text_Piso[cont-1],GUILayout.Width(Btn),GUILayout.Height(Btn)))
{
Textura = new Texture();
Textura = Instantiate(Text_Piso[cont-1]);
showExampleModel = true;
PreviewText = Textura;
GameObject.FindWithTag("FollowMouse").renderer.material.mainTexture = Textura;
preto = 255;
vermelho = 255;
azul = 255;
verde = 255;
tipo = "Piso";
// Para Rotacionar a Textura usando Shaders
//GameObject.FindWithTag("FollowMouse").renderer.material = NewMaterial(Text_Parede[cont-1]);
}
}
j++;
}
GUILayout.EndHorizontal();
if(BtnCor)
{
CoresPredefinidas();
GrayScale = false;
}
GUILayout.EndScrollView();
/*
...
other functions and variables that do not have to do with the problem//other functions variables
....
*/
// Screen To Reset Button
GUILayout.BeginHorizontal();
GUILayout.Space(180);
if(reset)
{
GUILayout.Box("Resetando Aguarde...",GUILayout.Width(60));
/*DeslocarTextura = true;
EscalarTextura = false;
ColorirTextura = false;*/
reset = false;
}
else
{
if(GUILayout.Button("Resetar",GUILayout.Width(60)))
{
//reset = true;
//Scale_x_text = 1;
//Scale_y_text = 1;
Desc_x_text = 0;
Desc_y_text = 0;
vermelho = 255;
verde = 255;
azul = 255;
Textura = null;
PreviewText = null;
GameObject.FindWithTag("FollowMouse").renderer.material.mainTexture = Textura;
}
}
GUILayout.EndHorizontal();
// the file has 540 lines and not everything has to do with the problem why just put the code where the problem occurred.
Ps.: I am using object with scalar functions, vertical and horizontal scroll, rotate, change color of all textures that appear in the viewer. Do not worry about the variable names in Portuguese.
Thanks for reading, and if you can help will be much appreciated. Sincerely, nicholasfsoares
well guys, no longer need, I solved differently, as I use a color control material for some reason to reset the texture he crashed the value of control, leaving blank or black according to the changed code, as on my screen, I had little buttons like a toolbar, color, scale and texture displacement, reseted the initial position of the toolbar to control color, and now everything is normal.
strange as it may seem my text, the important thing that worked here, it was error semantics.
thanks guys
Your answer
Follow this Question
Related Questions
GUI button doesn't appear on Android 0 Answers
How can I get the Unity 3 texture for 'button on'? 2 Answers
GUILayout.Button scales texture wrong 0 Answers
Specify OnMouseEnter 2 Answers
DrawTexture GUI iPhone 1 Answer