Esempio n. 1
0
        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");

            GOWrapperSO.AppendSOGeometry(parentGO, s1, true);
            GOWrapperSO.AppendSOGeometry(parentGO, s2, 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);
        }
Esempio n. 2
0
        override public SceneObject Duplicate()
        {
            GOWrapperSO copy        = new GOWrapperSO();
            GameObject  duplicateGO = UnityEngine.Object.Instantiate(this.parentGO);

            copy.Create(duplicateGO);
            copy.AssignSOMaterial(GetAssignedSOMaterial());
            return(copy);
        }
Esempio n. 3
0
        // embeds input GameObject in a GOWrapperSO, which provides some basic
        // F3 functionality for arbitrary game objects
        public static SceneObject WrapAnyGameObject(GameObject wrapGO, FContext context, bool bAllowMaterialChanges)
        {
            GOWrapperSO wrapperSO = new GOWrapperSO()
            {
                AllowMaterialChanges = bAllowMaterialChanges
            };

            wrapperSO.Create(wrapGO);
            context.Scene.AddSceneObject(wrapperSO, true);
            return(wrapperSO);
        }
Esempio n. 4
0
        void Update()
        {
            if (ContextSource == null)
            {
                return;
            }

            BaseSceneConfig config = ContextSource.GetComponent <BaseSceneConfig>();

            if (config != null && config.Context != null && config.Context.Scene != null)
            {
                GOWrapperSO newSO = new GOWrapperSO();
                newSO.Create(this.gameObject);

                config.Context.Scene.AddSceneObject(newSO);

                Component.Destroy(this.gameObject.GetComponent <AddExistingGOToScene>());
            }
        }
Esempio n. 5
0
        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);
        }