Exemplo n.º 1
0
        public async System.Threading.Tasks.Task <GActor> NewPrefabActorTo(
            [Editor.Editor_RNameType(EngineNS.Editor.Editor_RNameTypeAttribute.Prefab)]
            RName prefabname,
            SceneGraph.GSceneGraph scene,
            Vector3 location, Quaternion quaternion, Vector3 scale)
        {
            mClip_NewPrefabeActorTo.TimeOutAction = (clip, time) =>
            {
                System.Diagnostics.Debug.WriteLine($"Pooled Prefab [{prefabname}] NewPrefabActorTo time out: {time}/{clip.MaxElapse}");
            };
            using (new Profiler.TimeClipHelper(mClip_NewPrefabeActorTo))
            {
                if (!quaternion.IsValid)
                {
                    quaternion = Quaternion.Identity;
                }
                if (scale == Vector3.Zero)
                {
                    scale = Vector3.UnitXYZ;
                }
                var    rc    = CEngine.Instance.RenderContext;
                GActor actor = await this.QueryObject(prefabname);

                if (actor == null)
                {
                    return(null);
                }

                if (scene != null)
                {
                    actor.AddToScene(scene);
                }
                actor.Placement.Location = location;
                actor.Placement.Rotation = quaternion;
                actor.Placement.Scale    = scale;
                return(actor);
            }
        }
Exemplo n.º 2
0
 public void AddToScene(SceneGraph.GSceneGraph scene)
 {
     scene.AddActor(this);
     scene.World.AddActor(this);
 }