Ejemplo n.º 1
0
        public void OnGamePlay()
        {
            if (_prevStartKey != _startKey)
            {
                Infos.Clear();
                int sceneCount = SceneManager.sceneCount;
                for (int si = 0; si < sceneCount; ++si)
                {
                    try
                    {
                        var scene   = SceneManager.GetSceneAt(si);
                        var gos     = scene.GetRootGameObjects();
                        int goCount = gos.Length;
                        for (int gi = 0; gi < goCount; ++gi)
                        {
                            var go      = gos[gi];
                            var rbs     = go.GetComponentsInChildren <Rigidbody>();
                            var rbCount = rbs.Length;
                            for (int bi = 0; bi < rbCount; ++bi)
                            {
                                var rb   = rbs[bi];
                                var info = new RigidbodyInfo()
                                {
                                    Name        = GetFullName(rb),
                                    IsActive    = rb.gameObject.activeSelf,
                                    IsKinematic = rb.isKinematic,
                                    IsSleeping  = rb.IsSleeping(),
                                    Position    = rb.position,
                                    Velocity    = rb.velocity,
                                    EntityKey   = EntityKey.Default
                                };

                                var entityReference = rb.GetComponent <EntityReference>();
                                if (entityReference != null)
                                {
                                    info.EntityKey = entityReference.EntityKey;
                                }

                                Infos.Add(info);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.ErrorFormat("{0}", e);
                    }
                }

                _prevStartKey = _startKey;
            }
        }
Ejemplo n.º 2
0
        protected override RigidBodyDebugInfo GetDebugInfo(object param)
        {
            var debugInfo = new RigidBodyDebugInfo();;

            var vhInfo = new VehiclesInfo();

            vhInfo.ActiveUpdateRate = SharedConfig.VehicleActiveUpdateRate;

            var vehicles = _contexts.vehicle.GetEntities();

            foreach (var v in vehicles)
            {
                if (v.IsActiveSelf())
                {
                    vhInfo.ActiveCount++;
                }
                else
                {
                    vhInfo.DeactiveCount++;
                }
            }
            debugInfo.VehcilesInfo = vhInfo;

            var rbDebugInfo = new List <RigidbodyInfo>();

            debugInfo.RigidBodyInfoList = rbDebugInfo;
            int sceneCount = SceneManager.sceneCount;

            for (int si = 0; si < sceneCount; ++si)
            {
                try
                {
                    var scene   = SceneManager.GetSceneAt(si);
                    var gos     = scene.GetRootGameObjects();
                    int goCount = gos.Length;
                    for (int gi = 0; gi < goCount; ++gi)
                    {
                        var go      = gos[gi];
                        var rbs     = go.GetComponentsInChildren <Rigidbody>();
                        var rbCount = rbs.Length;
                        for (int bi = 0; bi < rbCount; ++bi)
                        {
                            var rb   = rbs[bi];
                            var info = new RigidbodyInfo()
                            {
                                Name        = GetFullName(rb),
                                IsActive    = rb.gameObject.activeSelf,
                                IsKinematic = rb.isKinematic,
                                IsSleeping  = rb.IsSleeping(),
                                Position    = rb.position,
                                Velocity    = rb.velocity,
                                EntityKey   = EntityKey.Default
                            };

                            var entityReference = rb.GetComponent <EntityReference>();
                            if (entityReference != null)
                            {
                                info.EntityKey = entityReference.EntityKey;
                            }

                            rbDebugInfo.Add(info);
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.ErrorFormat("{0}", e);
                }
            }

            return(debugInfo);
        }