111
This commit is contained in:
15
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/CachedComponents.cs
vendored
Normal file
15
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/CachedComponents.cs
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class CachedComponents : MonoBehaviour
|
||||
{
|
||||
public GameObject go;
|
||||
public Transform t;
|
||||
public MeshRenderer mr;
|
||||
public MeshFilter mf;
|
||||
public GarbageCollectMesh garbageCollectMesh;
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/CachedComponents.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/CachedComponents.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03afcff0c1e9bee4f8c9e97428da7b81
|
||||
timeCreated: 1508479768
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
733
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Console.cs
vendored
Normal file
733
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Console.cs
vendored
Normal file
@@ -0,0 +1,733 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class Console : MonoBehaviour
|
||||
{
|
||||
static public Console instance;
|
||||
public KeyCode consoleKey = KeyCode.F1;
|
||||
public bool logActive = true;
|
||||
public bool showConsole;
|
||||
public bool showOnError;
|
||||
public bool combineAutomatic = true;
|
||||
bool showLast = true;
|
||||
bool setFocus;
|
||||
|
||||
GameObject selectGO;
|
||||
|
||||
public List<LogEntry> logs = new List<LogEntry>();
|
||||
|
||||
Rect window, inputRect = new Rect(), logRect = new Rect(), vScrollRect = new Rect();
|
||||
string inputText;
|
||||
float scrollPos = 0;
|
||||
int lines = 20;
|
||||
bool showUnityLog = true, showInputLog = true;
|
||||
MeshCombiner[] meshCombiners;
|
||||
MeshCombiner selectedMeshCombiner;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
FindMeshCombiners();
|
||||
|
||||
window = new Rect();
|
||||
inputText = string.Empty;
|
||||
|
||||
ReportStartup();
|
||||
}
|
||||
|
||||
void ReportStartup()
|
||||
{
|
||||
Log("---------------------------------");
|
||||
Log("*** MeshCombineStudio Console ***");
|
||||
Log("---------------------------------");
|
||||
Log("");
|
||||
ReportMeshCombiners(false);
|
||||
Log("combine automatic " + (combineAutomatic ? "on" : "off"));
|
||||
|
||||
if (meshCombiners != null && meshCombiners.Length > 0) SelectMeshCombiner(meshCombiners[0].name);
|
||||
Log("");
|
||||
Log("Type '?' to show commands");
|
||||
|
||||
// ExecuteCommand("?");
|
||||
}
|
||||
|
||||
void FindMeshCombiners()
|
||||
{
|
||||
meshCombiners = GameObject.FindObjectsOfType<MeshCombiner>();
|
||||
}
|
||||
|
||||
void ReportMeshCombiners(bool reportSelected = true)
|
||||
{
|
||||
for (int i = 0; i < meshCombiners.Length; i++) ReportMeshCombiner(meshCombiners[i], true);
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
Log("Selected MCS -> " + selectedMeshCombiner.name);
|
||||
}
|
||||
}
|
||||
|
||||
void ReportMeshCombiner(MeshCombiner meshCombiner, bool foundText = false)
|
||||
{
|
||||
Log((foundText ? "Found MCS -> " : "") + meshCombiner.name + " (" + (meshCombiner.combined ? "*color-green#Combined" : "*color-blue#Uncombined" ) + ")" + " -> Cell Size " + meshCombiner.cellSize + (meshCombiner.searchOptions.useMaxBoundsFactor ? " | Max Bounds Factor " + meshCombiner.searchOptions.maxBoundsFactor : "")
|
||||
+ (meshCombiner.searchOptions.useVertexInputLimit ? " | Vertex Input Limit " + (meshCombiner.searchOptions.useVertexInputLimit ? meshCombiner.searchOptions.vertexInputLimit : 65534) : ""),
|
||||
0, null, meshCombiner);
|
||||
}
|
||||
|
||||
public int SelectMeshCombiner(string name)
|
||||
{
|
||||
if (meshCombiners == null && meshCombiners.Length == 0) return 0;
|
||||
|
||||
for (int i = 0; i < meshCombiners.Length; i++)
|
||||
{
|
||||
MeshCombiner meshCombiner = meshCombiners[i];
|
||||
if (meshCombiner.name == name)
|
||||
{
|
||||
Log("Selected MCS -> " + meshCombiner.name + " (" + (meshCombiner.combined ? "*color-green#Combined" : "*color-blue#Uncombined") + ")", 0, null, meshCombiner);
|
||||
selectedMeshCombiner = meshCombiner; return 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Application.logMessageReceived += HandleLog;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Application.logMessageReceived -= HandleLog;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
instance = null;
|
||||
}
|
||||
|
||||
static public void Log(string logString, int commandType = 0, GameObject go = null, MeshCombiner meshCombiner = null)
|
||||
{
|
||||
instance.logs.Add(new LogEntry(logString, "", LogType.Log, false, commandType, go, meshCombiner));
|
||||
}
|
||||
|
||||
void HandleLog(string logString, string stackTrace, LogType logType)
|
||||
{
|
||||
if (logActive)
|
||||
{
|
||||
logs.Add(new LogEntry(logString, stackTrace, logType, true));
|
||||
if (showOnError && (logType == LogType.Error || logType == LogType.Warning))
|
||||
{
|
||||
SetConsoleActive(true);
|
||||
showLast = true;
|
||||
showUnityLog = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(consoleKey))
|
||||
{
|
||||
SetConsoleActive(!showConsole);
|
||||
}
|
||||
}
|
||||
|
||||
void SetConsoleActive(bool active)
|
||||
{
|
||||
showConsole = active;
|
||||
if (showConsole)
|
||||
{
|
||||
setFocus = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ExecuteCommand(string cmd)
|
||||
{
|
||||
logs.Add(new LogEntry(cmd, "", LogType.Log, false, 1));
|
||||
LogEntry log = logs[logs.Count - 1];
|
||||
|
||||
if (cmd == "?")
|
||||
{
|
||||
Log("'F1' to show/hide console");
|
||||
Log("'dir', 'dirAll', 'dirSort', 'cd', 'show', 'showAll', 'hide', 'hideAll'");
|
||||
Log("'components', 'lines', 'clear', 'gc collect'");
|
||||
Log("'select (MeshCombineStudio name)', ");
|
||||
Log("'report MeshCombineStudio'");
|
||||
Log("'combine', 'uncombine', 'combine automatic on/off'");
|
||||
Log("'max bounds factor (float)/off'");
|
||||
Log("'vertex input limit (float)/off'");
|
||||
Log("'vertex input limit lod (float)/off'");
|
||||
Log("'cell size (float)'");
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd == "gc collect")
|
||||
{
|
||||
System.GC.Collect();
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd == "dir") { Dir(); log.commandType = 2; }
|
||||
else if (cmd == "components") { Components(log); }
|
||||
else if (cmd.Contains("lines "))
|
||||
{
|
||||
int.TryParse(cmd.Replace("lines ", ""), out lines);
|
||||
lines = Mathf.Clamp(lines, 5, 50);
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd == "cd..") { CD(log, ".."); }
|
||||
else if (cmd == "cd\\") { CD(log, "\\"); }
|
||||
else if (cmd.Contains("cd ")) { CD(log, cmd.Replace("cd ", "")); }
|
||||
else if (cmd.Contains("show "))
|
||||
{
|
||||
Transform t = Methods.Find<Transform>(selectGO, cmd.Replace("show ", ""));
|
||||
if (t != null) { t.gameObject.SetActive(true); log.commandType = 2; }
|
||||
}
|
||||
else if (cmd == "show")
|
||||
{
|
||||
if (selectGO != null) { selectGO.SetActive(true); log.commandType = 2; }
|
||||
}
|
||||
else if (cmd.Contains("showAll "))
|
||||
{
|
||||
SetActiveContains(cmd.Replace("showAll ", ""), true);
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd.Contains("hide "))
|
||||
{
|
||||
GameObject go = GameObject.Find(cmd.Replace("hide ", ""));
|
||||
if (go != null) { go.SetActive(false); log.commandType = 2; }
|
||||
}
|
||||
else if (cmd.Contains("hideAll "))
|
||||
{
|
||||
SetActiveContains(cmd.Replace("hideAll ", ""), false);
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd == "hide")
|
||||
{
|
||||
if (selectGO != null) { selectGO.SetActive(false); log.commandType = 2; }
|
||||
}
|
||||
else if (cmd.Contains("clear")) { Clear(log, cmd.Replace("clear ", "")); }
|
||||
else if (cmd.Contains("dir ")) { DirContains(cmd.Replace("dir ", "")); log.commandType = 2; }
|
||||
else if (cmd == "dirAll") { DirAll(); log.commandType = 2; }
|
||||
else if (cmd.Contains("dirSort ")) { DirSort(cmd.Replace("dirSort ", "")); log.commandType = 2; }
|
||||
else if (cmd == "dirSort") { DirSort(); log.commandType = 2; }
|
||||
else if (cmd.Contains("cell size "))
|
||||
{
|
||||
int cellSize;
|
||||
int.TryParse(cmd.Replace("cell size ", ""), out cellSize);
|
||||
if (cellSize < 4)
|
||||
{
|
||||
Log("cell size should be bigger than 4");
|
||||
return;
|
||||
}
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
selectedMeshCombiner.cellSize = cellSize;
|
||||
selectedMeshCombiner.AddObjectsAutomatically();
|
||||
if (combineAutomatic) selectedMeshCombiner.CombineAll();
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
else if (cmd == "report MeshCombineStudio")
|
||||
{
|
||||
ReportMeshCombiners();
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd == "combine")
|
||||
{
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
selectedMeshCombiner.octreeContainsObjects = false;
|
||||
selectedMeshCombiner.CombineAll();
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
else if (cmd == "uncombine")
|
||||
{
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
selectedMeshCombiner.DestroyCombinedObjects();
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
else if (cmd == "combine automatic off")
|
||||
{
|
||||
combineAutomatic = false;
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd == "combine automatic on")
|
||||
{
|
||||
combineAutomatic = true;
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd.Contains("select "))
|
||||
{
|
||||
if (SelectMeshCombiner(cmd.Replace("select ", "")) == 2)
|
||||
{
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
else if (cmd == "max bounds factor off")
|
||||
{
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
selectedMeshCombiner.searchOptions.useMaxBoundsFactor = false;
|
||||
selectedMeshCombiner.AddObjectsAutomatically();
|
||||
if (combineAutomatic) selectedMeshCombiner.CombineAll();
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
else if (cmd.Contains("max bounds factor "))
|
||||
{
|
||||
float maxBoundsFactor;
|
||||
float.TryParse(cmd.Replace("max bounds factor ", ""), out maxBoundsFactor);
|
||||
if (maxBoundsFactor < 1)
|
||||
{
|
||||
Log("max bounds factor needs to be bigger than 1");
|
||||
return;
|
||||
}
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
selectedMeshCombiner.searchOptions.useMaxBoundsFactor = true;
|
||||
selectedMeshCombiner.searchOptions.maxBoundsFactor = maxBoundsFactor;
|
||||
selectedMeshCombiner.AddObjectsAutomatically();
|
||||
if (combineAutomatic) selectedMeshCombiner.CombineAll();
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
else if (cmd == "vertex input limit off")
|
||||
{
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
selectedMeshCombiner.searchOptions.useVertexInputLimit = false;
|
||||
selectedMeshCombiner.AddObjectsAutomatically();
|
||||
if (combineAutomatic) selectedMeshCombiner.CombineAll();
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
else if (cmd.Contains("vertex input limit "))
|
||||
{
|
||||
int vertexInputLimit;
|
||||
int.TryParse(cmd.Replace("vertex input limit ", ""), out vertexInputLimit);
|
||||
if (vertexInputLimit < 1)
|
||||
{
|
||||
Log("vertex input limit needs to be bigger than 1");
|
||||
return;
|
||||
}
|
||||
if (selectedMeshCombiner != null)
|
||||
{
|
||||
selectedMeshCombiner.searchOptions.useVertexInputLimit = true;
|
||||
selectedMeshCombiner.searchOptions.vertexInputLimit = vertexInputLimit;
|
||||
selectedMeshCombiner.AddObjectsAutomatically();
|
||||
if (combineAutomatic) selectedMeshCombiner.CombineAll();
|
||||
ReportMeshCombiner(selectedMeshCombiner);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DirSort()
|
||||
{
|
||||
GameObject[] gos = Methods.Search<GameObject>(selectGO);
|
||||
|
||||
SortLog(gos, true);
|
||||
}
|
||||
|
||||
void DirSort(string name)
|
||||
{
|
||||
GameObject[] gos = Methods.Search<GameObject>();
|
||||
List<GameObject> sortedGos = new List<GameObject>();
|
||||
|
||||
for (int i = 0; i < gos.Length; i++)
|
||||
{
|
||||
if (Methods.Contains(gos[i].name, name)) sortedGos.Add(gos[i]);
|
||||
}
|
||||
SortLog(sortedGos.ToArray());
|
||||
}
|
||||
|
||||
public void SortLog(GameObject[] gos, bool showMeshInfo = false)
|
||||
{
|
||||
List<GameObject> list = new List<GameObject>();
|
||||
List<int> amountList = new List<int>();
|
||||
|
||||
int count = 0;
|
||||
int meshCount = 0;
|
||||
|
||||
for (int i = 0; i < gos.Length; i++)
|
||||
{
|
||||
GameObject go = gos[i];
|
||||
GetMeshInfo(go, ref meshCount);
|
||||
string name = go.name;
|
||||
|
||||
int index = -1;
|
||||
for (int j = 0; j < list.Count; j++)
|
||||
{
|
||||
if (list[j].name == name) { index = j; break; }
|
||||
}
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
list.Add(go);
|
||||
amountList.Add(1);
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
amountList[index]++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
int temp = 0;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
string text = list[i].name + " -> " + amountList[i] + " " + GetMeshInfo(list[i], ref temp);
|
||||
Log(text);
|
||||
}
|
||||
Log("Total amount " + count + " Total items " + list.Count + " Total shared meshes " + meshCount);
|
||||
}
|
||||
|
||||
string GetMeshInfo(GameObject go, ref int meshCount)
|
||||
{
|
||||
MeshFilter mf = go.GetComponent<MeshFilter>();
|
||||
if (mf != null)
|
||||
{
|
||||
Mesh m = mf.sharedMesh;
|
||||
if (m != null)
|
||||
{
|
||||
++meshCount;
|
||||
return "(vertices " + m.vertexCount + ", combine " + Mathf.FloorToInt(65000 / m.vertexCount) + ")";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void TimeStep(string cmd)
|
||||
{
|
||||
float time;
|
||||
float.TryParse(cmd, out time);
|
||||
|
||||
Time.fixedDeltaTime = time;
|
||||
}
|
||||
|
||||
void TimeScale(string cmd)
|
||||
{
|
||||
float time;
|
||||
float.TryParse(cmd, out time);
|
||||
Time.timeScale = time;
|
||||
}
|
||||
|
||||
void Clear(LogEntry log, string cmd)
|
||||
{
|
||||
if (cmd == "clear") { logs.Clear(); log.commandType = 2; }
|
||||
else if (cmd == "input")
|
||||
{
|
||||
for (int i = 0; i < logs.Count; i++)
|
||||
{
|
||||
if (!logs[i].unityLog) logs.RemoveAt(i--);
|
||||
}
|
||||
log.commandType = 2;
|
||||
}
|
||||
else if (cmd == "unity")
|
||||
{
|
||||
for (int i = 0; i < logs.Count; i++)
|
||||
{
|
||||
if (logs[i].unityLog) logs.RemoveAt(i--);
|
||||
}
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void DirAll()
|
||||
{
|
||||
GameObject[] gos = Methods.Search<GameObject>(selectGO);
|
||||
int meshCount = 0;
|
||||
for (int i = 0; i < gos.Length; i++) Log(GetPath(gos[i]) + "\\" + gos[i].transform.childCount + " " + GetMeshInfo(gos[i], ref meshCount), 0, gos[i]);
|
||||
Log(gos.Length + " (meshes " + meshCount + ")\\..");
|
||||
}
|
||||
|
||||
void Dir()
|
||||
{
|
||||
int meshCount = 0;
|
||||
if (selectGO == null)
|
||||
{
|
||||
#if !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2
|
||||
GameObject[] gos = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
|
||||
for (int i = 0; i < gos.Length; i++) Log(gos[i].name + "\\" + gos[i].transform.childCount + " " + GetMeshInfo(gos[i], ref meshCount), 0, gos[i]);
|
||||
Log(gos.Length + " (meshes " + meshCount + ")\\..");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowPath();
|
||||
Transform selectT = selectGO.transform;
|
||||
for (int i = 0; i < selectT.childCount; i++)
|
||||
{
|
||||
Transform child = selectT.GetChild(i);
|
||||
Log(child.name + "\\" + child.childCount + " " + GetMeshInfo(child.gameObject, ref meshCount), 0, child.gameObject);
|
||||
}
|
||||
Log(selectT.childCount + " (meshes " + meshCount + ")\\..");
|
||||
}
|
||||
}
|
||||
|
||||
void Components(LogEntry log)
|
||||
{
|
||||
if (selectGO == null) { log.commandType = 1; return; }
|
||||
|
||||
Component[] components = selectGO.GetComponents<Component>();
|
||||
|
||||
ShowPath(true);
|
||||
for (int i = 0; i < components.Length; i++)
|
||||
{
|
||||
if (components[i] != null) Log(components[i].GetType().Name);
|
||||
}
|
||||
log.commandType = 2;
|
||||
}
|
||||
|
||||
void ShowPath(bool showLines = true)
|
||||
{
|
||||
string path = GetPath(selectGO);
|
||||
if (path != "") Log(path); else Log("Root\\");
|
||||
if (showLines) Log("---------------------------------");
|
||||
}
|
||||
|
||||
string GetPath(GameObject go)
|
||||
{
|
||||
if (go != null)
|
||||
{
|
||||
string path = go.name;
|
||||
Transform t = go.transform;
|
||||
|
||||
while (t.parent != null)
|
||||
{
|
||||
path = path.Insert(0, t.parent.name + "\\");
|
||||
t = t.parent;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void CD(LogEntry log, string name)
|
||||
{
|
||||
if (name == "..")
|
||||
{
|
||||
if (selectGO != null)
|
||||
{
|
||||
if (selectGO.transform.parent != null) selectGO = selectGO.transform.parent.gameObject;
|
||||
else selectGO = null;
|
||||
|
||||
log.commandType = 2;
|
||||
ShowPath(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (name == "\\") { selectGO = null; log.commandType = 2; return; }
|
||||
|
||||
Transform t = Methods.Find<Transform>(selectGO, name);
|
||||
|
||||
if (t != null)
|
||||
{
|
||||
selectGO = t.gameObject;
|
||||
ShowPath(false);
|
||||
log.commandType = 2;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActiveContains(string textContains, bool active)
|
||||
{
|
||||
GameObject[] gos = Methods.Search<GameObject>(selectGO);
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < gos.Length; i++)
|
||||
{
|
||||
if (Methods.Contains(gos[i].name, textContains))
|
||||
{
|
||||
// we shouldn't hide GUI elements :)
|
||||
if (gos[i].transform.parent.name.IndexOf("GUI") == 0 || gos[i].transform.parent.parent == null || gos[i].transform.parent.parent.name.IndexOf("GUI") == 0)
|
||||
{
|
||||
gos[i].SetActive(active);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
}
|
||||
Log("Total amount set to " + active + " : " + count);
|
||||
}
|
||||
|
||||
public void DirContains(string textContains)
|
||||
{
|
||||
GameObject[] gos = Methods.Search<GameObject>(selectGO);
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < gos.Length; i++)
|
||||
{
|
||||
if (Methods.Contains(gos[i].name, textContains)) { Log(gos[i].name, 0, gos[i]); ++count; }
|
||||
}
|
||||
Log("Total amount: " + count);
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!showConsole) return;
|
||||
window.x = 225;
|
||||
window.y = 5;
|
||||
window.yMax = (lines * 20) + 30;
|
||||
window.xMax = Screen.width - (window.x);
|
||||
|
||||
GUI.Box(window, "Console");
|
||||
|
||||
inputRect.x = window.x + 5;
|
||||
inputRect.y = window.yMax - 25;
|
||||
inputRect.xMax = window.xMax - 10;
|
||||
inputRect.yMax = window.yMax - 5;
|
||||
|
||||
if (showInputLog)
|
||||
{
|
||||
if (GUI.GetNameOfFocusedControl() == "ConsoleInput")
|
||||
{
|
||||
if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
|
||||
{
|
||||
showLast = true;
|
||||
|
||||
ExecuteCommand(inputText);
|
||||
inputText = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
GUI.SetNextControlName("ConsoleInput");
|
||||
GUI.changed = false;
|
||||
inputText = GUI.TextField(inputRect, inputText);
|
||||
if (GUI.changed)
|
||||
{
|
||||
if (inputText.Contains("`"))
|
||||
{
|
||||
inputText = inputText.Replace("`", "");
|
||||
SetConsoleActive(!showConsole);
|
||||
}
|
||||
}
|
||||
if (setFocus)
|
||||
{
|
||||
setFocus = false;
|
||||
GUI.FocusControl("ConsoleInput");
|
||||
}
|
||||
}
|
||||
|
||||
if (showInputLog) GUI.color = Color.green; else GUI.color = Color.grey;
|
||||
if (GUI.Button(new Rect(window.xMin + 5, window.yMin + 5, 75, 20), "Input Log"))
|
||||
{
|
||||
showInputLog = !showInputLog;
|
||||
}
|
||||
if (showUnityLog) GUI.color = Color.green; else GUI.color = Color.grey;
|
||||
if (GUI.Button(new Rect(window.xMin + 85, window.yMin + 5, 75, 20), "Unity Log"))
|
||||
{
|
||||
showUnityLog = !showUnityLog;
|
||||
}
|
||||
GUI.color = Color.white;
|
||||
|
||||
if (!showInputLog && !showUnityLog) showInputLog = true;
|
||||
|
||||
logRect.x = window.x + 5;
|
||||
logRect.y = window.y + 25;
|
||||
logRect.xMax = window.xMax - 20;
|
||||
logRect.yMax = logRect.y + 20;
|
||||
|
||||
vScrollRect.x = window.xMax - 15;
|
||||
vScrollRect.y = logRect.y;
|
||||
vScrollRect.xMax = window.xMax - 5;
|
||||
vScrollRect.yMax = window.yMax - 45;
|
||||
|
||||
float size = Mathf.Ceil(vScrollRect.height / 20);
|
||||
|
||||
if (showLast && Event.current.type != EventType.Repaint) scrollPos = logs.Count;
|
||||
|
||||
GUI.changed = false;
|
||||
scrollPos = GUI.VerticalScrollbar(vScrollRect, scrollPos, size > logs.Count - 1 ? logs.Count - 1 : size - 1, 0, logs.Count - 1);
|
||||
if (GUI.changed)
|
||||
{
|
||||
showLast = false;
|
||||
}
|
||||
|
||||
int start = (int)scrollPos;
|
||||
if (start < 0) start = 0;
|
||||
|
||||
int end = start + (int)size;
|
||||
if (end > logs.Count) end = logs.Count;
|
||||
|
||||
int amount = end - start;
|
||||
int i = start;
|
||||
int index = 0;
|
||||
|
||||
while (index != amount && i < logs.Count)
|
||||
{
|
||||
LogEntry log = logs[i];
|
||||
|
||||
if ((log.unityLog && showUnityLog) || (!log.unityLog && showInputLog))
|
||||
{
|
||||
|
||||
if (log.logType == LogType.Warning) AnimateColor(Color.yellow, log, 0.75f);
|
||||
else if (log.logType == LogType.Error) AnimateColor(Color.red, log, 0.75f);
|
||||
else if (log.logType == LogType.Exception) AnimateColor(Color.magenta, log, 0.75f);
|
||||
else if (log.unityLog) AnimateColor(Color.white, log, 0.75f);
|
||||
else if (log.commandType == 1) GUI.color = new Color(0, 0.5f, 0);
|
||||
else if (log.commandType == 2) GUI.color = Color.green;
|
||||
else if (log.go != null) GUI.color = log.go.activeSelf ? Color.white : Color.white * 0.7f;
|
||||
|
||||
string text = log.logString;
|
||||
|
||||
if (text.Contains("*color-"))
|
||||
{
|
||||
if (text.Contains("*color-green#")) { text = text.Replace("*color-green#", ""); GUI.color = Color.green; }
|
||||
else if (text.Contains("*color-blue#")) { text = text.Replace("*color-blue#", ""); GUI.color = Color.blue; }
|
||||
}
|
||||
|
||||
GUI.Label(logRect, i + ") ");
|
||||
logRect.xMin += 55;
|
||||
GUI.Label(logRect, text + ((log.stackTrace != "") ? (" (" + log.stackTrace + ")") : ""));
|
||||
logRect.xMin -= 55;
|
||||
|
||||
GUI.color = Color.white;
|
||||
logRect.y += 20;
|
||||
index++;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void AnimateColor(Color col, LogEntry log, float multi)
|
||||
{
|
||||
GUI.color = Color.Lerp(col * multi, col, Mathf.Abs(Mathf.Sin(Time.time)));
|
||||
}
|
||||
|
||||
public class LogEntry
|
||||
{
|
||||
public string logString;
|
||||
public string stackTrace;
|
||||
public LogType logType;
|
||||
public int commandType;
|
||||
public bool unityLog;
|
||||
public float tStamp;
|
||||
public GameObject go;
|
||||
public MeshCombiner meshCombiner;
|
||||
|
||||
public LogEntry(string logString, string stackTrace, LogType logType, bool unityLog = false, int commandType = 0, GameObject go = null, MeshCombiner meshCombiner = null)
|
||||
{
|
||||
this.logString = logString;
|
||||
this.stackTrace = stackTrace;
|
||||
this.logType = logType;
|
||||
this.unityLog = unityLog;
|
||||
this.commandType = commandType;
|
||||
this.go = go;
|
||||
this.meshCombiner = meshCombiner;
|
||||
// tStamp = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Console.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Console.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 866d6feafa7767a4cb2fcc19a7e5814c
|
||||
timeCreated: 1509385662
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DirectDraw.cs
vendored
Normal file
49
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DirectDraw.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class DirectDraw : MonoBehaviour
|
||||
{
|
||||
|
||||
MeshRenderer[] mrs;
|
||||
Mesh[] meshes;
|
||||
Material[] mats;
|
||||
Vector3[] positions;
|
||||
Quaternion[] rotations;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mrs = GetComponentsInChildren<MeshRenderer>(false);
|
||||
SetMeshRenderersEnabled(false);
|
||||
|
||||
meshes = new Mesh[mrs.Length];
|
||||
mats = new Material[mrs.Length];
|
||||
positions = new Vector3[mrs.Length];
|
||||
rotations = new Quaternion[mrs.Length];
|
||||
|
||||
for (int i = 0; i < mrs.Length; i++)
|
||||
{
|
||||
MeshFilter mf = mrs[i].GetComponent<MeshFilter>();
|
||||
meshes[i] = mf.sharedMesh;
|
||||
mats[i] = mrs[i].sharedMaterial;
|
||||
positions[i] = mrs[i].transform.position;
|
||||
rotations[i] = mrs[i].transform.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
void SetMeshRenderersEnabled(bool enabled)
|
||||
{
|
||||
for (int i = 0; i < mrs.Length; i++) mrs[i].enabled = enabled;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
for (int i = 0; i < mrs.Length; i++)
|
||||
{
|
||||
Graphics.DrawMesh(meshes[i], positions[i], rotations[i], mats[i], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DirectDraw.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DirectDraw.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe3ead8849c569942bd92549d4b8b33b
|
||||
timeCreated: 1504681663
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledLodMeshRender.cs
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledLodMeshRender.cs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class DisabledLodMeshRender : MonoBehaviour
|
||||
{
|
||||
[HideInInspector] public MeshCombiner meshCombiner;
|
||||
public CachedLodGameObject cachedLodGO;
|
||||
}
|
||||
}
|
||||
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledLodMeshRender.cs.meta
vendored
Normal file
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledLodMeshRender.cs.meta
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 543503b98c01a314fb4d57359cf83933
|
||||
timeCreated: 1510253824
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledMeshRenderer.cs
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledMeshRenderer.cs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class DisabledMeshRenderer : MonoBehaviour
|
||||
{
|
||||
[HideInInspector] public MeshCombiner meshCombiner;
|
||||
public CachedGameObject cachedGO;
|
||||
}
|
||||
}
|
||||
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledMeshRenderer.cs.meta
vendored
Normal file
13
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/DisabledMeshRenderer.cs.meta
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cc7efff353789c46a358e329b54fac1
|
||||
timeCreated: 1510254104
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/EnableChildrenMeshRenderers.cs
vendored
Normal file
25
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/EnableChildrenMeshRenderers.cs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class EnableChildrenMeshRenderers : MonoBehaviour
|
||||
{
|
||||
public bool execute;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (execute)
|
||||
{
|
||||
execute = false;
|
||||
Execute();
|
||||
}
|
||||
}
|
||||
|
||||
void Execute()
|
||||
{
|
||||
var mrs = GetComponentsInChildren<MeshRenderer>();
|
||||
|
||||
foreach (var mr in mrs) mr.enabled = true;
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/EnableChildrenMeshRenderers.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/EnableChildrenMeshRenderers.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4730eb4026f3f184da3245e99672aa8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
481
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/FastList.cs
vendored
Normal file
481
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/FastList.cs
vendored
Normal file
@@ -0,0 +1,481 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class FastListBase
|
||||
{
|
||||
protected const int defaultCapacity = 4;
|
||||
public int Count;
|
||||
|
||||
protected int _count;
|
||||
protected int arraySize;
|
||||
}
|
||||
|
||||
public class FastListBase<T> : FastListBase
|
||||
{
|
||||
public T[] items;
|
||||
|
||||
//public T this[int index]
|
||||
//{
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// get { return items[index]; }
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// set { items[index] = value; }
|
||||
//}
|
||||
|
||||
protected void DoubleCapacity()
|
||||
{
|
||||
arraySize *= 2;
|
||||
T[] newItems = new T[arraySize];
|
||||
Array.Copy(items, newItems, _count);
|
||||
items = newItems;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class FastList<T> : FastListBase<T>
|
||||
{
|
||||
// static readonly T[] emptyArray = new T[0];
|
||||
|
||||
// Constructors
|
||||
//=========================================================================================================================================*********
|
||||
//=========================================================================================================================================*********
|
||||
public FastList()
|
||||
{
|
||||
items = new T[defaultCapacity];
|
||||
arraySize = defaultCapacity;
|
||||
}
|
||||
|
||||
public FastList(bool reserve, int reserved)
|
||||
{
|
||||
int capacity = Mathf.Max(reserved, defaultCapacity);
|
||||
items = new T[capacity];
|
||||
arraySize = capacity;
|
||||
Count = _count = reserved;
|
||||
}
|
||||
|
||||
public FastList(int capacity)
|
||||
{
|
||||
if (capacity < 1) capacity = 1;
|
||||
items = new T[capacity];
|
||||
arraySize = capacity;
|
||||
// Debug.Log(items.Length);
|
||||
}
|
||||
|
||||
public FastList(FastList<T> list)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
items = new T[defaultCapacity];
|
||||
arraySize = defaultCapacity;
|
||||
return;
|
||||
}
|
||||
|
||||
items = new T[list.Count];
|
||||
Array.Copy(list.items, items, list.Count);
|
||||
arraySize = items.Length;
|
||||
Count = _count = items.Length;
|
||||
}
|
||||
|
||||
public FastList(T[] items)
|
||||
{
|
||||
this.items = items;
|
||||
_count = Count = arraySize = items.Length;
|
||||
}
|
||||
//=========================================================================================================================================*********
|
||||
//=========================================================================================================================================*********
|
||||
|
||||
protected void SetCapacity(int capacity)
|
||||
{
|
||||
arraySize = capacity;
|
||||
T[] newItems = new T[arraySize];
|
||||
if (_count > 0) Array.Copy(items, newItems, _count);
|
||||
items = newItems;
|
||||
}
|
||||
|
||||
public void SetCount(int count)
|
||||
{
|
||||
if (count > arraySize) SetCapacity(count);
|
||||
Count = _count = count;
|
||||
}
|
||||
|
||||
public void EnsureCount(int count)
|
||||
{
|
||||
if (count <= _count) return;
|
||||
|
||||
if (count > arraySize) SetCapacity(count);
|
||||
Count = _count = count;
|
||||
}
|
||||
|
||||
public virtual void SetArray(T[] items)
|
||||
{
|
||||
this.items = items;
|
||||
_count = Count = arraySize = items.Length;
|
||||
}
|
||||
|
||||
public int AddUnique(T item)
|
||||
{
|
||||
if (!Contains(item)) return Add(item);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return Array.IndexOf(items, item, 0, _count) != -1;
|
||||
}
|
||||
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
return Array.IndexOf(items, item, 0, _count);
|
||||
}
|
||||
|
||||
public T GetIndex(T item)
|
||||
{
|
||||
int index = Array.IndexOf(items, item, 0, _count);
|
||||
if (index == -1) return default(T); else return items[index];
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public virtual int Add(T item)
|
||||
{
|
||||
if (_count == arraySize) DoubleCapacity();
|
||||
|
||||
items[_count] = item;
|
||||
Count = ++_count;
|
||||
return _count - 1;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public virtual int AddThreadSafe(T item)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (_count == arraySize) DoubleCapacity();
|
||||
|
||||
items[_count] = item;
|
||||
Count = ++_count;
|
||||
return _count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Add(T item, T item2)
|
||||
{
|
||||
if (_count + 1 >= arraySize) DoubleCapacity();
|
||||
|
||||
items[_count++] = item;
|
||||
items[_count++] = item2;
|
||||
Count = _count;
|
||||
}
|
||||
|
||||
public virtual void Add(T item, T item2, T item3)
|
||||
{
|
||||
if (_count + 2 >= arraySize) DoubleCapacity();
|
||||
|
||||
items[_count++] = item;
|
||||
items[_count++] = item2;
|
||||
items[_count++] = item3;
|
||||
Count = _count;
|
||||
}
|
||||
|
||||
public virtual void Add(T item, T item2, T item3, T item4)
|
||||
{
|
||||
if (_count + 3 >= arraySize) DoubleCapacity();
|
||||
|
||||
items[_count++] = item;
|
||||
items[_count++] = item2;
|
||||
items[_count++] = item3;
|
||||
items[_count++] = item4;
|
||||
Count = _count;
|
||||
}
|
||||
|
||||
public virtual void Add(T item, T item2, T item3, T item4, T item5)
|
||||
{
|
||||
if (_count + 4 >= arraySize) DoubleCapacity();
|
||||
|
||||
items[_count++] = item;
|
||||
items[_count++] = item2;
|
||||
items[_count++] = item3;
|
||||
items[_count++] = item4;
|
||||
items[_count++] = item5;
|
||||
Count = _count;
|
||||
}
|
||||
|
||||
public virtual void Insert(int index, T item)
|
||||
{
|
||||
if (index > _count) { Debug.LogError("Index " + index + " is out of range " + _count); }
|
||||
if (_count == arraySize) DoubleCapacity();
|
||||
if (index < _count) Array.Copy(items, index, items, index + 1, _count - index);
|
||||
|
||||
items[index] = item;
|
||||
Count = ++_count;
|
||||
}
|
||||
|
||||
public virtual void AddRange(T[] arrayItems)
|
||||
{
|
||||
if (arrayItems == null) return;
|
||||
|
||||
int length = arrayItems.Length;
|
||||
int newCount = _count + length;
|
||||
if (newCount >= arraySize) SetCapacity(newCount * 2);
|
||||
|
||||
Array.Copy(arrayItems, 0, items, _count, length);
|
||||
Count = _count = newCount;
|
||||
}
|
||||
|
||||
public virtual void AddRange(T[] arrayItems, int startIndex, int length)
|
||||
{
|
||||
int newCount = _count + length;
|
||||
if (newCount >= arraySize) SetCapacity(newCount * 2);
|
||||
|
||||
Array.Copy(arrayItems, startIndex, items, _count, length);
|
||||
Count = _count = newCount;
|
||||
}
|
||||
|
||||
public virtual void AddRange(FastList<T> list)
|
||||
{
|
||||
if (list.Count == 0) return;
|
||||
|
||||
int newCount = _count + list.Count;
|
||||
if (newCount >= arraySize) SetCapacity(newCount * 2);
|
||||
|
||||
Array.Copy(list.items, 0, items, _count, list.Count);
|
||||
Count = _count = newCount;
|
||||
}
|
||||
|
||||
public virtual int GrabListThreadSafe(FastList<T> threadList, bool fastClear = false)
|
||||
{
|
||||
lock (threadList)
|
||||
{
|
||||
int count = _count;
|
||||
AddRange(threadList);
|
||||
if (fastClear) threadList.FastClear(); else threadList.Clear();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
//public void AddRange(T item, int amount)
|
||||
//{
|
||||
// int newCount = _count + amount;
|
||||
// if (newCount >= arraySize) SetCapacity(newCount * 2);
|
||||
|
||||
// for (int i = 0; i < amount; i++) items[_count++] = item;
|
||||
|
||||
// Count = _count;
|
||||
//}
|
||||
|
||||
public virtual void ChangeRange(int startIndex, T[] arrayItems)
|
||||
{
|
||||
for (int i = 0; i < arrayItems.Length; i++)
|
||||
{
|
||||
items[startIndex + i] = arrayItems[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Slow
|
||||
public virtual bool Remove(T item, bool weakReference = false)
|
||||
{
|
||||
int index = Array.IndexOf(items, item, 0, _count);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
items[index] = items[--_count];
|
||||
items[_count] = default(T);
|
||||
Count = _count;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void RemoveAt(int index)
|
||||
{
|
||||
if (index >= _count) { Debug.LogError("Index " + index + " is out of range. List count is " + _count); return; }
|
||||
|
||||
items[index] = items[--_count];
|
||||
items[_count] = default(T);
|
||||
Count = _count;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public virtual void RemoveLast()
|
||||
{
|
||||
if (_count == 0) return;
|
||||
|
||||
--_count;
|
||||
|
||||
items[_count] = default(T);
|
||||
|
||||
Count = _count;
|
||||
}
|
||||
|
||||
//public void RemoveRange(int startIndex, int length)
|
||||
//{
|
||||
// if (startIndex + length > _count) { Debug.LogError("StartIndex " + startIndex + " Length " + length + " is out of range. List count is " + _count); return; }
|
||||
|
||||
// int minIndex = startIndex + length;
|
||||
// int copyIndex = _count - length;
|
||||
|
||||
// if (copyIndex < minIndex) copyIndex = minIndex;
|
||||
|
||||
// int length2 = _count - copyIndex;
|
||||
// int index = startIndex;
|
||||
|
||||
// // Debug.Log("CopyIndex " + copyIndex + " length2 " + length2 + " rest " + (length - length2));
|
||||
|
||||
// for (int i = 0; i < length2; i++)
|
||||
// {
|
||||
// if (items[index] == null) { Debug.LogError(" item list " + (index) + " is null! List count " + _count); }
|
||||
// items[index] = items[copyIndex + i];
|
||||
// items[copyIndex + i] = default(T);
|
||||
// --_count;
|
||||
// }
|
||||
|
||||
// length -= length2;
|
||||
|
||||
// for (int i = 0; i < length; i++)
|
||||
// {
|
||||
// items[index++] = default(T);
|
||||
// --_count;
|
||||
// }
|
||||
|
||||
// Count = _count;
|
||||
//}
|
||||
|
||||
public virtual void RemoveRange(int index, int length)
|
||||
{
|
||||
if (_count - index < length)
|
||||
{
|
||||
Debug.LogError("Invalid length!");
|
||||
}
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
_count -= length;
|
||||
if (index < _count)
|
||||
{
|
||||
Array.Copy(items, index + length, items, index, _count - index);
|
||||
}
|
||||
Array.Clear(items, _count, length);
|
||||
Count = _count;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T Dequeue()
|
||||
{
|
||||
if (_count == 0)
|
||||
{
|
||||
Debug.LogError("List is empty!");
|
||||
return default(T);
|
||||
}
|
||||
|
||||
T item = items[--_count];
|
||||
|
||||
items[_count] = default(T);
|
||||
Count = _count;
|
||||
return item;
|
||||
}
|
||||
|
||||
public virtual T Dequeue(int index)
|
||||
{
|
||||
T item = items[index];
|
||||
|
||||
items[index] = items[--_count];
|
||||
items[_count] = default(T);
|
||||
Count = _count;
|
||||
return item;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public virtual void Clear()
|
||||
{
|
||||
Array.Clear(items, 0, _count);
|
||||
Count = _count = 0;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public virtual void ClearThreadSafe()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
Array.Clear(items, 0, _count);
|
||||
Count = _count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ClearRange(int startIndex)
|
||||
{
|
||||
Array.Clear(items, startIndex, _count - startIndex);
|
||||
Count = _count = startIndex;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public virtual void FastClear()
|
||||
{
|
||||
Count = _count = 0;
|
||||
}
|
||||
|
||||
public virtual void FastClear(int newCount)
|
||||
{
|
||||
if (newCount < Count)
|
||||
{
|
||||
Count = _count = newCount;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] ToArray()
|
||||
{
|
||||
T[] array = new T[_count];
|
||||
Array.Copy(items, 0, array, 0, _count);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class SortedFastList<T> : FastList<T>
|
||||
{
|
||||
new public void RemoveAt(int index)
|
||||
{
|
||||
if (index >= _count) { Debug.LogError("Index " + index + " is out of range " + _count); }
|
||||
|
||||
_count--;
|
||||
if (index < _count) Array.Copy(items, index + 1, items, index, _count - index);
|
||||
items[_count] = default(T);
|
||||
Count = _count;
|
||||
}
|
||||
|
||||
new public void RemoveRange(int index, int endIndex)
|
||||
{
|
||||
int length = (endIndex - index) + 1;
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
Debug.LogError("Index needs to be bigger than 0 -> " + index);
|
||||
return;
|
||||
}
|
||||
|
||||
if (length < 0)
|
||||
{
|
||||
Debug.LogError("Length needs to be bigger than 0 -> " + length);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count - index < length)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_count -= length;
|
||||
if (index < _count)
|
||||
{
|
||||
Array.Copy(items, index + length, items, index, _count - index);
|
||||
}
|
||||
Array.Clear(items, _count, length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/FastList.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/FastList.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b551b40363254e4d834daa4f6baac9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/GarbageCollectMesh.cs
vendored
Normal file
25
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/GarbageCollectMesh.cs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class GarbageCollectMesh : MonoBehaviour
|
||||
{
|
||||
public Mesh mesh;
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (mesh != null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
DestroyImmediate(mesh);
|
||||
#else
|
||||
Destroy(mesh);
|
||||
#endif
|
||||
}
|
||||
// Debug.Log("Destroy Mesh");
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/GarbageCollectMesh.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/GarbageCollectMesh.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 585afa5e7b5db2c42986fb8e6960e8d7
|
||||
timeCreated: 1497467774
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
75
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_CameraController.cs
vendored
Normal file
75
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_CameraController.cs
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class MCS_CameraController : MonoBehaviour {
|
||||
|
||||
public float speed = 10;
|
||||
public float mouseMoveSpeed = 1;
|
||||
public float shiftMulti = 3f;
|
||||
public float controlMulti = 0.5f;
|
||||
|
||||
Vector3 oldMousePosition;
|
||||
GameObject cameraMountGO, cameraChildGO;
|
||||
|
||||
Transform cameraMountT, cameraChildT, t;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
t = transform;
|
||||
CreateParents();
|
||||
}
|
||||
|
||||
void CreateParents()
|
||||
{
|
||||
cameraMountGO = new GameObject("CameraMount");
|
||||
cameraChildGO = new GameObject("CameraChild");
|
||||
|
||||
cameraMountT = cameraMountGO.transform;
|
||||
cameraChildT = cameraChildGO.transform;
|
||||
|
||||
cameraChildT.SetParent(cameraMountT);
|
||||
|
||||
cameraMountT.position = t.position;
|
||||
cameraMountT.rotation = t.rotation;
|
||||
|
||||
t.SetParent(cameraChildT);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 deltaMouse = (Input.mousePosition - oldMousePosition) * mouseMoveSpeed * (Time.deltaTime * 60);
|
||||
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
cameraMountT.Rotate(0, deltaMouse.x, 0, Space.Self);
|
||||
cameraChildT.Rotate(-deltaMouse.y, 0, 0, Space.Self);
|
||||
}
|
||||
|
||||
oldMousePosition = Input.mousePosition;
|
||||
|
||||
Vector3 move = Vector3.zero;
|
||||
|
||||
if (Input.GetKey(KeyCode.W)) move.z = speed;
|
||||
else if (Input.GetKey(KeyCode.S)) move.z = -speed;
|
||||
else if (Input.GetKey(KeyCode.A)) move.x = -speed;
|
||||
else if (Input.GetKey(KeyCode.D)) move.x = speed;
|
||||
else if (Input.GetKey(KeyCode.Q)) move.y = -speed;
|
||||
else if (Input.GetKey(KeyCode.E)) move.y = speed;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) move *= shiftMulti;
|
||||
else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) move *= controlMulti;
|
||||
|
||||
move *= Time.deltaTime * 60;
|
||||
|
||||
Quaternion rotation = Quaternion.identity;
|
||||
rotation.eulerAngles = new Vector3(cameraChildT.eulerAngles.x, cameraMountT.eulerAngles.y, 0);
|
||||
move = rotation * move;
|
||||
// move = cameraMountT.rotation * move;
|
||||
|
||||
cameraMountT.position += move;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_CameraController.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_CameraController.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 378152e1b020e6d4987908966ef4833e
|
||||
timeCreated: 1505372378
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
305
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_FPSCounter.cs
vendored
Normal file
305
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_FPSCounter.cs
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class MCS_FPSCounter : MonoBehaviour
|
||||
{
|
||||
|
||||
static public MCS_FPSCounter instance;
|
||||
|
||||
[Header("___ Settings ___________________________________________________________________________________________________________")]
|
||||
public float interval = 0.25f;
|
||||
public enum GUIType { DisplayRunning, DisplayResults, DisplayNothing }
|
||||
public GUIType displayType = GUIType.DisplayRunning;
|
||||
public Vector2 gradientRange = new Vector2(15, 60);
|
||||
public Font fontRun;
|
||||
public Font fontResult;
|
||||
public Texture logo;
|
||||
public bool showLogoOnResultsScreen = true;
|
||||
public KeyCode showHideButton = KeyCode.Backspace;
|
||||
public bool acceptInput = true;
|
||||
public bool reset;
|
||||
|
||||
[Header("___ Results ___________________________________________________________________________________________________________")]
|
||||
public float currentFPS = 0;
|
||||
public float averageFPS = 0;
|
||||
public float minimumFPS = 0;
|
||||
public float maximumFPS = 0;
|
||||
|
||||
// Privates
|
||||
int totalFrameCount, tempFrameCount;
|
||||
double tStamp, tStampTemp;
|
||||
|
||||
// GUI-------------------------------------------
|
||||
string currentFPSText, avgFPSText, minFPSText, maxFSPText;
|
||||
|
||||
GUIStyle bigStyle = new GUIStyle(); GUIStyle bigStyleShadow;
|
||||
GUIStyle smallStyle = new GUIStyle(); GUIStyle smallStyleShadow; GUIStyle smallStyleLabel;
|
||||
GUIStyle headerStyle = new GUIStyle();
|
||||
|
||||
Rect[] rectsRun = { new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect() };
|
||||
Rect[] rectsResult = { new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect(), new Rect() };
|
||||
Gradient gradient = new Gradient();
|
||||
|
||||
const float line1 = 4;
|
||||
const float line2 = line1 + 26;
|
||||
const float line3 = line2 + 14;
|
||||
const float line4 = line3 + 14;
|
||||
const float labelWidth = 26;
|
||||
const float paddingH = 8;
|
||||
const float lineHeight = 22;
|
||||
float columnRight;
|
||||
float columnLeft;
|
||||
|
||||
Color fontShadow = new Color(0, 0, 0, 0.5f);
|
||||
Color label = new Color(0.8f, 0.8f, 0.8f, 1);
|
||||
Color colorCurrent, colorAvg;
|
||||
|
||||
const string resultHeader = "BENCHMARK RESULTS";
|
||||
const string resultLabelAvg = "AVERAGE FPS:";
|
||||
const string resultLabelMin = "MINIMUM FPS:";
|
||||
const string resultLabelMax = "MAXIMUM FPS:";
|
||||
GUIContent resultHeaderGUI = new GUIContent(resultHeader);
|
||||
GUIContent reslutLabelAvgGUI = new GUIContent(resultLabelAvg);
|
||||
GUIContent avgTextGUI = new GUIContent();
|
||||
GUIContent instructions = new GUIContent("PRESS SPACEBAR TO RERUN BENCHMARK | PRESS ESCAPE TO RETURN TO MENU");
|
||||
|
||||
const string runLabelAvg = "Avg:";
|
||||
const string runLabelMin = "Min:";
|
||||
const string runLabelMax = "Max:";
|
||||
|
||||
Vector2 screenSize = new Vector2(0, 0);
|
||||
GUIType oldDisplayType = GUIType.DisplayNothing;
|
||||
//-----------------------------------------------
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
gradient.colorKeys = new GradientColorKey[] { new GradientColorKey(new Color(1, 0, 0, 1), 0), new GradientColorKey(new Color(1, 1, 0, 1), 0.5f), new GradientColorKey(new Color(0, 1, 0, 1), 1f) };
|
||||
}
|
||||
|
||||
void OnDestroy() { if (instance == this) instance = null; }
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (displayType == GUIType.DisplayNothing) return;
|
||||
else if (displayType == GUIType.DisplayRunning)
|
||||
{
|
||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y) { screenSize.x = Screen.width; screenSize.y = Screen.height; SetRectsRun(); }
|
||||
|
||||
// TEXT DROPSHADOWS ----------------------------------------------------------
|
||||
GUI.Label(rectsRun[0], currentFPSText, bigStyleShadow); // Result Current FPS
|
||||
GUI.Label(rectsRun[1], avgFPSText, smallStyleShadow); // Result Average FPS
|
||||
GUI.Label(rectsRun[2], minFPSText, smallStyleShadow); // ReSult Minimum FPS
|
||||
GUI.Label(rectsRun[3], maxFSPText, smallStyleShadow); // Result Maximum FPS
|
||||
|
||||
GUI.Label(rectsRun[4], runLabelAvg, smallStyleShadow); // Label Average FPS
|
||||
GUI.Label(rectsRun[5], runLabelMin, smallStyleShadow); // Label Minimum FPS
|
||||
GUI.Label(rectsRun[6], runLabelMax, smallStyleShadow); // Label Maximum FPS
|
||||
|
||||
// TEXT ----------------------------------------------------------------------
|
||||
GUI.Label(rectsRun[7], currentFPSText, bigStyle); // Result Current FPS
|
||||
GUI.Label(rectsRun[8], avgFPSText, smallStyle); // Result Average FPS
|
||||
GUI.Label(rectsRun[9], minFPSText, smallStyle); // ReSult Minimum FPS
|
||||
GUI.Label(rectsRun[10], maxFSPText, smallStyle); // Result Maximum FPS
|
||||
|
||||
GUI.Label(rectsRun[11], runLabelAvg, smallStyleLabel); // Label Average FPS
|
||||
GUI.Label(rectsRun[12], runLabelMin, smallStyleLabel); // Label Minimum FPS
|
||||
GUI.Label(rectsRun[13], runLabelMax, smallStyleLabel); // Label Maximum FPS
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y) { screenSize.x = Screen.width; screenSize.y = Screen.height; SetRectsResult(); }
|
||||
|
||||
if (showLogoOnResultsScreen) GUI.DrawTexture(rectsResult[8], logo);
|
||||
|
||||
GUI.Label(rectsResult[0], resultHeaderGUI, headerStyle); // Header
|
||||
GUI.DrawTexture(rectsResult[1], Texture2D.whiteTexture); // Line
|
||||
|
||||
GUI.Label(rectsResult[2], reslutLabelAvgGUI, smallStyle); // Label Average FPS
|
||||
GUI.Label(rectsResult[4], resultLabelMin, smallStyleLabel); // Label Minimum FPS
|
||||
GUI.Label(rectsResult[6], resultLabelMax, smallStyleLabel); // Label Maximum FPS
|
||||
|
||||
GUI.Label(rectsResult[3], avgTextGUI, bigStyle); // Result Average FPS
|
||||
GUI.Label(rectsResult[5], minFPSText, smallStyle); // ReSult Minimum FPS
|
||||
GUI.Label(rectsResult[7], maxFSPText, smallStyle); // Result Maximum FPS
|
||||
|
||||
GUI.Label(rectsResult[9], instructions, smallStyleLabel); // Instructions
|
||||
}
|
||||
} //==============================================================================================================
|
||||
void SetRectsRun()
|
||||
{
|
||||
columnRight = Screen.width - (labelWidth + paddingH);
|
||||
columnLeft = columnRight - (labelWidth + paddingH);
|
||||
|
||||
// float editorOffset = Screen.height * 0.09f;
|
||||
float editorOffset = 0;
|
||||
|
||||
|
||||
// TEXT DROPSHADOWS ----------------------------------------------------------
|
||||
rectsRun[0].Set(Screen.width - (40 + paddingH) + 1, editorOffset + line1 + 2, 40, lineHeight); // Result Current FPS
|
||||
rectsRun[1].Set(columnRight + 1, editorOffset + line2 + 2, labelWidth, lineHeight); // Result Average FPS
|
||||
rectsRun[2].Set(columnRight + 1, editorOffset + line3 + 2, labelWidth, lineHeight); // ReSult Minimum FPS
|
||||
rectsRun[3].Set(columnRight + 1, editorOffset + line4 + 2, labelWidth, lineHeight); // Result Maximum FPS
|
||||
|
||||
rectsRun[4].Set(columnLeft + 1, editorOffset + line2 + 2, labelWidth, lineHeight); // Label Average FPS
|
||||
rectsRun[5].Set(columnLeft + 1, editorOffset + line3 + 2, labelWidth, lineHeight); // Label Minimum FPS
|
||||
rectsRun[6].Set(columnLeft + 1, editorOffset + line4 + 2, labelWidth, lineHeight); // Label Maximum FPS
|
||||
|
||||
// TEXT ----------------------------------------------------------------------
|
||||
rectsRun[7].Set(Screen.width - (45 + paddingH), editorOffset + line1, 45, lineHeight); // Result Current FPS
|
||||
rectsRun[8].Set(columnRight, editorOffset + line2, labelWidth, lineHeight); // Result Average FPS
|
||||
rectsRun[9].Set(columnRight, editorOffset + line3, labelWidth, lineHeight); // ReSult Minimum FPS
|
||||
rectsRun[10].Set(columnRight, editorOffset + line4, labelWidth, lineHeight); // Result Maximum FPS
|
||||
|
||||
rectsRun[11].Set(columnLeft, editorOffset + line2, labelWidth, lineHeight); // Label Average FPS
|
||||
rectsRun[12].Set(columnLeft, editorOffset + line3, labelWidth, lineHeight); // Label Minimum FPS
|
||||
rectsRun[13].Set(columnLeft, editorOffset + line4, labelWidth, lineHeight); // Result Maximum FPS
|
||||
} //==============================================================================================================
|
||||
|
||||
void SetRectsResult()
|
||||
{
|
||||
float totalHeight = 512 / 2;
|
||||
rectsResult[8].Set((Screen.width / 2) - (logo.width / 2), (Screen.height / 2) - totalHeight, logo.width, logo.height); // Drone Logo
|
||||
|
||||
Vector2 size = headerStyle.CalcSize(resultHeaderGUI);
|
||||
rectsResult[0].Set((Screen.width / 2) - (size.x / 2), (Screen.height / 2) - (totalHeight - 256), size.x, size.y); // Header
|
||||
size.x += 10;
|
||||
rectsResult[1].Set((Screen.width / 2) - (size.x / 2), (Screen.height / 2) - (totalHeight - 256 - 30), size.x, 1); // Line
|
||||
|
||||
rectsResult[2].Set((Screen.width / 2) - 200, (Screen.height / 2) - (totalHeight - 256 - 30 - 30), 200, 24); // Label Average FPS
|
||||
rectsResult[4].Set((Screen.width / 2) - 200, (Screen.height / 2) - (totalHeight - 256 - 30 - 30 - 20), 200, 24); // Label Minimum FPS
|
||||
rectsResult[6].Set((Screen.width / 2) - 200, (Screen.height / 2) - (totalHeight - 256 - 30 - 30 - 20 - 20), 200, 24); // Label Maximum FPS
|
||||
|
||||
rectsResult[3].Set((Screen.width / 2), (Screen.height / 2) - (totalHeight - 256 - 30 - 18), 65, 24); // Result Average FPS
|
||||
rectsResult[5].Set((Screen.width / 2), (Screen.height / 2) - (totalHeight - 256 - 30 - 30 - 20), 65, 24); // ReSult Minimum FPS
|
||||
rectsResult[7].Set((Screen.width / 2), (Screen.height / 2) - (totalHeight - 256 - 30 - 30 - 20 - 20), 65, 24); // Result Maximum FPS
|
||||
size = smallStyleLabel.CalcSize(instructions);
|
||||
rectsResult[9].Set((Screen.width / 2) - (size.x / 2), (Screen.height / 2) - (totalHeight - 256 - 30 - 30 - 20 - 20 - 40), size.x, size.y); // Instructions
|
||||
} //==============================================================================================================
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
headerStyle.normal.textColor = label;
|
||||
headerStyle.fontSize = 24;
|
||||
headerStyle.font = fontResult;
|
||||
headerStyle.alignment = TextAnchor.UpperCenter;
|
||||
|
||||
bigStyle.alignment = TextAnchor.UpperRight;
|
||||
bigStyle.font = fontRun;
|
||||
bigStyle.fontSize = 24;
|
||||
bigStyle.normal.textColor = Color.green;
|
||||
bigStyleShadow = new GUIStyle(bigStyle);
|
||||
bigStyleShadow.normal.textColor = fontShadow;
|
||||
|
||||
smallStyle.alignment = TextAnchor.UpperRight;
|
||||
smallStyle.font = fontRun;
|
||||
smallStyle.fontSize = 12;
|
||||
smallStyle.normal.textColor = Color.white;
|
||||
smallStyleShadow = new GUIStyle(smallStyle);
|
||||
smallStyleShadow.normal.textColor = fontShadow;
|
||||
smallStyleLabel = new GUIStyle(smallStyle);
|
||||
smallStyleLabel.normal.textColor = label;
|
||||
|
||||
Invoke("Reset", 0.5f);
|
||||
} //==============================================================================================================
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (displayType != oldDisplayType)
|
||||
{
|
||||
if (displayType == GUIType.DisplayResults)
|
||||
{
|
||||
SetRectsResult();
|
||||
colorAvg = EvaluateGradient(averageFPS);
|
||||
bigStyle.normal.textColor = colorAvg;
|
||||
avgTextGUI.text = avgFPSText;
|
||||
}
|
||||
else if (displayType == GUIType.DisplayRunning)
|
||||
{
|
||||
Reset();
|
||||
SetRectsRun();
|
||||
}
|
||||
oldDisplayType = displayType;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(showHideButton) && acceptInput && displayType != GUIType.DisplayResults)
|
||||
{
|
||||
if (displayType == GUIType.DisplayNothing) displayType = GUIType.DisplayRunning;
|
||||
else displayType = GUIType.DisplayNothing;
|
||||
}
|
||||
|
||||
if (displayType == GUIType.DisplayNothing) return;
|
||||
else if (displayType == GUIType.DisplayRunning) GetFPS();
|
||||
if (reset) { reset = false; Reset(); }
|
||||
} //==============================================================================================================
|
||||
|
||||
|
||||
public void StartBenchmark()
|
||||
{
|
||||
Reset();
|
||||
SetRectsRun();
|
||||
displayType = GUIType.DisplayRunning;
|
||||
} //==============================================================================================================
|
||||
|
||||
|
||||
public void StopBenchmark()
|
||||
{
|
||||
SetRectsResult();
|
||||
displayType = GUIType.DisplayResults;
|
||||
colorAvg = EvaluateGradient(averageFPS);
|
||||
bigStyle.normal.textColor = colorAvg;
|
||||
//R_Console.Log("---------------------------------");
|
||||
//R_Console.Log("Average FPS: " + averageFPS.ToString("F2"));
|
||||
//R_Console.Log("Mininum FPS: " + minimumFPS.ToString("F2"));
|
||||
//R_Console.Log("Maximum FPS: " + maximumFPS.ToString("F2"));
|
||||
//R_Console.Log("---------------------------------");
|
||||
} //==============================================================================================================
|
||||
|
||||
|
||||
void GetFPS()
|
||||
{
|
||||
tempFrameCount++;
|
||||
totalFrameCount++;
|
||||
|
||||
if (Time.realtimeSinceStartup - tStampTemp > interval)
|
||||
{
|
||||
currentFPS = (float)(tempFrameCount / (Time.realtimeSinceStartup - tStampTemp));
|
||||
averageFPS = (float)(totalFrameCount / (Time.realtimeSinceStartup - tStamp));
|
||||
if (currentFPS < minimumFPS) minimumFPS = currentFPS;
|
||||
if (currentFPS > maximumFPS) maximumFPS = currentFPS;
|
||||
|
||||
tStampTemp = Time.realtimeSinceStartup;
|
||||
tempFrameCount = 0;
|
||||
|
||||
currentFPSText = "FPS " + currentFPS.ToString("0.0");
|
||||
avgFPSText = averageFPS.ToString("0.0");
|
||||
minFPSText = minimumFPS.ToString("0.0");
|
||||
maxFSPText = maximumFPS.ToString("0.0");
|
||||
colorCurrent = EvaluateGradient(currentFPS);
|
||||
bigStyle.normal.textColor = colorCurrent;
|
||||
}
|
||||
} //==============================================================================================================
|
||||
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
tStamp = Time.realtimeSinceStartup;
|
||||
tStampTemp = Time.realtimeSinceStartup;
|
||||
|
||||
currentFPS = 0;
|
||||
averageFPS = 0;
|
||||
minimumFPS = 999.9f;
|
||||
maximumFPS = 0;
|
||||
|
||||
tempFrameCount = 0;
|
||||
totalFrameCount = 0;
|
||||
} //==============================================================================================================
|
||||
|
||||
|
||||
Color EvaluateGradient(float f) { return gradient.Evaluate(Mathf.Clamp01((f - gradientRange.x) / (gradientRange.y - gradientRange.x))); }
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_FPSCounter.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/MCS_FPSCounter.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e83c49ade708374995107d7992d0c66
|
||||
timeCreated: 1510142056
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
407
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Mathw.cs
vendored
Normal file
407
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Mathw.cs
vendored
Normal file
@@ -0,0 +1,407 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public struct AABB3
|
||||
{
|
||||
public Vector3 min;
|
||||
public Vector3 max;
|
||||
|
||||
public AABB3(Vector3 min, Vector3 max)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Triangle3
|
||||
{
|
||||
public Vector3 a, b, c;
|
||||
public Vector3 dirAb, dirAc, dirBc;
|
||||
public Vector3 h1;
|
||||
|
||||
public float ab, ac, bc;
|
||||
public float area, h, ah, hb;
|
||||
|
||||
public void Calc()
|
||||
{
|
||||
var _a = a;
|
||||
var _b = b;
|
||||
var _c = c;
|
||||
|
||||
var _dirAb = b - a;
|
||||
var _dirAc = c - a;
|
||||
var _dirBc = c - b;
|
||||
|
||||
float _ab = _dirAb.magnitude;
|
||||
float _ac = _dirAc.magnitude;
|
||||
float _bc = _dirBc.magnitude;
|
||||
|
||||
if (_ac > _ab && _ac > _bc)
|
||||
{
|
||||
a = _a;
|
||||
b = _c;
|
||||
c = _b;
|
||||
}
|
||||
else if (_bc > _ab)
|
||||
{
|
||||
a = _c;
|
||||
b = _b;
|
||||
c = _a;
|
||||
}
|
||||
|
||||
dirAb = b - a;
|
||||
dirAc = c - a;
|
||||
dirBc = c - b;
|
||||
|
||||
ab = dirAb.magnitude;
|
||||
ac = dirAc.magnitude;
|
||||
bc = dirBc.magnitude;
|
||||
|
||||
float s = (ab + ac + bc) * 0.5f;
|
||||
|
||||
area = Mathf.Sqrt(s * (s - ab) * (s - ac) * (s - bc));
|
||||
h = (2 * area) / ab;
|
||||
|
||||
ah = Mathf.Sqrt((ac * ac) - (h * h));
|
||||
|
||||
hb = ab - ah;
|
||||
|
||||
// Debug.Log("ab " + ab + " ac " + ac + " bc " + bc + " area " + area + " h " + h + " ah " + ah);
|
||||
|
||||
h1 = a + (dirAb * ((1 / ab) * ah));
|
||||
}
|
||||
}
|
||||
|
||||
public struct Sphere3
|
||||
{
|
||||
public Vector3 center;
|
||||
public float radius;
|
||||
|
||||
public Sphere3(Vector3 center, float radius)
|
||||
{
|
||||
this.center = center;
|
||||
this.radius = radius;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Int2
|
||||
{
|
||||
public int x, y;
|
||||
|
||||
public Int2(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Int3
|
||||
{
|
||||
public int x, y, z;
|
||||
|
||||
public Int3(int x, int y, int z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static Int3 operator +(Int3 a, Int3 b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
|
||||
static public class Mathw
|
||||
{
|
||||
static public readonly int[] bits = new int[] { 1 << 0 , 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16, 1 << 17,
|
||||
1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 22, 1 << 23, 1 << 24, 1 << 25, 1 << 26, 1 << 27, 1 << 28, 1 << 29, 1 << 30, 1 << 31};
|
||||
|
||||
static public Vector3 Clamp(Vector3 v, float min, float max)
|
||||
{
|
||||
if (v.x < min) v.x = min;
|
||||
else if (v.x > max) v.x = max;
|
||||
if (v.y < min) v.y = min;
|
||||
else if (v.y > max) v.y = max;
|
||||
if (v.z < min) v.z = min;
|
||||
else if (v.z > max) v.z = max;
|
||||
return v;
|
||||
}
|
||||
|
||||
static public Vector3 FloatToVector3(float v)
|
||||
{
|
||||
return new Vector3(v, v, v);
|
||||
}
|
||||
|
||||
static public float SinDeg(float angle)
|
||||
{
|
||||
return Mathf.Sin(angle * Mathf.Deg2Rad);// * Mathf.Rad2Deg;
|
||||
}
|
||||
|
||||
static public float GetMax(Vector3 v)
|
||||
{
|
||||
float max = v.x;
|
||||
if (v.y > max) max = v.y;
|
||||
if (v.z > max) max = v.z;
|
||||
return max;
|
||||
}
|
||||
|
||||
static public Vector3 SetMin(Vector3 v, float min)
|
||||
{
|
||||
if (v.x < min) v.x = min;
|
||||
if (v.y < min) v.y = min;
|
||||
if (v.z < min) v.z = min;
|
||||
return v;
|
||||
}
|
||||
|
||||
static public Vector3 Snap(Vector3 v, float snapSize)
|
||||
{
|
||||
v.x = Mathf.Floor(v.x / snapSize) * snapSize;
|
||||
v.y = Mathf.Floor(v.y / snapSize) * snapSize;
|
||||
v.z = Mathf.Floor(v.z / snapSize) * snapSize;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static public Vector3 Abs(Vector3 v)
|
||||
{
|
||||
return new Vector3(v.x < 0 ? -v.x : v.x, v.y < 0 ? -v.y : v.y, v.z < 0 ? -v.z : v.z);
|
||||
}
|
||||
|
||||
static public bool IntersectAABB3Sphere3(AABB3 box, Sphere3 sphere)
|
||||
{
|
||||
Vector3 center = sphere.center;
|
||||
Vector3 min = box.min;
|
||||
Vector3 max = box.max;
|
||||
float totalDistance = 0f;
|
||||
float distance;
|
||||
if (center.x < min.x)
|
||||
{
|
||||
distance = center.x - min.x;
|
||||
totalDistance += distance * distance;
|
||||
}
|
||||
else if (center.x > max.x)
|
||||
{
|
||||
distance = center.x - max.x;
|
||||
totalDistance += distance * distance;
|
||||
}
|
||||
if (center.y < min.y)
|
||||
{
|
||||
distance = center.y - min.y;
|
||||
totalDistance += distance * distance;
|
||||
}
|
||||
else if (center.y > max.y)
|
||||
{
|
||||
distance = center.y - max.y;
|
||||
totalDistance += distance * distance;
|
||||
}
|
||||
if (center.z < min.z)
|
||||
{
|
||||
distance = center.z - min.z;
|
||||
totalDistance += distance * distance;
|
||||
}
|
||||
else if (center.z > max.z)
|
||||
{
|
||||
distance = center.z - max.z;
|
||||
totalDistance += distance * distance;
|
||||
}
|
||||
return totalDistance <= sphere.radius * sphere.radius;
|
||||
}
|
||||
|
||||
static public bool IntersectAABB3Triangle3(Vector3 boxCenter, Vector3 boxHalfSize, Triangle3 triangle)
|
||||
{
|
||||
Vector3 v0, v1, v2;
|
||||
|
||||
float min, max, fex, fey, fez;
|
||||
Vector3 normal, e0, e1, e2;
|
||||
|
||||
v0 = triangle.a - boxCenter;
|
||||
v1 = triangle.b - boxCenter;
|
||||
v2 = triangle.c - boxCenter;
|
||||
|
||||
e0 = v1 - v0;
|
||||
e1 = v2 - v1;
|
||||
e2 = v0 - v2;
|
||||
|
||||
fex = Abs(e0[0]);
|
||||
fey = Abs(e0[1]);
|
||||
fez = Abs(e0[2]);
|
||||
|
||||
if (!AxisTest_X01(v0, v2, boxHalfSize, e0[2], e0[1], fez, fey, out min, out max)) return false;
|
||||
if (!AxisTest_Y02(v0, v2, boxHalfSize, e0[2], e0[0], fez, fex, out min, out max)) return false;
|
||||
if (!AxisTest_Z12(v1, v2, boxHalfSize, e0[1], e0[0], fey, fex, out min, out max)) return false;
|
||||
|
||||
fex = Abs(e1[0]);
|
||||
fey = Abs(e1[1]);
|
||||
fez = Abs(e1[2]);
|
||||
|
||||
if (!AxisTest_X01(v0, v2, boxHalfSize, e1[2], e1[1], fez, fey, out min, out max)) return false;
|
||||
if (!AxisTest_Y02(v0, v2, boxHalfSize, e1[2], e1[0], fez, fex, out min, out max)) return false;
|
||||
if (!AxisTest_Z0(v0, v1, boxHalfSize, e1[1], e1[0], fey, fex, out min, out max)) return false;
|
||||
|
||||
fex = Abs(e2[0]);
|
||||
fey = Abs(e2[1]);
|
||||
fez = Abs(e2[2]);
|
||||
|
||||
if (!AxisTest_X2(v0, v1, boxHalfSize, e2[2], e2[1], fez, fey, out min, out max)) return false;
|
||||
if (!AxisTest_Y1(v0, v1, boxHalfSize, e2[2], e2[0], fez, fex, out min, out max)) return false;
|
||||
if (!AxisTest_Z12(v1, v2, boxHalfSize, e2[1], e2[0], fey, fex, out min, out max)) return false;
|
||||
|
||||
GetMinMax(v0[0], v1[0], v2[0], out min, out max);
|
||||
|
||||
if (min > boxHalfSize[0] || max < -boxHalfSize[0]) return false;
|
||||
|
||||
GetMinMax(v0[1], v1[1], v2[1], out min, out max);
|
||||
|
||||
if (min > boxHalfSize[1] || max < -boxHalfSize[1]) return false;
|
||||
|
||||
GetMinMax(v0[2], v1[2], v2[2], out min, out max);
|
||||
|
||||
if (min > boxHalfSize[2] || max < -boxHalfSize[2]) return false;
|
||||
|
||||
normal = Vector3.Cross(e0, e1);
|
||||
if (!PlaneBoxOverlap(normal, v0, boxHalfSize)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static void GetMinMax(float x0, float x1, float x2, out float min, out float max)
|
||||
{
|
||||
min = max = x0;
|
||||
|
||||
if (x1 < min) min = x1;
|
||||
else if (x1 > max) max = x1;
|
||||
|
||||
if (x2 < min) min = x2;
|
||||
else if (x2 > max) max = x2;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool PlaneBoxOverlap(Vector3 normal, Vector3 vert, Vector3 maxBox)
|
||||
{
|
||||
float v;
|
||||
Vector3 vmin = Vector3.zero, vmax = Vector3.zero;
|
||||
|
||||
for (int i = 0; i <= 2; i++)
|
||||
{
|
||||
v = vert[i];
|
||||
|
||||
if (normal[i] > 0.0f)
|
||||
{
|
||||
vmin[i] = -maxBox[i] - v;
|
||||
vmax[i] = maxBox[i] - v;
|
||||
}
|
||||
else
|
||||
{
|
||||
vmin[i] = maxBox[i] - v;
|
||||
vmax[i] = -maxBox[i] - v;
|
||||
}
|
||||
}
|
||||
|
||||
if (Vector3.Dot(normal, vmin) > 0.0f) return false;
|
||||
if (Vector3.Dot(normal, vmax) >= 0.0f) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static float Abs(float v)
|
||||
{
|
||||
return v < 0 ? -v : v;
|
||||
}
|
||||
|
||||
/*======================== X-tests ========================*/
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool AxisTest_X01(Vector3 v0, Vector3 v2, Vector3 boxHalfSize, float a, float b, float fa, float fb, out float min, out float max)
|
||||
{
|
||||
float p0 = a * v0[1] - b * v0[2];
|
||||
float p2 = a * v2[1] - b * v2[2];
|
||||
|
||||
if (p0 < p2) { min = p0; max = p2; } else { min = p2; max = p0; }
|
||||
|
||||
float rad = fa * boxHalfSize[1] + fb * boxHalfSize[2];
|
||||
|
||||
if (min > rad || max < -rad) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool AxisTest_X2(Vector3 v0, Vector3 v1, Vector3 boxHalfSize, float a, float b, float fa, float fb, out float min, out float max)
|
||||
{
|
||||
float p0 = a * v0[1] - b * v0[2];
|
||||
float p1 = a * v1[1] - b * v1[2];
|
||||
|
||||
if (p0 < p1) { min = p0; max = p1; } else { min = p1; max = p0; }
|
||||
|
||||
float rad = fa * boxHalfSize[1] + fb * boxHalfSize[2];
|
||||
|
||||
if (min > rad || max < -rad) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================== Y-tests ========================*/
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool AxisTest_Y02(Vector3 v0, Vector3 v2, Vector3 boxHalfSize, float a, float b, float fa, float fb, out float min, out float max)
|
||||
{
|
||||
float p0 = -a * v0[0] + b * v0[2];
|
||||
float p2 = -a * v2[0] + b * v2[2];
|
||||
|
||||
if (p0 < p2) { min = p0; max = p2; } else { min = p2; max = p0; }
|
||||
|
||||
float rad = fa * boxHalfSize[0] + fb * boxHalfSize[2];
|
||||
|
||||
if (min > rad || max < -rad) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool AxisTest_Y1(Vector3 v0, Vector3 v1, Vector3 boxHalfSize, float a, float b, float fa, float fb, out float min, out float max)
|
||||
{
|
||||
float p0 = -a * v0[0] + b * v0[2];
|
||||
float p1 = -a * v1[0] + b * v1[2];
|
||||
|
||||
if (p0 < p1) { min = p0; max = p1; } else { min = p1; max = p0; }
|
||||
|
||||
float rad = fa * boxHalfSize[0] + fb * boxHalfSize[2];
|
||||
|
||||
if (min > rad || max < -rad) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================== Z-tests ========================*/
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool AxisTest_Z12(Vector3 v1, Vector3 v2, Vector3 boxHalfSize, float a, float b, float fa, float fb, out float min, out float max)
|
||||
{
|
||||
float p1 = a * v1[0] - b * v1[1];
|
||||
float p2 = a * v2[0] - b * v2[1];
|
||||
|
||||
if (p2 < p1) { min = p2; max = p1; } else { min = p1; max = p2; }
|
||||
|
||||
float rad = fa * boxHalfSize[0] + fb * boxHalfSize[1];
|
||||
|
||||
if (min > rad || max < -rad) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool AxisTest_Z0(Vector3 v0, Vector3 v1, Vector3 boxHalfSize, float a, float b, float fa, float fb, out float min, out float max)
|
||||
{
|
||||
float p0 = a * v0[0] - b * v0[1];
|
||||
float p1 = a * v1[0] - b * v1[1];
|
||||
|
||||
if (p0 < p1) { min = p0; max = p1; } else { min = p1; max = p0; }
|
||||
|
||||
float rad = fa * boxHalfSize[0] + fb * boxHalfSize[1];
|
||||
|
||||
if (min > rad || max < -rad) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Mathw.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Mathw.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7bc54856b835184b846778cd1be4c6c
|
||||
timeCreated: 1497466510
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
285
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Methods.cs
vendored
Normal file
285
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Methods.cs
vendored
Normal file
@@ -0,0 +1,285 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
static public class Methods
|
||||
{
|
||||
static public void SetTag(GameObject go, string tag)
|
||||
{
|
||||
Transform[] tArray = go.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < tArray.Length; i++) { tArray[i].tag = tag; }
|
||||
}
|
||||
|
||||
static public void SetTagWhenCollider(GameObject go, string tag)
|
||||
{
|
||||
Transform[] tArray = go.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < tArray.Length; i++)
|
||||
{
|
||||
if (tArray[i].GetComponent<Collider>() != null) tArray[i].tag = tag;
|
||||
}
|
||||
}
|
||||
|
||||
static public void SetTagAndLayer(GameObject go, string tag, int layer)
|
||||
{
|
||||
// Debug.Log("Layer " + layer);
|
||||
Transform[] tArray = go.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < tArray.Length; i++) { tArray[i].tag = tag; tArray[i].gameObject.layer = layer; }
|
||||
}
|
||||
|
||||
static public void SetLayer(GameObject go, int layer)
|
||||
{
|
||||
go.layer = layer;
|
||||
Transform[] tArray = go.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < tArray.Length; i++) tArray[i].gameObject.layer = layer;
|
||||
}
|
||||
|
||||
static public bool LayerMaskContainsLayer(int layerMask, int layer)
|
||||
{
|
||||
return ((1 << layer) & layerMask) != 0;
|
||||
}
|
||||
|
||||
static public int GetFirstLayerInLayerMask(int layerMask)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if ((layerMask & Mathw.bits[i]) != 0) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static public bool Contains(string compare, string name)
|
||||
{
|
||||
List<string> cuts = new List<string>();
|
||||
int index;
|
||||
|
||||
do
|
||||
{
|
||||
index = name.IndexOf("*");
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
if (index != 0) { cuts.Add(name.Substring(0, index)); }
|
||||
if (index != name.Length - 1) { name = name.Substring(index + 1); }
|
||||
else break;
|
||||
}
|
||||
}
|
||||
while (index != -1);
|
||||
|
||||
cuts.Add(name);
|
||||
|
||||
for (int i = 0; i < cuts.Count; i++)
|
||||
{
|
||||
//Debug.Log(cuts.items[i] +" " + compare);
|
||||
if (!compare.Contains(cuts[i])) return false;
|
||||
}
|
||||
//Debug.Log("Passed");
|
||||
return true;
|
||||
}
|
||||
|
||||
static public T[] Search<T>(GameObject parentGO = null)
|
||||
{
|
||||
GameObject[] gos = null;
|
||||
if (parentGO == null) {
|
||||
#if !UNITY_5_1 && !UNITY_5_2
|
||||
gos = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
|
||||
#endif
|
||||
}
|
||||
|
||||
else gos = new GameObject[] { parentGO };
|
||||
|
||||
if (gos == null) return null;
|
||||
|
||||
if (typeof(T) == typeof(GameObject))
|
||||
{
|
||||
List<GameObject> list = new List<GameObject>();
|
||||
for (int i = 0; i < gos.Length; i++)
|
||||
{
|
||||
Transform[] transforms = gos[i].GetComponentsInChildren<Transform>(true);
|
||||
for (int j = 0; j < transforms.Length; j++) list.Add(transforms[j].gameObject);
|
||||
}
|
||||
return list.ToArray() as T[];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parentGO == null)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
for (int i = 0; i < gos.Length; i++)
|
||||
{
|
||||
list.AddRange(gos[i].GetComponentsInChildren<T>(true));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
else return parentGO.GetComponentsInChildren<T>(true);
|
||||
}
|
||||
}
|
||||
|
||||
#if !UNITY_5
|
||||
static public FastList<GameObject> GetAllRootGameObjects()
|
||||
{
|
||||
FastList<GameObject> list = new FastList<GameObject>();
|
||||
|
||||
for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount; i++)
|
||||
{
|
||||
list.AddRange(UnityEngine.SceneManagement.SceneManager.GetSceneAt(i).GetRootGameObjects());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
#endif
|
||||
|
||||
static public T[] SearchParent<T>(GameObject parentGO, bool searchInActiveGameObjects) where T : Component
|
||||
{
|
||||
if (parentGO == null) return SearchAllScenes<T>(searchInActiveGameObjects).ToArray();
|
||||
|
||||
if (!searchInActiveGameObjects && !parentGO.activeInHierarchy) return null;
|
||||
|
||||
if (typeof(T) == typeof(GameObject))
|
||||
{
|
||||
var ts = parentGO.GetComponentsInChildren<Transform>(searchInActiveGameObjects);
|
||||
GameObject[] gos = new GameObject[ts.Length];
|
||||
for (int i = 0; i < gos.Length; i++) gos[i] = ts[i].gameObject;
|
||||
return gos as T[];
|
||||
}
|
||||
|
||||
return parentGO.GetComponentsInChildren<T>(searchInActiveGameObjects);
|
||||
}
|
||||
|
||||
#if !UNITY_5
|
||||
static public T[] SearchScene<T>(UnityEngine.SceneManagement.Scene scene, bool searchInActiveGameObjects) where T : Component
|
||||
{
|
||||
var gos = scene.GetRootGameObjects();
|
||||
|
||||
var list = new FastList<T>();
|
||||
|
||||
foreach (var go in gos) list.AddRange(SearchParent<T>(go, searchInActiveGameObjects));
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
#endif
|
||||
|
||||
static public FastList<T> SearchAllScenes<T>(bool searchInActiveGameObjects) where T : Component
|
||||
{
|
||||
var list = new FastList<T>();
|
||||
|
||||
#if !UNITY_5
|
||||
FastList<GameObject> gos = GetAllRootGameObjects();
|
||||
|
||||
for (int i = 0; i < gos.Count; i++)
|
||||
{
|
||||
var result = SearchParent<T>(gos.items[i], searchInActiveGameObjects);
|
||||
|
||||
list.AddRange(result);
|
||||
}
|
||||
#else
|
||||
list.items = GameObject.FindObjectsOfType<T>();
|
||||
list.SetCount(list.items.Length);
|
||||
|
||||
if (!searchInActiveGameObjects)
|
||||
{
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (!list.items[i].gameObject.activeInHierarchy) list.RemoveAt(i--);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static public T Find<T>(GameObject parentGO, string name) where T : UnityEngine.Component
|
||||
{
|
||||
T[] gos = SearchParent<T>(parentGO, true);
|
||||
|
||||
for (int i = 0; i < gos.Length; i++)
|
||||
{
|
||||
if (gos[i].name == name) return gos[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static public void SetCollidersActive(Collider[] colliders, bool active, string[] nameList)
|
||||
{
|
||||
for (int i = 0; i < colliders.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < nameList.Length; j++)
|
||||
{
|
||||
if (colliders[i].name.Contains(nameList[j])) colliders[i].enabled = active;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void SelectChildrenWithMeshRenderer(Transform t)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
MeshRenderer[] mrs = t.GetComponentsInChildren<MeshRenderer>();
|
||||
|
||||
GameObject[] gos = new GameObject[mrs.Length];
|
||||
|
||||
for (int i = 0; i < mrs.Length; i++) gos[i] = mrs[i].gameObject;
|
||||
|
||||
UnityEditor.Selection.objects = gos;
|
||||
#endif
|
||||
}
|
||||
|
||||
static public void DestroyChildren(Transform t)
|
||||
{
|
||||
while (t.childCount > 0)
|
||||
{
|
||||
Transform child = t.GetChild(0);
|
||||
child.parent = null;
|
||||
GameObject.DestroyImmediate(child.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
static public void Destroy(GameObject go)
|
||||
{
|
||||
if (go == null) return;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
GameObject.DestroyImmediate(go);
|
||||
#else
|
||||
GameObject.Destroy(go);
|
||||
#endif
|
||||
}
|
||||
|
||||
static public void SetChildrenActive(Transform t, bool active)
|
||||
{
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
{
|
||||
Transform child = t.GetChild(i);
|
||||
child.gameObject.SetActive(active);
|
||||
}
|
||||
}
|
||||
|
||||
static public void SnapBoundsAndPreserveArea(ref Bounds bounds, float snapSize, Vector3 offset)
|
||||
{
|
||||
Vector3 newCenter = Mathw.Snap(bounds.center, snapSize) + offset;
|
||||
bounds.size += Mathw.Abs(newCenter - bounds.center) * 2;
|
||||
bounds.center = newCenter;
|
||||
}
|
||||
|
||||
static public void ListRemoveAt<T>(List<T> list, int index)
|
||||
{
|
||||
list[index] = list[list.Count - 1];
|
||||
list.RemoveAt(list.Count - 1);
|
||||
}
|
||||
|
||||
static public void CopyComponent(Component component, GameObject target)
|
||||
{
|
||||
Type type = component.GetType();
|
||||
target.AddComponent(type);
|
||||
PropertyInfo[] propInfo = type.GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance);
|
||||
foreach (var property in propInfo)
|
||||
{
|
||||
property.SetValue(target.GetComponent(type), property.GetValue(component, null), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Methods.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/Methods.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d68ccf92729e6604aa5673d5d42a77cf
|
||||
timeCreated: 1494490213
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/ReadMe.cs
vendored
Normal file
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/ReadMe.cs
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class ReadMe : MonoBehaviour {
|
||||
|
||||
public bool buttonEdit;
|
||||
public string readme;
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/ReadMe.cs.meta
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/ReadMe.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eac827fa24e617e478912ae0761ce9f5
|
||||
timeCreated: 1511099101
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/TriangleAAB3.cs
vendored
Normal file
12
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/TriangleAAB3.cs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
static public class TriangleAAB3
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/TriangleAAB3.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/MeshCombineStudio/Scripts/Misc/TriangleAAB3.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a11984188c2c8048b2e0ee040857025
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user