Beispiel #1
0
    void BenchmarkLoad()
    {
        loadTimer = new Stopwatch();
        loadTimer.Start();

        using (Stream mdlStream = File.OpenRead(mdlLocation))
            using (Stream mdxStream = File.OpenRead(mdxLocation))
            {
                AuroraModel auroraModel = new AuroraModel(mdlStream, mdxStream, Game.KotOR);
                mdlObj = auroraModel.mdlObject;
            }

        loadTimer.Stop();
    }
Beispiel #2
0
    public void OnGUI()
    {
        using (new EditorGUILayout.VerticalScope())
        {
            mdlLocation = EditorGUILayout.TextField("MDL Location", mdlLocation);
            mdxLocation = EditorGUILayout.TextField("MDX Location", mdxLocation);
            if (GUILayout.Button("Load"))
            {
                using (Stream mdlStream = File.OpenRead(mdlLocation))
                    using (Stream mdxStream = File.OpenRead(mdxLocation))
                    {
                        AuroraModel auroraModel = new AuroraModel(mdlStream, mdxStream, Game.KotOR);
                        mdlObj = auroraModel.mdlObject;
                    }
            }
            if (GUILayout.Button("Instantiate"))
            {
                using (Stream mdlStream = File.OpenRead(mdlLocation))
                    using (Stream mdxStream = File.OpenRead(mdxLocation))
                    {
                        // Create an instance
                        GameObject model = AuroraEngine.Resources.LoadModel(mdlStream, mdxStream, new Dictionary <string, GameObject>(), Vector3.zero, null, null, null);
                    }
            }

            if (GUILayout.Button("Benchmark Load"))
            {
                BenchmarkLoad();
            }

            if (GUILayout.Button("Benchmark Instantiate"))
            {
                BenchmarkInstantiate();
            }

            if (loadTimer != null)
            {
                GUILayout.Label("Loading: " + loadTimer.Elapsed.ToString());
            }

            if (instantiateTimer != null)
            {
                GUILayout.Label("Instantiation: " + instantiateTimer.Elapsed.ToString());
            }

            if (loadTimer != null && instantiateTimer != null)
            {
                GUILayout.Label("Loading takes " + loadTimer.Elapsed.TotalSeconds / instantiateTimer.Elapsed.TotalSeconds);
            }

            //using (var scope = new EditorGUILayout.ScrollViewScope(scroll, "box"))
            //{
            //    scroll = scope.scrollPosition;

            //    if (mdlObj != null)
            //    {
            //        // Show the MDL object's information
            //        ShowMDL();
            //    }
            //}
        }
    }