12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using UnityEngine;
- using System.Collections;
- using LunarCatsStudio.SuperCombiner;
- namespace LunarCatsStudio.SuperCombiner
- {
-
-
-
-
-
-
- public class CombinedMeshModification : MonoBehaviour
- {
-
- [Tooltip("Reference to the _combinedResult file")]
- public CombinedResult _combinedResult;
-
- [Tooltip("Reference to the MeshFilter in which the combined mesh is attached to")]
- public MeshFilter _meshFilter;
-
- private CombinedResult _currentCombinedResult;
-
- void Awake()
- {
-
- _currentCombinedResult = GameObject.Instantiate(_combinedResult) as CombinedResult;
- }
-
-
-
-
- public void RemoveFromCombined(GameObject gameObject)
- {
- RemoveFromCombined (gameObject.GetInstanceID ());
- }
-
-
-
-
- public void RemoveFromCombined(int instanceID)
- {
-
- if (_meshFilter == null)
- {
- Logger.Instance.AddLog("SuperCombiner", "MeshFilter is not set, please assign MeshFilter parameter before trying to remove a part of it's mesh", Logger.LogLevel.LOG_WARNING);
- return;
- }
- bool success = false;
- foreach (MeshCombined meshResult in _currentCombinedResult._meshResults)
- {
- if (meshResult.instanceIds.Contains(instanceID))
- {
- Logger.Instance.AddLog("SuperCombiner", "Removing object '" + instanceID + "' from combined mesh");
- _meshFilter.mesh = meshResult.RemoveMesh(instanceID, _meshFilter.mesh);
- success = true;
- }
- }
- if (!success)
- {
- Logger.Instance.AddLog("SuperCombiner", "Could not remove object '" + instanceID + "' because it was not found", Logger.LogLevel.LOG_WARNING);
- }
- }
- }
- }
|