Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hollym16 · Jun 26, 2015 at 12:35 PM · c#guitexturescriptingbasicsaugmented-reality

Textures changing for no reason

Ive got a scene that has some GUI buttons coded along the top of my screen, a Canvas with a Menu Bar along the side (New GUI system) and Planes that are attached to the camera and triggered by the GUI buttons.

The scene uses an ARCamera which augments a cuboid model.

On start up, if the camera isn't pointing at the tracker, it brings up a textured plane telling the user to do so then removes it when it is pointing at the camera.

Here's where the problem starts; when using an Android device, while the camera is pointing away and the plane tells you to point at the tracker, everything is fine. However, when I point it at the tracker, it changes the texture of one of the GUI buttons and the Menu bar to the texture of the cuboid model.

It goes back to the right texture if I press one of the GUI buttons that brings up a Plane attached to the camera.

Testing on an iPad, its fine when not looking at the tracker but when it looks at it, it removes all GUI.

Testing in the Editor, it works absolutely fine.

I've tried a number of things such as changing the cuboid model, changing its texture, changing the coding that goes with it, even reimporting all the assets, but all to no avail.

I don't think it's a coding issue as the textures don't link in anyway. The Menu bar doesn't even reference the GUI buttons or the cuboid model.

Here's the code I'm using for my GUI buttons, I hope someone can help:

 using UnityEngine;
 using System.Collections;
 
 public class GUI_Buttons : MonoBehaviour {
 
     //The GUI Buttons
     public Texture2D HomeButton;
     public Texture2D Xray;
     public Texture2D App;
     public Texture2D Basket;
     public Texture2D HelpPage;
     public Texture2D Exit;
     public Texture2D OFF;
 
     //xray of cuboid model
     private GameObject xrayModel;
     //normal cuboid model (Texture Sharer)
     private GameObject RealTex;
     //plane attached to ARCamera
     private GameObject APP;
     //plane attached to ARCamera
     private GameObject HelpWindow;
     private bool clicked = false;
     
     void Start(){
         xrayModel = GameObject.Find ("ImageTarget/XRAY");
         xrayModel.SetActive (true);
         RealTex = GameObject.Find ("ImageTarget/bar");
         RealTex.SetActive (false);
         APP = GameObject.Find ("ARCamera/APP");
         APP.SetActive (false);
         HelpWindow = GameObject.Find ("ARCamera/HelpWindow");
         HelpWindow.SetActive (false);
     }
     void OnGUI(){
         GUI.DrawTexture (new Rect (10, 10, 100, 100), HomeButton);
         GUI.DrawTexture (new Rect (120, 10, 100, 100), Xray);
         GUI.DrawTexture (new Rect (230, 10, 100, 100), App);
         GUI.DrawTexture (new Rect (340, 10, 100, 100), Basket);
         GUI.DrawTexture (new Rect (450, 10, 100, 100), HelpPage);
         GUI.DrawTexture (new Rect (560, 10, 100, 100), Exit);
         GUI.backgroundColor = Color.clear;
     
         if (GUI.Button (new Rect (10, 10, 100, 100), ""))
             Application.LoadLevel ("Home");
 
         if (GUI.Button (new Rect (230, 10, 100, 100), ""))
             APP.SetActive(true);
 
         if (GUI.Button (new Rect (340, 10, 100, 100), ""))
             Application.OpenURL ("http://www.website.com");
 
         if (GUI.Button (new Rect (450, 10, 100, 100), ""))
             HelpWindow.SetActive (true);
 
         if (GUI.Button (new Rect (560, 10, 100, 100), ""))
             Application.Quit ();
             
         if (GUI.Button (new Rect (120, 10, 100, 100), ""))
             clicked = true;
         StartCoroutine ("UnSetActive");
         StartCoroutine ("TexOn");
     
         if (clicked) {
             StartCoroutine ("SetActive");
             StartCoroutine ("TexOff");
             GUI.DrawTexture (new Rect (120, 120, 100, 100), OFF);
             if (GUI.Button (new Rect (120, 120, 100, 100), ""))
                 clicked = false;
         }
     }
     void SetActive(){
         xrayModel.SetActive (true);
     }
     void UnSetActive(){
         xrayModel.SetActive (false);
     }
     void TexOn(){
         RealTex.SetActive (true);
     }
     void TexOff(){
         RealTex.SetActive (false);
     }
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI Style Issue-- Texture not changing 2 Answers

How can i show number of lives as image during gameplay 1 Answer

Can I use multi-layered textures on GUI? 0 Answers

How to change texture of Gameobject/Player 0 Answers

Loading texture2d by script null instance 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges