public static GameObject CreateIU(Model3dARC arc, Transform parentSpace, GameObject prefab) { _gameObject = Instantiate(prefab, new Vector3(), Quaternion.identity); _gameObject.name = "3dARC"; _gameObject.tag = "arc"; _gameObject.transform.SetParent(parentSpace.transform); _gameObject.transform.localPosition = arc.GetPos(); _gameObject.transform.localRotation = arc.GetRotation(); _gameObject.transform.localScale = arc.GetScale(); _gameObject.GetComponent <Apply3dModel>().ApplyModel(arc.GetLink(), _gameObject.transform); return(_gameObject); }
public static GameObject CreateIU(Model3dARC arc, Transform parentSpace, GameObject prefab) { _gameObject = Instantiate(prefab, new Vector3(), Quaternion.identity); _gameObject.name = "3dARC"; _gameObject.tag = "arc"; _gameObject.transform.SetParent(parentSpace.transform); _gameObject.transform.localPosition = arc.GetPos(); _gameObject.transform.localRotation = arc.GetRotation(); _gameObject.transform.localScale = arc.GetScale(); Animation animation = _gameObject.GetComponent <Animation>(); animation.playAutomatically = false; animation.wrapMode = WrapMode.Loop; Debug.Log("Searching for animation clip by name '" + arc.GetAnimationClip() + "'"); AnimationClip clip = animation.GetClip(arc.GetAnimationClip()); if (clip != null) { Debug.Log("Play animation clip '" + arc.GetAnimationClip() + "'"); animation.Play(clip.name); } else { Debug.Log("No animation clip by name '" + arc.GetAnimationClip() + "' is found in this game object, searching in Assets folder"); for (int i = 0; i < InformationViewController.clips.Length; i++) { clip = InformationViewController.clips[i]; if (clip.name.Trim().Equals(arc.GetAnimationClip())) { Debug.Log("Animation clip '" + arc.GetAnimationClip() + "' is found in Assets folder"); Debug.Log("Adding animation clip '" + arc.GetAnimationClip() + "' and play"); clip.legacy = true; animation.AddClip(clip, clip.name); animation.Play(clip.name); break; } } } return(_gameObject); }
private void DisplayIUs(IAU iau) { //destroy current ARControllers foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>()) { if (trans.tag.Equals("arc")) { Destroy(trans.gameObject); } } foreach (Transform trans in panel_bottom.GetComponentsInChildren <Transform>()) { if (trans.tag.Equals("arc")) { Destroy(trans.gameObject); } } //create new arcontrollers with new Content GameObject obj = null; for (int i = 0; i < iau.iau_ius.Count; ++i) { IU iu = iau.iau_ius[i]; switch (iu.iu_type) { case "image": PictureARC pictureARC = new PictureARC(); pictureARC.SetLink(iu.iu_link); pictureARC.SetPos(iu.GetPosition()); pictureARC.SetScale(iu.GetScale()); pictureARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(pictureARC, panel_top, imagePrefab); break; case "text": TextARC textARC = new TextARC(); textARC.SetLink(iu.iu_link); textARC.SetPos(iu.GetPosition()); textARC.SetScale(iu.GetScale()); textARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(textARC, panel_top, textPrefab); break; case "video": VideoARC videoARC = new VideoARC(); videoARC.SetLink(iu.iu_link); videoARC.SetPos(iu.GetPosition()); videoARC.SetScale(iu.GetScale()); videoARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(videoARC, panel_top, videoPrefab); break; case "audio": AudioARC audioARC = new AudioARC(); audioARC.SetLink(iu.iu_link); audioARC.SetPos(iu.GetPosition()); audioARC.SetScale(iu.GetScale()); audioARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(audioARC, panel_top, audioPrefab); break; case "3d": Model3dARC model3dARC = new Model3dARC(); model3dARC.SetLink(iu.iu_link); model3dARC.SetPos(iu.GetPosition()); model3dARC.SetScale(iu.GetScale()); model3dARC.SetRotation(iu.GetRotation()); switch (model3dARC.GetModel()) { case "fusebox": obj = CreateARC.CreateIU(model3dARC, panel_bottom, fuseboxPrefab); break; case "battery pack": obj = CreateARC.CreateIU(model3dARC, panel_bottom, batteryPackPrefab); break; case "buss bars": obj = CreateARC.CreateIU(model3dARC, panel_bottom, bussBarsPrefab); break; case "estop button key": obj = CreateARC.CreateIU(model3dARC, panel_bottom, eStopButtonKeyPrefab); break; case "estop button push": obj = CreateARC.CreateIU(model3dARC, panel_bottom, eStopButtonPushPrefab); break; case "conveyor belt": obj = CreateARC.CreateIU(model3dARC, panel_bottom, conveyorPrefab); break; default: Debug.Log("Could not find 3d model by name '" + model3dARC.GetModel() + "'"); break; } obj.AddComponent <BoxCollider>().size = new Vector3(50, 15, 30); break; default: Debug.Log("Something went wrong with iu type"); break; } } }
private void DisplayIUs(IAU iau) { //destroy current ARControllers foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>()) { if (trans.tag.Equals("arc")) { Destroy(trans.gameObject); } } foreach (Transform trans in panel_bottom.GetComponentsInChildren <Transform>()) { if (trans.tag.Equals("arc")) { Destroy(trans.gameObject); } } foreach (Transform trans in worldSpace.GetComponentsInChildren <Transform>()) { if (trans.tag.Equals("arc")) { Destroy(trans.gameObject); } } //create new arcontrollers with new Content GameObject obj = null; for (int i = 0; i < iau.iau_ius.Count; ++i) { IU iu = iau.iau_ius[i]; switch (iu.iu_type) { case "image": PictureARC pictureARC = new PictureARC(); pictureARC.SetLink(iu.iu_link); pictureARC.SetPos(iu.GetPosition()); pictureARC.SetScale(iu.GetScale()); pictureARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(pictureARC, panel_top, imagePrefab); break; case "text": TextARC textARC = new TextARC(); textARC.SetLink(iu.iu_link); textARC.SetPos(iu.GetPosition()); textARC.SetScale(iu.GetScale()); textARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(textARC, panel_top, textPrefab); break; case "video": VideoARC videoARC = new VideoARC(); videoARC.SetLink(iu.iu_link); videoARC.SetPos(iu.GetPosition()); videoARC.SetScale(iu.GetScale()); videoARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(videoARC, panel_top, videoPrefab); break; case "audio": AudioARC audioARC = new AudioARC(); audioARC.SetLink(iu.iu_link); audioARC.SetPos(iu.GetPosition()); audioARC.SetScale(iu.GetScale()); audioARC.SetRotation(iu.GetRotation()); obj = CreateARC.CreateIU(audioARC, panel_top, audioPrefab); break; case "3d": Model3dARC model3dARC = new Model3dARC(); model3dARC.SetLink(iu.iu_link); model3dARC.SetPos(iu.GetPosition()); model3dARC.SetScale(iu.GetScale()); model3dARC.SetRotation(iu.GetRotation()); CreateARC.CreateIU(model3dARC, panel_bottom, model3dPrefab); break; default: Debug.Log("Something went wrong with iu type"); break; } } }