Stack Overflow Asked by A4Treok on January 1, 2022
I’m working with Unity(+Vuforia), and I’m having some problems trying to print some variables that I want to identify the vuMark Augmented Reality Object (this a Vuforia thing) with, but I can’t seem to get it to work.
My code is below, where I want the vuMarkID to be compared to “Table”. In the DebugLog, however, my second statement (Debug.Log("vuMarkCompareToTable...")
) returns 1. Even though the first statement (Debug.Log("ID = {0}"...)
) returns “Table”. I have tried trimming the vuMarkID string object, and also tried converting it directly, as you see below.
The other strange thing is nothing will print after “Table” in the debug log, for the first statement. I’ve tried concatenating using something like vuMarkID+"END"
, and the statement just cuts off at “Table”. I’ve even tried printing using "ID = {0}{0}"
, and only the first “Table” prints. Even if the vuMarkID object changes (for instance, to Stool), it still does not print anything after the initial vuMarkID object.
How can I get the Debug.Log to recognize text after “Table” and have the CompareTo function return 0 when the arguments are (seemingly) the same?
Edit: I tried Debug.Log(string.Format("ID = " + vuMarkID + "DONE"));
as well (I’m trying to see if there’s something after the text), but that also cuts off immediately after the vuMarkID. I tried replacing for newline, just in case it was there, but it didn’t have an effect.
//Gets the id of a VuMark Object
string vuMarkID = GetVuMarkId(vuMarkObj).ToString();
if (vuMarkID.CompareTo("Table ") == 0)
{
Debug.Log("Table found from tracking!");
}
else
{
string logdebug = vuMarkID;
object[] args = new object[] { (vuMarkID), vuMarkID.CompareTo("Table") };
Debug.Log(string.Format("ID = {0}", logdebug));
Debug.Log("vuMarkCompareToTable = " + (vuMarkID.Trim().CompareTo("Table")));
}
if (vuMarkID.CompareTo("Table ") == 0)
Note the " "
(space) after Table.
If vuMarkID
is "Table", it would go to else statement as it doesn't match.
You need to remove space:
if (vuMarkID.Trim().CompareTo("Table") == 0)
And to print object if its something else:
do this:
string vuMarkID = GetVuMarkId(vuMarkObj).ToString();
Debug.Log(vuMarkID); // this will always tell you id. No matter what it is.
if (vuMarkID.CompareTo("Table") == 0)
{
Debug.Log("Table found from tracking!");
// do table related stuff.
}
Hope this helps
Answered by Umair M on January 1, 2022
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP