Log in or register to post comments

Text displaying by triggering tracker

March 1, 2013 - 8:08pm #1

Hi, Pros,

How can I display a GUI layout by triggering tracker.

Here is my code:

void OnGUI() {
        if (GUI.Button(new Rect(50,700,100,50), "Clone")) {
            mCloneAsap = true;
        }
		if (GUI.Button(new Rect(200,700,100,50), "Delete"))
		{
			mDestroy = true;
		}
		if (GUI.Button(new Rect(350,700,100,50), "Description")) {
            TapSelect();
        }
		if (GUI.Button(new Rect(500,700,100,50), "Exit")) {
            TapSelect();
        }
		if (mShowScreen)
        {
            // scale the help window to fit device screen size
            // because of this scaling, hardcoded values can be used
            float deviceDependentScale = Screen.width / 480f;
            Vector2 screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
            GUIUtility.ScaleAroundPivot(new Vector2(deviceDependentScale, deviceDependentScale), screenCenter);

            // draw the instruction dialog
            GUI.Window(0, new Rect(screenCenter.x - 230, screenCenter.y - 130, 460, 260),
                DrawWindowContent, "", mGUISkin.window);

            // reset scale after drawing
            GUIUtility.ScaleAroundPivot(Vector2.one, screenCenter);
        }
    }
	void TapSelect() 
	{
   		
						mGUISkin = Resources.Load("UserInterfaceSkin") as GUISkin;
						
						mShowScreen = true;
						
						//Debug.Log("Enter"+ hit.collider.gameObject.name);
					
 
	}
	private void DrawWindowContent(int id)
    {
        // render the text in the window
        GUI.Label(new Rect(0, 20, 460, 240), mText, mGUISkin.label);

        if (GUI.Button(new Rect(240, 210, 210, 40), "Back", mGUISkin.button))
        {
            // Re-enable the VideoPlaybackController
           

            // Hide this screen
            mShowScreen = false;
        }
    }

 

Text displaying by triggering tracker

February 28, 2018 - 10:55am #7

Hello Leslie95,

Here's the Unity Documentation for that value: https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

Either print it to the console or a Unity Text UI field.

Thanks,

Vuforia Support

Text displaying by triggering tracker

February 28, 2018 - 10:06am #6

Hi, i need to print my application.persistentdatapath in the screen, i work with odg r7 glasses, and i need to see the path in the screen to check my problem. How can i do that?

thank you.

Text displaying by triggering tracker

March 2, 2013 - 6:09pm #5

That is conditionally displaying the GUI layout when a Trackable is detected  ;)

I think that you need to have your OnGUI method check a boolean variable to control when the text is rendered - this variable should be set to true in OnTrackingFound and false in OnTrackingLost.

e.g.

boolean targetIsFound =  false;

OnGUI(){

if( targetIsFound ){

// render the text

}

}

 

If your OnGUI method is in a separate script from the event handler, you'll need to make that boolean variable public and access it from the event handler using GetComponent<script_name>().variable_name . If it's on another object, Find() that object and call GetComponent on the object reference (e.g. found_obj.GetComponent<T>() ).

Text displaying by triggering tracker

March 2, 2013 - 10:02am #4

Hi, 

I mean when the tracker is found, GUI layout will appear.

But I notice that it won't work because I use void OnGui();

It will automatically show when the program start.

Thx

Text displaying by triggering tracker

March 2, 2013 - 10:02am #3

Hi, 

I mean when the tracker is found, GUI layout will appear.

But I notice that it won't work because I use void OnGui();

It will automatically show when the program start.

Thx

Text displaying by triggering tracker

March 2, 2013 - 1:11am #2

Hi, what do you mean by "triggering tracker" ?

do you mean conditionally display the GUI layout when a Trackable is detected ?

Log in or register to post comments