public virtual void AppendNewGO(fGameObject go, fGameObject parent, bool bKeepPosition) { vObjects.Add(go); go.SetParent(parent, bKeepPosition); go.SetLayer(parent.GetLayer()); foreach (GameObject child_go in go.Children()) { vObjects.Add(child_go); child_go.SetLayer(parent.GetLayer()); } }
/// <summary> /// Utility to add SO geometry to a parent GO, which would then be passed to Create() /// </summary> public static void AppendSOGeometry(fGameObject parentGO, SceneObject so, bool bAddMeshColliders) { fGameObject copy = GameObjectFactory.Duplicate(so.RootGameObject); // if so is a DMeshSO, and it doesn't have a collider, add it if (so is DMeshSO && bAddMeshColliders) { foreach (var go in copy.Children()) { if (go.GetComponent <MeshFilter>() != null && go.GetComponent <MeshCollider>() == null) { go.AddComponent <MeshCollider>(); } } } parentGO.AddChild(copy, true); }
/// <summary> /// This is called for each SO we are going to export, and only fGameObject /// elements in the returned list will be included in mesh export. By default /// this is anything with a MeshFilter. /// *However*, DMeshSO is handled separately because it has an internal DMesh /// that should be written, instead of the fGOs it uses for rendering! /// </summary> protected virtual List <fGameObject> CollectGOChildren(SceneObject so) { List <fGameObject> vExports = new List <fGameObject>(); if (so is DMeshSO) { // handled separately } else { fGameObject rootgo = so.RootGameObject; foreach (GameObject childgo in rootgo.Children()) { if (childgo.GetSharedMesh() != null) { vExports.Add(childgo); } } } return(vExports); }
public static GOWrapperSO CombineAnySOs(SceneObject s1, SceneObject s2, bool bDeleteExisting = true) { FScene scene = s1.GetScene(); if (scene.IsSelected(s1)) { scene.Deselect(s1); } if (scene.IsSelected(s2)) { scene.Deselect(s2); } fGameObject parentGO = GameObjectFactory.CreateParentGO("combined"); fGameObject copy1 = GameObjectFactory.Duplicate(s1.RootGameObject); fGameObject copy2 = GameObjectFactory.Duplicate(s2.RootGameObject); // if inputs are DMeshSOs, they do not have colliders, which we will need... if (s1 is DMeshSO) { foreach (var go in copy1.Children()) { if (go.GetComponent <MeshFilter>() != null && go.GetComponent <MeshCollider>() == null) { go.AddComponent <MeshCollider>(); } } } if (s2 is DMeshSO) { foreach (var go in copy2.Children()) { if (go.GetComponent <MeshFilter>() != null && go.GetComponent <MeshCollider>() == null) { go.AddComponent <MeshCollider>(); } } } parentGO.AddChild(copy1, true); parentGO.AddChild(copy2, true); GOWrapperSO wrapperSO = new GOWrapperSO() { AllowMaterialChanges = false }; wrapperSO.Create(parentGO); if (bDeleteExisting) { scene.RemoveSceneObject(s1, false); scene.RemoveSceneObject(s2, false); } scene.AddSceneObject(wrapperSO, false); return(wrapperSO); }