열차 목업의 내부 확인용 프로젝트
smchoi
2024-07-24 ff74c0073046f0e086eb7d355950bda39937c92c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using UnityEngine;
 
public class RunTimeCombineAndRelease:MonoBehaviour{
    
    public SimpleMeshCombine simpleMeshCombine;
    
    public float combineTime = 0.5f;
    public float releaseTime = 2.0f;
    
    public void Awake(){
        simpleMeshCombine = GetComponent<SimpleMeshCombine>();
        //simpleMeshCombine.CombineMeshes();
    }
    
    public void Start() {
        
        if(simpleMeshCombine == null){
            Debug.Log("Couldn't find SMC, aborting");
            return;
        }
        Invoke("Combine", combineTime);
        Invoke("Release", releaseTime);
    }
    
    public void Combine() {
        simpleMeshCombine.CombineMeshes();
        Debug.Log("Combined");
    }
    
    public void Release() {
        simpleMeshCombine.EnableRenderers(true);
        if(simpleMeshCombine.combined == null) return;
        Destroy(simpleMeshCombine.combined);
        simpleMeshCombine.combinedGameOjects = null;
        Debug.Log("Released");
    }
}