Hello, I have problem access to child of a prefab. the prefab is that I use in ARsession and is a prefab that contain a car model. Model is a fbx made from 4 parts. I need to access this parts of prefab to make single component visible/invisible through canvas button. Someone can help me? tanks
Hello, since no one answers, maybe I wasn't clear in the previous post. I'm developing an app that displays a machine on the AR plane. The machine is made up of 4 parts. Following the standard procedure for creating an AR session in Unity, my machine model (fbx) was converted to prefab, prefab which is then assigned to the script "PlaceOnPlane", script that is component of "AR session origin". Everything works well and the machine is placed perfectly on the plane detected by the app. Now I need to access the different parts of the machine model to interact with these, for example by changing the color or visibility of the part. The interaction is managed through a canvas button. To the button is assigned a script similar to the one below: Code (CSharp): using UnityEngine; using System.Collections; public class apri_stabilizzatori : MonoBehaviour { public GameObject A; public GameObject B; private bool OnOff = true; void Start () { A.SetActive(false); B.SetActive(true); How you'll notice that to make script works you have to drag the GameObject into a field in the editor, but because the GameObject that I had to use is a part of a prefab, I can't drag it directly and I'm not even offered it in the asset list. Essentially, can someone tell me how to access a part (child) of a prefab to interact via an gui button? I apologize if maybe the question is obvious, but I'm stuck on this problem. thank you very much Federico
Correct me if I'm wrong, but it sounds like your model in the scene doesn't have any visible children that you can drag onto scripts, correct? It acts as if it's just one single object? If that is the case, then it sounds like an art problem, the FBX needs to have the four parts split into submeshes in the art tool (Maya or Blender or whatever).
Hi DreamPower, tanks fo your answers. Yes, My model in the scene doesn't have any visible children that I can drag onto scripts. But it isn't a model, it's a prefab dragged in ARSession. I need to access the children inside prefab to switch on/off some of them but I can't see any children. The prefab was done by importing an fbx file from Blender, and I can confirm that the original model had any part split into submeshes. Any idea? Cheers
So, based on your explanation, I assume that the model object is one-single-file that contains many models inside, but none of them being described separately. In short, no visible children of them. This is only an idea, how about create a new Prefab for it in Unity? Make an empty GameObject. Simply, yet quite tiring, put all of the model parts one by one into separate new GameObject. We should place them exactly as the real model.