コード例 #1
0
ファイル: DemoUtils.cs プロジェクト: spicysoft/h5-count-shape
        static public void SetDisplaySize(int width, int height, RenderMode renderMode = RenderMode.Auto)
        {
            DisplayInfo di = tinyEnv.GetConfigData <DisplayInfo>();

            di.width           = width;
            di.height          = height;
            di.renderMode      = renderMode;
            di.autoSizeToFrame = true;
            tinyEnv.SetConfigData(di);
        }
コード例 #2
0
        protected override void OnUpdate()
        {
            Entities.WithAll <CameraAutoAspectFromDisplay>().ForEach((ref Camera c) =>
            {
                TinyEnvironment env = World.TinyEnvironment();
                DisplayInfo di      = env.GetConfigData <DisplayInfo>();
                c.aspect            = (float)di.width / (float)di.height;
            });

            // add camera matrices if needed
            EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.Temp);

            Entities.WithNone <CameraMatrices>().WithAll <Camera>().ForEach((Entity e) =>
            {
                ecb.AddComponent <CameraMatrices>(e);
            });
            ecb.Playback(EntityManager);
            ecb.Dispose();

            // update
            Entities.ForEach((ref Camera c, ref LocalToWorld tx, ref CameraMatrices cm, ref Frustum f) =>
            { // with frustum
                cm.projection = ProjectionMatrixFromCamera(ref c);
                cm.view       = math.inverse(tx.Value);
                FrustumFromCamera(ref cm, ref f);
            });
            Entities.WithNone <Frustum>().ForEach((ref Camera c, ref LocalToWorld tx, ref CameraMatrices cm) =>
            { // no frustum
                cm.projection = ProjectionMatrixFromCamera(ref c);
                cm.view       = math.inverse(tx.Value);
            });
        }
