Exemple #1
0
        public void Run(IServiceRunner runner)
        {
            this.validateData = runner.GetArgs <bool>("ValidateData");

            new ServiceTask <IAssetManager>().Start().Continue(task =>
            {
                ScenePrefab.CreateRecyclePool();

                runner.Ready(_Terminate);
                return(null);
            });
        }
Exemple #2
0
        public override void Enter(StateMachine stateMachine)
        {
            this.completed = false;

            var chunk = stateMachine.Model as SceneChunk;

            chunk._Objects = new List <SceneObject>();
            ServiceCenter.GetService <IAssetManager>().LoadAsync(chunk._ChunkRefData.Path + ".bytes", AssetType.BYTES, asset =>
            {
                if (null != asset)
                {
                    var stream = new MemoryStream(asset.Cast <byte[]>());
                    SceneChunkData.DeserializeAsync(stream, chunk._ValidateData, chunkData =>
                    {
                        stream.Close();
                        stream.Dispose();
                        for (var i = 0; i < chunkData.Objects.Count; ++i)
                        {
                            var go = new GameObject();
                            go.transform.SetParent(chunk._ChunkRoot.transform);

                            var objectData  = chunkData.Objects[i];
                            SceneObject obj = null;
                            switch (objectData.Type)
                            {
                            case SceneObjectType.PREFAB:
                                obj     = new ScenePrefab(objectData, go);
                                go.name = "_Prefab";
                                break;

                            case SceneObjectType.LIGHTMODIFIER:
                                obj     = new SceneLightModifier(objectData, go);
                                go.name = "_LightModifier";
                                break;

                            default:
                                go.name = "_SceneObject";
                                break;
                            }
                            chunk._Objects.Add(obj);
                        }

                        this.completed = true;
                    });
                }
                asset.Dispose();
            });
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        public void Load()
        {
            Clear();

            var prefab = new ScenePrefab(new ScenePrefabData {
                PositionX    = this.transform.localPosition.x,
                PositionY    = this.transform.localPosition.y,
                PositionZ    = this.transform.localPosition.z,
                OrientationX = this.transform.localRotation.x,
                OrientationY = this.transform.localRotation.y,
                OrientationZ = this.transform.localRotation.z,
                OrientationW = this.transform.localRotation.w,
                ScaleX       = this.transform.localScale.x,
                ScaleY       = this.transform.localScale.y,
                ScaleZ       = this.transform.localScale.z,
                Path         = this.PrefabPath,
            }, this.gameObject);

            prefab.Load();
        }
Exemple #4
0
        public void Load()
        {
            using (var asset = ServiceCenter.GetService <IAssetManager>().Load(this.chunkRefData.Path + ".bytes", AssetType.BYTES)) {
                var bytes = asset.Cast <byte[]>();
                if (null != bytes)
                {
                    this.objects = new List <SceneObject>();
                    using (var stream = new MemoryStream(bytes)) {
                        var chunkData = SceneChunkData.Deserialize(stream, this.validateData);
                        for (var i = 0; i < chunkData.Objects.Count; ++i)
                        {
                            var go = new GameObject();
                            go.transform.SetParent(this.chunkRoot.transform);

                            var         objectData = chunkData.Objects[i];
                            SceneObject obj        = null;
                            switch (objectData.Type)
                            {
                            case SceneObjectType.PREFAB:
                                obj     = new ScenePrefab(objectData, go);
                                go.name = "_Prefab";
                                break;

                            case SceneObjectType.LIGHTMODIFIER:
                                obj     = new SceneLightModifier(objectData, go);
                                go.name = "_LightModifier";
                                break;

                            default:
                                go.name = "_SceneObject";
                                break;
                            }
                            this.objects.Add(obj);
                            obj.Load();
                        }
                    }
                }
            }
        }