Example #1
0
        private void Awake()
        {
            World = new World(new Vector2(0, -10));

            // Define the gravity vector.
            DebugDrawer = DebugDrawer.GetDrawer();

            WorldDrawer = new BoxDrawer {
                Drawer = DebugDrawer
            };

            World.SetDebugDrawer(WorldDrawer);
            Logger.SetLogger(new UnityLogger());
        }
Example #2
0
        private void Awake()
        {
            if (!Camera.main)
            {
                throw new NullReferenceException("Require Main Camera: Camera.main");
            }

            TestSettings = FindObjectOfType <TestSettings>();
            MainCamera   = Camera.main;
            World        = new World(new Vector2(0, -10));
            GroundBody   = World.CreateBody(new BodyDef());
            FrameManager = new FrameManager
            {
                Job = () =>
                {
                    PreStep();
                    _pointsCount            = 0;
                    World.AllowSleep        = TestSettings.Sleep;
                    World.WarmStarting      = TestSettings.WarmStarting;
                    World.ContinuousPhysics = TestSettings.TimeOfImpact;
                    World.SubStepping       = TestSettings.SubStepping;
                    World.Step(
                        1f / TestSettings.Frequency,
                        TestSettings.VelocityIteration,
                        TestSettings.PositionIteration);
                    PostStep();
                },
                Interval = 1 / TestSettings.Frequency
            };
            World.SetContactListener(this);
            World.SetDebugDrawer(TestSettings.WorldDrawer);
            Logger.SetLogger(new UnityLogger());

            // DrawString
            //_line = 0f;
            //_lineHeight = Screen.height * 2 / 100f;
            _rect  = new Rect(0, 0, Screen.width, Screen.height * 2f / 100f);
            _style = new GUIStyle
            {
                alignment = TextAnchor.UpperLeft,
                fontSize  = Screen.height * 2 / 100,
                normal    = { textColor = new UnityEngine.Color(0.0f, 0.0f, 0.5f, 1.0f) }
            };
        }