111
This commit is contained in:
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/DisabledLODGroup.cs
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/DisabledLODGroup.cs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class DisabledLODGroup : MonoBehaviour
|
||||
{
|
||||
[HideInInspector] public MeshCombiner meshCombiner;
|
||||
public LODGroup lodGroup;
|
||||
}
|
||||
}
|
||||
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/DisabledLODGroup.cs.meta
vendored
Normal file
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/DisabledLODGroup.cs.meta
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec7640472ee37d84298be8f3769ced5f
|
||||
timeCreated: 1510250774
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
42
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/FindLODGroups.cs
vendored
Normal file
42
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/FindLODGroups.cs
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class FindLodGroups : MonoBehaviour
|
||||
{
|
||||
|
||||
public bool find;
|
||||
|
||||
void Start()
|
||||
{
|
||||
FindLods();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (find)
|
||||
{
|
||||
find = false;
|
||||
FindLods();
|
||||
}
|
||||
}
|
||||
|
||||
void FindLods()
|
||||
{
|
||||
LODGroup[] lodGroups = GetComponentsInChildren<LODGroup>(true);
|
||||
|
||||
for (int i = 0; i < lodGroups.Length; i++)
|
||||
{
|
||||
Debug.Log(lodGroups[i].name);
|
||||
}
|
||||
Debug.Log("---------------------------------------------");
|
||||
Debug.Log("LODGroups found " + lodGroups.Length);
|
||||
Debug.Log("---------------------------------------------");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/FindLODGroups.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/FindLODGroups.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b31f9c228d56bf043b5219a5ff58508b
|
||||
timeCreated: 1508838518
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
131
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/LODGroupSetup.cs
vendored
Normal file
131
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/LODGroupSetup.cs
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class LODGroupSetup : MonoBehaviour {
|
||||
|
||||
public MeshCombiner meshCombiner;
|
||||
public LODGroup lodGroup;
|
||||
public int lodGroupParentIndex;
|
||||
public int lodCount;
|
||||
|
||||
LODGroup[] lodGroups;
|
||||
|
||||
public void Init(MeshCombiner meshCombiner, int lodGroupParentIndex)
|
||||
{
|
||||
this.meshCombiner = meshCombiner;
|
||||
this.lodGroupParentIndex = lodGroupParentIndex;
|
||||
lodCount = lodGroupParentIndex + 1;
|
||||
|
||||
if (lodGroup == null) lodGroup = gameObject.AddComponent<LODGroup>();
|
||||
|
||||
GetSetup();
|
||||
}
|
||||
|
||||
void GetSetup()
|
||||
{
|
||||
LOD[] lods = new LOD[lodGroupParentIndex + 1];
|
||||
|
||||
for (int i = 0; i < lods.Length; i++)
|
||||
{
|
||||
lods[i] = new LOD();
|
||||
lods[i].screenRelativeTransitionHeight = meshCombiner.lodGroupsSettings[lodGroupParentIndex].lodSettings[i].screenRelativeTransitionHeight;
|
||||
}
|
||||
|
||||
lodGroup.SetLODs(lods);
|
||||
}
|
||||
|
||||
public void ApplySetup()
|
||||
{
|
||||
// Debug.Log("ApplySetup");
|
||||
LOD[] lods = lodGroup.GetLODs();
|
||||
|
||||
if (lodGroups == null) lodGroups = GetComponentsInChildren<LODGroup>();
|
||||
|
||||
if (lods.Length != lodCount) return;
|
||||
|
||||
bool lodGroupsAreRemoved = false;
|
||||
|
||||
if (lodGroupParentIndex == 0)
|
||||
{
|
||||
// Debug.Log("Length " + lodGroups.Length +" " +lods[0].screenRelativeTransitionHeight);
|
||||
if (lods[0].screenRelativeTransitionHeight != 0)
|
||||
{
|
||||
if (lodGroups == null || lodGroups.Length == 1) AddLODGroupsToChildren();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lodGroup != null && lodGroups.Length != 1) RemoveLODGroupFromChildren();
|
||||
lodGroupsAreRemoved = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (meshCombiner != null)
|
||||
{
|
||||
for (int i = 0; i < lods.Length; i++)
|
||||
{
|
||||
meshCombiner.lodGroupsSettings[lodGroupParentIndex].lodSettings[i].screenRelativeTransitionHeight = lods[i].screenRelativeTransitionHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (lodGroupsAreRemoved) return;
|
||||
|
||||
for (int i = 0; i < lodGroups.Length; i++)
|
||||
{
|
||||
LOD[] childLods = lodGroups[i].GetLODs();
|
||||
|
||||
for (int j = 0; j < childLods.Length; j++)
|
||||
{
|
||||
childLods[j].screenRelativeTransitionHeight = lods[j].screenRelativeTransitionHeight;
|
||||
}
|
||||
|
||||
lodGroups[i].SetLODs(childLods);
|
||||
}
|
||||
|
||||
if (meshCombiner != null) lodGroup.size = meshCombiner.cellSize;
|
||||
}
|
||||
|
||||
public void AddLODGroupsToChildren()
|
||||
{
|
||||
// Debug.Log("Add Lod Groups");
|
||||
Transform t = transform;
|
||||
List<LODGroup> lodGroupList = new List<LODGroup>();
|
||||
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
{
|
||||
Transform child = t.GetChild(i);
|
||||
Debug.Log(child.name);
|
||||
LODGroup lodGroup = child.GetComponent<LODGroup>();
|
||||
|
||||
if (lodGroup == null)
|
||||
{
|
||||
lodGroup = child.gameObject.AddComponent<LODGroup>();
|
||||
LOD[] lods = new LOD[1];
|
||||
lods[0] = new LOD(0, child.GetComponentsInChildren<MeshRenderer>());
|
||||
lodGroup.SetLODs(lods);
|
||||
}
|
||||
|
||||
lodGroupList.Add(lodGroup);
|
||||
}
|
||||
|
||||
lodGroups = lodGroupList.ToArray();
|
||||
}
|
||||
|
||||
public void RemoveLODGroupFromChildren()
|
||||
{
|
||||
// Debug.Log("Remove Lod Groups");
|
||||
Transform t = transform;
|
||||
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
{
|
||||
Transform child = t.GetChild(i);
|
||||
LODGroup lodGroup = child.GetComponent<LODGroup>();
|
||||
if (lodGroup != null) DestroyImmediate(lodGroup);
|
||||
}
|
||||
|
||||
lodGroups = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/LODGroupSetup.cs.meta
vendored
Normal file
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/LODGroups/LODGroupSetup.cs.meta
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e72c6f397f46114ca26e357c0ff7e27
|
||||
timeCreated: 1510423325
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user