/// This method calls recursively to find all descendants of a GameObject. If /// they have meshes to render, and/or are Examinable, they are recorded in our /// meshes and examinables lists. private void AddChildToLists(Transform child) { // Don't record the mesh if the child is disabled! if (child.gameObject.activeSelf == false) { return; } // Determine whether the GameObject has a mesh or is Examinable MeshFilter mf = child.gameObject.GetComponent <MeshFilter>(); SkinnedMeshRenderer smr = child.gameObject.GetComponent <SkinnedMeshRenderer>(); IExaminable examinable = child.gameObject.GetComponent <IExaminable>(); // If examinable, create a unique colour to affiliate the examinable with. All non- // examinable children will also be affiliated with this colour. if (examinable != null) { ChangeToNextColour(); colours.Push(new Color(rValue, gValue, bValue, 1.0f)); examinables.Add(new ExaminableColourAffiliation(child.gameObject, colours.Peek(), child.gameObject.name)); } // If mesh exists, record the colour affiliation of it if (mf != null && mf.sharedMesh != null && child.gameObject.GetComponent <Renderer>().enabled) { meshes.Add(new MeshColourAffiliation(mf.sharedMesh, colours.Peek(), child)); } if (smr != null && smr.sharedMesh != null && child.gameObject.GetComponent <Renderer>().enabled) { meshes.Add(new MeshColourAffiliation(smr.sharedMesh, colours.Peek(), child, smr)); } // Recursively call this method on each child for (int i = 0; i < child.childCount; i++) { AddChildToLists(child.GetChild(i)); } // This object and all children have been affiliated with the colour. Remove it. if (examinable != null) { colours.Pop(); } }
public void RemoveExaminable(IExaminable signpost) { if (_control.CurrentExaminables.Contains(signpost)) { _control.CurrentExaminables.Remove(signpost); } }
public void AddExaminable(IExaminable signpost) { if (!_control.CurrentExaminables.Contains(signpost)) { _control.CurrentExaminables.Add(signpost); } }