You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
930 B

5 years ago
  1. using UnityEngine;
  2. public class RunTimeCombineAndRelease:MonoBehaviour{
  3. public SimpleMeshCombine simpleMeshCombine;
  4. public float combineTime = 0.5f;
  5. public float releaseTime = 2.0f;
  6. public void Awake(){
  7. simpleMeshCombine = GetComponent<SimpleMeshCombine>();
  8. //simpleMeshCombine.CombineMeshes();
  9. }
  10. public void Start() {
  11. if(simpleMeshCombine == null){
  12. Debug.Log("Couldn't find SMC, aborting");
  13. return;
  14. }
  15. Invoke("Combine", combineTime);
  16. Invoke("Release", releaseTime);
  17. }
  18. public void Combine() {
  19. simpleMeshCombine.CombineMeshes();
  20. Debug.Log("Combined");
  21. }
  22. public void Release() {
  23. simpleMeshCombine.EnableRenderers(true);
  24. if(simpleMeshCombine.combined == null) return;
  25. Destroy(simpleMeshCombine.combined);
  26. simpleMeshCombine.combinedGameOjects = null;
  27. Debug.Log("Released");
  28. }
  29. }