浏览代码

fix issue with attachments to newly created mesh assets, fix issue with non-triangle mesh attachments

/main
Lasse Jon Fuglsang Pedersen 4 年前
当前提交
f26de6c2
共有 2 个文件被更改,包括 20 次插入6 次删除
  1. 4
      Runtime/Utility/MeshBuffers.cs
  2. 22
      Runtime/Utility/MeshInstanceBehaviour.cs

4
Runtime/Utility/MeshBuffers.cs


{
for (int i = 0; i != submeshCount; i++)
{
var topology = mesh.GetTopology(i);
if (topology != MeshTopology.Triangles)
continue;
mesh.GetTriangles(__tempIndices, i);
int submeshTriangleCount = __tempIndices.Count;

22
Runtime/Utility/MeshInstanceBehaviour.cs


using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Experimental.SceneManagement;
#endif

protected virtual void OnMeshInstanceCreated() { }
protected virtual void OnMeshInstanceDeleted() { }
static bool IsMeshInstance(Mesh mesh)
{
#if UNITY_EDITOR
return (EditorUtility.IsPersistent(mesh) == false);
#else
return (mesh.GetInstanceID() < 0);
#endif
}
if (smr.sharedMesh == null || (smr.sharedMesh.GetInstanceID() < 0 && smr.sharedMesh != meshInstance))
if (smr.sharedMesh == null || (IsMeshInstance(smr.sharedMesh) && smr.sharedMesh != meshInstance))
if (smr.sharedMesh != null && smr.sharedMesh.GetInstanceID() >= 0)
if (smr.sharedMesh != null && !IsMeshInstance(smr.sharedMesh))
smr.sharedMesh = EnsureMeshInstanceAux(smr.sharedMesh);
return;

if (mf != null)
{
if (mf.sharedMesh == null || (mf.sharedMesh.GetInstanceID() < 0 && mf.sharedMesh != meshInstance))
if (mf.sharedMesh == null || (IsMeshInstance(mf.sharedMesh) && mf.sharedMesh != meshInstance))
if (mf.sharedMesh != null && mf.sharedMesh.GetInstanceID() >= 0)
if (mf.sharedMesh != null && !IsMeshInstance(mf.sharedMesh))
mf.sharedMesh = EnsureMeshInstanceAux(mf.sharedMesh);
return;

var smr = GetComponent<SkinnedMeshRenderer>();
if (smr != null)
{
if (smr.sharedMesh == null || smr.sharedMesh.GetInstanceID() < 0)
if (smr.sharedMesh == null || IsMeshInstance(smr.sharedMesh))
smr.sharedMesh = meshAsset;
RemoveMeshInstanceAux();

var mf = GetComponent<MeshFilter>();
if (mf != null)
{
if (mf.sharedMesh == null || mf.sharedMesh.GetInstanceID() < 0)
if (mf.sharedMesh == null || IsMeshInstance(mf.sharedMesh))
mf.sharedMesh = meshAsset;
RemoveMeshInstanceAux();

正在加载...
取消
保存