Ejemplo n.º 1
0
        private void Awake()
        {
            Settings             = TestSettingHelper.Load();
            Global.Settings      = Settings;
            Global.Camera.Width  = Settings.WindowWidth;
            Global.Camera.Height = Settings.WindowHeight;
            Screen.SetResolution(Settings.WindowWidth, Settings.WindowHeight, Settings.FullScreenMode);

            var testBaseType = typeof(TestBase);
            var allTypes     = this.GetType()
                               .Assembly.GetTypes();
            var testTypeArray = allTypes.Where(
                e => testBaseType.IsAssignableFrom(e) &&
                !e.IsAbstract &&
                e.GetCustomAttribute <TestCaseAttribute>() != null)
                                .ToArray();
            var testTypes     = new HashSet <Type>(testTypeArray);
            var inheritedTest = allTypes.Where(
                e => testBaseType.IsAssignableFrom(e) &&
                e.GetCustomAttribute <TestInheritAttribute>() != null &&
                e.GetCustomAttribute <TestCaseAttribute>() != null)
                                .ToList();

            foreach (var type in inheritedTest)
            {
                testTypes.Remove(type.BaseType);
            }

            inheritedTest.ForEach(t => testTypes.Add(t));
            Global.SetupTestCases(testTypes.ToList());

            _screenWidth  = Screen.width;
            _screenHeight = Screen.height;

            UnityInput   = new UnityInput();
            Global.Input = UnityInput;

            UnityDrawer = UnityDrawer.GetDrawer();
            DebugDrawer = new DebugDrawer {
                Drawer = UnityDrawer
            };
            Global.DebugDrawer = DebugDrawer;

            GUIController = new GUIController(this);

            Application.quitting += () => TestSettingHelper.Save(Settings);

            FixedUpdate = new FixedUpdate(TimeSpan.FromSeconds(1 / 60d), Tick);
            MainCamera  = Camera.main;
        }
Ejemplo n.º 2
0
        public static void Save(UnityTestSettings settings)
        {
            var json = JsonUtility.ToJson(settings, true);

            File.WriteAllText(SettingFilePath, json);
        }