유니티 셋팅
This commit is contained in:
42
Assets/MeshBaker/Examples/SceneRuntimeExample/MB_Example.cs
Normal file
42
Assets/MeshBaker/Examples/SceneRuntimeExample/MB_Example.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace DigitalOpus.MB.Examples
|
||||
{
|
||||
public class MB_Example : MonoBehaviour
|
||||
{
|
||||
|
||||
public MB3_MeshBaker meshbaker;
|
||||
public GameObject[] objsToCombine;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//Add the objects to the combined mesh
|
||||
//Must have previously baked textures for these in the editor
|
||||
if (meshbaker.AddDeleteGameObjects(objsToCombine, null, true))
|
||||
{
|
||||
//apply the changes we made this can be slow. See documentation
|
||||
meshbaker.Apply();
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
//Apply changes after this and other scripts have made changes
|
||||
//Only to vertecies, tangents and normals
|
||||
//Only want to call this once per frame since it is slow
|
||||
if (meshbaker.UpdateGameObjects(objsToCombine))
|
||||
{
|
||||
meshbaker.Apply(false, true, true, true, false, false, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Dynamically updates the vertices, normals and tangents in combined mesh every frame.\n" +
|
||||
"This is similar to dynamic batching. It is not recommended to do this every frame.\n" +
|
||||
"Also consider baking the mesh renderer objects into a skinned mesh renderer\n" +
|
||||
"The skinned mesh approach is faster for objects that need to move independently of each other every frame.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user