예제 #1
0
 public void Reload()
 {
     Debug.Log("Reload");
     cam.transform.SetParent(null);
     ESMiniLib.SE_Close();
     InitScenario();
 }
예제 #2
0
    private void Update()
    {
        ESMiniLib.SE_StepDT(Time.deltaTime);

        if (ESMiniLib.SE_GetQuitFlag())
        {
     #if UNITY_EDITOR
            // Application.Quit() does not work in the editor so
            // UnityEditor.EditorApplication.isPlaying need to be set to false to end the game
            ESMiniLib.SE_Close();
            UnityEditor.EditorApplication.isPlaying = false;
     #else
            Application.Quit();
     #endif
        }

        // Check nr of objects
        for (int i = 0; i < ESMiniLib.SE_GetNumberOfObjects(); i++)
        {
            ESMiniLib.SE_GetObjectState(i, ref state);

            // Instantiate objects
            if (cars.Count <= i)
            {
                // Add scenario controlled objects
                int model_id = Mathf.Min(state.model_id, objectNames.Count - 1);
                cars.Add((GameObject)Instantiate(Resources.Load(objectNames[model_id])));
                Debug.Log("Adding " + objectNames[model_id]);

                // Attach camera to first object
                if (i == 0)
                {
                    cam.transform.SetParent(cars[0].transform);
                    cam.transform.position = new Vector3(0.0f, 4f, -12.0f);
                    cam.transform.rotation = Quaternion.Euler(10, 0, 0);
                }
            }

            // Adapt to Unity coordinate system
            cars[i].transform.position = RH2Unity(new Vector3(state.x, state.y, state.z));
            cars[i].transform.rotation = Quaternion.Euler(RHHPR2UnityXYZ(new Vector3(state.h, state.p, state.r)));
        }
    }
예제 #3
0
 void OnApplicationQuit()
 {
     Debug.Log("Quit");
     ESMiniLib.SE_Close();
 }
예제 #4
0
 void OnApplicationQuit()
 {
     Debug.Log("Quit");
     ESMiniLib.SE_Close();
     Marshal.FreeHGlobal(user_data_ptr);
 }