internal void LoadLevel(int indexOffset) { BasePhysicsDemo.ResetDefaultWorld(); var i = m_SceneData.FindIndex(s => s.Index == SceneManager.GetActiveScene().buildIndex); i += indexOffset; i = (i % m_SceneData.Count + m_SceneData.Count) % m_SceneData.Count; SceneManager.LoadScene(m_SceneData[i].Index, LoadSceneMode.Single); }
#pragma warning restore 649 void Start() { DontDestroyOnLoad(m_EventSystem); DontDestroyOnLoad(gameObject); m_MenuButton.onClick.AddListener(() => { BasePhysicsDemo.ResetDefaultWorld(); SceneManager.LoadScene(0, LoadSceneMode.Single); Destroy(gameObject); Destroy(m_EventSystem.gameObject); }); m_PreviousButton.onClick.AddListener(() => { Loader.LoadLevel(-1); }); m_NextButton.onClick.AddListener(() => { Loader.LoadLevel(1); }); m_ReloadButton.onClick.AddListener(() => { Loader.LoadLevel(0); }); OnSceneLoaded(SceneManager.GetActiveScene(), default); SceneManager.sceneLoaded += OnSceneLoaded; }
void CreateTerrainBody(float3 position, BlobAssetReference <Unity.Physics.Collider> collider) { var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; Entity entity = entityManager.CreateEntity(new ComponentType[] {}); entityManager.AddComponentData(entity, new LocalToWorld { }); entityManager.AddComponentData(entity, new Translation { Value = position }); entityManager.AddComponentData(entity, new Rotation { Value = quaternion.identity }); var colliderComponent = new PhysicsCollider { Value = collider }; entityManager.AddComponentData(entity, colliderComponent); BasePhysicsDemo.CreateRenderMeshForCollider(entityManager, entity, collider, material); }