By dedenAkridana
on Sun, 01/12/2014 - 17:20
#pragma strict var ObjectA: GameObject; var ObjectB: GameObject; var TempActor: String = ""; private var Clone: GameObject; function OnGUI() { GUI.BeginGroup(Rect(20, 20, 200, 270)); GUI.Box(Rect(0, 0, 200, 315), "My Object"); if (GUI.Button(Rect(20, 30, 160, 50), "Object A")) SwitchActor("A"); if (GUI.Button(Rect(20, 100, 160, 50), "Object B")) SwitchActor("B"); GUI.EndGroup(); } function SwitchActor(mag) { if (mag != TempActor) { Destroy(GameObject.Find("Object" + TempActor)); switch (mag) { case "A": TempActor = "A"; Clone = Instantiate(ObjectA, Vector3(0.02722934, 0.002441725, 0.1107947), Quaternion.identity); Clone.name = "ObjectA"; print("A"); break; case "B": TempActor = "B"; Clone = Instantiate(ObjectB, Vector3(0.07206941, 0.07893508, 0.06796837), Quaternion.identity); Clone.name = "ObjectB"; print("B"); break; } } }
// I put it in ARCamera
Excuse me, i have a problem... Please anyone help me...When my phone camera focus to trackimage and I use the change button, it's working, I can change 3D object on my phone screen.But, when i push the button "Object B", Object A is still showed and not destroy, its make the object A is struck down.How to solve it ?
Chance 3D AR Object with Button
Try running your scene in Vuforia's Play Mode ( i.e. the Play button in the Editor ), and watch the Hierarchy panel to confirm that the object names you are using are correct for the instantiated objects.