Example #1
0
        public void Consume(ContentRef <SceneCopy> scene)
        {
            if (!scene.IsAvailable)
            {
                return;
            }
            SceneCopy otherScene = scene.Res;
            var       otherObj   = otherScene.RootObjects.ToArray();

            otherScene.Clear();
            this.objectManager.AddObjects(otherObj);
            otherScene.Dispose();
        }
Example #2
0
        void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation)
        {
            GameObjectCopy target = targetObj as GameObjectCopy;

            // Copy plain old data
            target.name      = this.name;
            target.initState = this.initState;
            if (!operation.Context.PreserveIdentity)
            {
                target.identifier = this.identifier;
            }

            // Copy Components from source to target
            for (int i = 0; i < this.compList.Count; i++)
            {
                operation.HandleObject(this.compList[i]);
            }

            // Copy child objects from source to target
            if (this.children != null)
            {
                for (int i = 0; i < this.children.Count; i++)
                {
                    operation.HandleObject(this.children[i]);
                }
            }

            // Copy the objects parent scene as a weak reference, i.e.
            // by assignment, and only when the the scene is itself part of the
            // copied object graph. That way, cloning a GameObject but not its
            // scene will result in a clone that doesn't reference a parent scene.
            SceneCopy targetScene = operation.GetWeakTarget(this.scene);

            if (targetScene != null)
            {
                target.scene = targetScene;
            }

            // Copy the objects prefab link
            operation.HandleObject(this.prefabLink, ref target.prefabLink, true);
        }