예제 #1
0
 private SceneLoadRequest(SceneSource source, string sceneBehaviorName, string sceneFilePath, SceneLoadMode sceneLoadMode)
 {
     Source            = source;
     SceneBehaviorName = sceneBehaviorName;
     SceneFilePath     = sceneFilePath;
     SceneLoadMode     = sceneLoadMode;
     IsHandled         = false;
 }
예제 #2
0
        protected override bool OnAttached()
        {
            //if (!Application.Current.IsEditor)
            {
                //Remove all children first
                while (this.Owner.NumChildren > 0)
                {
                    this.Owner.RemoveChild(this.Owner.ChildEntities.First());
                }

                this.assetsDirectory = Application.Current.Container.Resolve <AssetsDirectory>();
                WaveSceneImporter importer = new WaveSceneImporter();
                SceneSource       source   = new SceneSource();

                string path = this.GetAssetPath(TypeToId[(int)prefabType]);
                using (var stream = assetsDirectory.Open(path))
                {
                    importer.ImportHeader(stream, out source);
                    importer.ImportData(stream, source, false);
                }

                Entity root = source.SceneData.Items.First().Entity;
                root.Flags = HideFlags.DontSave;

                if (duplicateMaterials)
                {
                    foreach (MaterialComponent m in root.FindComponentsInChildren <MaterialComponent>())
                    {
                        m.Material = m.Material.Clone();
                    }
                }

                this.Owner.AddChild(root);
            }

            return(true);
        }