コード例 #3
0
ファイル: AudioHTML.cs プロジェクト: isaveu/SimpleUIDemo
        protected override bool PlaySource(Entity e)
        {
            var mgr = EntityManager;

            if (mgr.HasComponent <AudioSource>(e))
            {
                AudioSource audioSource = mgr.GetComponentData <AudioSource>(e);

                Entity clipEntity = audioSource.clip;
                if (mgr.HasComponent <AudioHTMLClip>(clipEntity))
                {
                    AudioHTMLClip clip = mgr.GetComponentData <AudioHTMLClip>(clipEntity);
                    if (clip.clipID > 0)
                    {
                        if (!unlocked)
                        {
                            AudioHTMLNativeCalls.Unlock();
                            unlocked = AudioHTMLNativeCalls.IsUnlocked();
                            if (unlocked)
                            {
                                TinyEnvironment env = World.TinyEnvironment();
                                AudioConfig     ac  = env.GetConfigData <AudioConfig>();
                                ac.unlocked = unlocked;
                                env.SetConfigData(ac);
                            }
                        }

                        if (unlocked)
                        {
                            // If there is an existing source, it should re-start.
                            // Do this with a Stop() and let it play below.
                            if (mgr.HasComponent <AudioHTMLSource>(e))
                            {
                                AudioHTMLSource ans = mgr.GetComponentData <AudioHTMLSource>(e);
                                AudioHTMLNativeCalls.Stop(ans.sourceID, true);
                            }

                            int sourceID = ++IDPool.sourceID;
                            AudioHTMLNativeCalls.Play(clip.clipID, sourceID, audioSource.volume, audioSource.loop);
                            AudioHTMLSource audioNativeSource = new AudioHTMLSource()
                            {
                                sourceID = sourceID
                            };
                            // Need a native source as well.
                            if (mgr.HasComponent <AudioHTMLSource>(e))
                            {
                                mgr.SetComponentData(e, audioNativeSource);
                            }
                            else
                            {
                                PostUpdateCommands.AddComponent(e, audioNativeSource);
                            }

                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #4
0
        protected override void InitAudioSystem()
        {
            AudioNativeCalls.InitAudio();

            TinyEnvironment env = World.TinyEnvironment();
            AudioConfig     ac  = env.GetConfigData <AudioConfig>();

            ac.initialized = true;
            ac.unlocked    = true;
            env.SetConfigData(ac);
        }
コード例 #5
0
ファイル: AudioHTML.cs プロジェクト: spicysoft/h5-count-shape
        protected override void InitAudioSystem()
        {
            //Console.WriteLine("InitAudioSystem()");
            AudioHTMLNativeCalls.Init();
            unlocked = AudioHTMLNativeCalls.IsUnlocked();
            //Console.WriteLine("(re) checking un-locked: ");
            //Console.WriteLine(unlocked ? "true" : "false");

            TinyEnvironment env = World.TinyEnvironment();
            AudioConfig     ac  = env.GetConfigData <AudioConfig>();

            ac.initialized = true;
            ac.unlocked    = unlocked;
            env.SetConfigData(ac);
        }
コード例 #6
0
ファイル: AudioHTML.cs プロジェクト: spicysoft/h5-count-shape
        protected override void OnUpdate()
        {
            base.OnUpdate();
            TinyEnvironment env = World.TinyEnvironment();
            AudioConfig     ac  = env.GetConfigData <AudioConfig>();

            if (ac.paused != paused)
            {
                paused = ac.paused;
                if (paused)
                {
                    AudioHTMLNativeCalls.Pause();
                }
                else
                {
                    AudioHTMLNativeCalls.Resume();
                }
            }
        }
コード例 #7
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            TinyEnvironment env = World.TinyEnvironment();
            AudioConfig     ac  = env.GetConfigData <AudioConfig>();

            AudioNativeCalls.PauseAudio(ac.paused);

            EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.Temp);

            Entities
            .WithNone <AudioClipLoadFromFileAudioFile>()
            .ForEach((Entity e, ref AudioNativeClip tag) =>
            {
                AudioNativeCalls.FreeAudio(tag.clipID);
                ecb.RemoveComponent <AudioNativeClip>(e);
            });
            ecb.Playback(EntityManager);
            ecb.Dispose();
        }
コード例 #8
0
ファイル: AudioHTML.cs プロジェクト: spicysoft/h5-count-shape
        protected override bool PlaySource(Entity e)
        {
            var mgr = EntityManager;

            if (mgr.HasComponent <AudioSource>(e))
            {
                AudioSource audioSource = mgr.GetComponentData <AudioSource>(e);

                if (mgr.HasComponent <AudioHTMLSource>(e))
                {
                    // If there is a native source and it is IsPlaying() then
                    // can't play another, but we are done. (So return true.)
                    // Note that IsPlaying() is synchronous (which is what we want)
                    // as opposed to isPlaying which is async.
                    AudioHTMLSource ans = mgr.GetComponentData <AudioHTMLSource>(e);
                    if (AudioHTMLNativeCalls.IsPlaying(ans.sourceID))
                    {
                        return(true);
                    }
                }


                Entity clipEntity = audioSource.clip;
                if (mgr.HasComponent <AudioHTMLClip>(clipEntity))
                {
                    AudioHTMLClip clip = mgr.GetComponentData <AudioHTMLClip>(clipEntity);
                    if (clip.clipID > 0)
                    {
                        if (!unlocked)
                        {
                            AudioHTMLNativeCalls.Unlock();
                            unlocked = AudioHTMLNativeCalls.IsUnlocked();
                            if (unlocked)
                            {
                                TinyEnvironment env = World.TinyEnvironment();
                                AudioConfig     ac  = env.GetConfigData <AudioConfig>();
                                ac.unlocked = unlocked;
                                env.SetConfigData(ac);
                            }
                        }

                        if (unlocked)
                        {
                            int sourceID = ++IDPool.sourceID;
                            AudioHTMLNativeCalls.Play(clip.clipID, sourceID, audioSource.volume, audioSource.loop);
                            AudioHTMLSource audioNativeSource = new AudioHTMLSource()
                            {
                                sourceID = sourceID
                            };
                            // Need a native source as well.
                            if (mgr.HasComponent <AudioHTMLSource>(e))
                            {
                                mgr.SetComponentData(e, audioNativeSource);
                            }
                            else
                            {
                                PostUpdateCommands.AddComponent(e, audioNativeSource);
                            }

                            return(true);
                        }
                    }
                }
            }
            return(false);
        }