基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
134
Assets/Plugins/Dreamteck/Utilities/ArrayUtility.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
namespace Dreamteck
|
||||
{
|
||||
using System;
|
||||
|
||||
public static class ArrayUtility
|
||||
{
|
||||
public static void Add<T>(ref T[] array, T item)
|
||||
{
|
||||
T[] newArray = new T[array.Length + 1];
|
||||
array.CopyTo(newArray, 0);
|
||||
newArray[newArray.Length - 1] = item;
|
||||
array = newArray;
|
||||
}
|
||||
public static bool Contains<T>(T[] array, T item)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (array[i].Equals(item)) return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static int IndexOf<T>(T[] array, T value)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (array[i].Equals(value)) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static void Insert<T>(ref T[] array, int index, T item)
|
||||
{
|
||||
T[] newArray = new T[array.Length + 1];
|
||||
for (int i = 0; i < newArray.Length; i++)
|
||||
{
|
||||
if (i < index) newArray[i] = array[i];
|
||||
else if (i > index) newArray[i] = array[i - 1];
|
||||
else newArray[i] = item;
|
||||
}
|
||||
array = newArray;
|
||||
}
|
||||
|
||||
|
||||
public static void RemoveAt<T>(ref T[] array, int index)
|
||||
{
|
||||
if (array.Length == 0) return;
|
||||
T[] newArray = new T[array.Length - 1];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (i < index) newArray[i] = array[i];
|
||||
else if (i > index) newArray[i-1] = array[i];
|
||||
}
|
||||
array = newArray;
|
||||
}
|
||||
|
||||
public static void ForEach<T>(this T[] source, Action<T> onLoop)
|
||||
{
|
||||
foreach (var item in source)
|
||||
{
|
||||
onLoop(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetLength<T>(ref T[] source, int newCount)
|
||||
{
|
||||
T[] newArray = new T[newCount];
|
||||
for (int i = 0; i < UnityEngine.Mathf.Min(newCount, source.Length); i++)
|
||||
{
|
||||
newArray[i] = source[i];
|
||||
}
|
||||
source = newArray;
|
||||
}
|
||||
|
||||
public static void ShiftLeft<T>(this T[] source, int startIndex = 0, bool loop = true)
|
||||
{
|
||||
var startItem = source[startIndex];
|
||||
for (int i = startIndex; i < source.Length-1; i++)
|
||||
{
|
||||
source[i] = source[i + 1];
|
||||
}
|
||||
source[source.Length - 1] = loop ? startItem : default;
|
||||
}
|
||||
|
||||
public static void ShiftRight<T>(this T[] source, int startIndex = 0, bool loop = true)
|
||||
{
|
||||
var startItem = source[source.Length - 1];
|
||||
for (int i = startIndex + 1; i < source.Length; i++)
|
||||
{
|
||||
source[i] = source[i - 1];
|
||||
}
|
||||
source[startIndex] = loop ? startItem : default;
|
||||
}
|
||||
|
||||
public static TArray[] QuickSort<TArray,T> (this TArray[] array, Func<TArray,T> getProperty, int leftIndex, int rightIndex) where T : IComparable
|
||||
{
|
||||
|
||||
var i = leftIndex;
|
||||
var j = rightIndex;
|
||||
var pivot = getProperty(array[leftIndex]);
|
||||
while (i <= j)
|
||||
{
|
||||
while (getProperty(array[i]).CompareTo(pivot) == -1)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
while (getProperty(array[j]).CompareTo(pivot) == 1)
|
||||
{
|
||||
j--;
|
||||
}
|
||||
if (i <= j)
|
||||
{
|
||||
var temp = array[i];
|
||||
array[i] = array[j];
|
||||
array[j] = temp;
|
||||
i++;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
if (leftIndex < j)
|
||||
QuickSort(array, getProperty, leftIndex, j);
|
||||
if (i < rightIndex)
|
||||
QuickSort(array,getProperty, i, rightIndex);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/ArrayUtility.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82febc9d0aa4907478f53a8dd5e86318
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
169
Assets/Plugins/Dreamteck/Utilities/AsyncJobSystem.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public class AsyncJobSystem : MonoBehaviour
|
||||
{
|
||||
private Queue<IJobData> _jobs = new Queue<IJobData>();
|
||||
|
||||
private IJobData _currentJob = null;
|
||||
|
||||
private bool _isWorking = false;
|
||||
|
||||
public AsyncJobOperation ScheduleJob<T>(JobData<T> data)
|
||||
{
|
||||
_jobs.Enqueue(data);
|
||||
return new AsyncJobOperation(data);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_jobs.Count > 0 && !_isWorking)
|
||||
{
|
||||
StartCoroutine(JobCoroutine());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator JobCoroutine()
|
||||
{
|
||||
_isWorking = true;
|
||||
|
||||
while (_jobs.Count > 0)
|
||||
{
|
||||
_currentJob = _jobs.Dequeue();
|
||||
_currentJob.Initialize();
|
||||
|
||||
while (!_currentJob.done)
|
||||
{
|
||||
_currentJob.Next();
|
||||
yield return null;
|
||||
}
|
||||
|
||||
_currentJob.Complete();
|
||||
_currentJob = null;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
_isWorking = false;
|
||||
}
|
||||
|
||||
|
||||
public class AsyncJobOperation : CustomYieldInstruction
|
||||
{
|
||||
private IJobData _job;
|
||||
|
||||
public AsyncJobOperation(IJobData job)
|
||||
{
|
||||
_job = job;
|
||||
}
|
||||
|
||||
public override bool keepWaiting {
|
||||
get { return !_job.done; }
|
||||
}
|
||||
}
|
||||
|
||||
public interface IJobData
|
||||
{
|
||||
bool done { get; }
|
||||
|
||||
void Initialize();
|
||||
|
||||
void Next();
|
||||
|
||||
void Complete();
|
||||
}
|
||||
|
||||
public class JobData<T> : IJobData
|
||||
{
|
||||
private int _index;
|
||||
|
||||
private int _iterations = 0;
|
||||
|
||||
private IEnumerable<T> _collection;
|
||||
|
||||
private Action<JobData<T>> _onComplete;
|
||||
|
||||
private Action<JobData<T>> _onIteration;
|
||||
|
||||
private IEnumerator<T> _enumerator;
|
||||
|
||||
public T current { get { return _enumerator.Current; } }
|
||||
|
||||
public int index { get { return _index; } }
|
||||
|
||||
public IEnumerable<T> collection { get { return _collection; } }
|
||||
|
||||
public bool done { get; private set; }
|
||||
|
||||
public JobData(IEnumerable<T> collection, int iterations, Action<JobData<T>> onIteration)
|
||||
{
|
||||
_collection = collection;
|
||||
_onIteration = onIteration;
|
||||
_iterations = iterations;
|
||||
done = false;
|
||||
}
|
||||
|
||||
public JobData(IEnumerable<T> collection, int iterations, Action<JobData<T>> onIteration, Action<JobData<T>> onComplete) :
|
||||
this(collection, iterations, onIteration)
|
||||
{
|
||||
_onComplete = onComplete;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_enumerator = _collection.GetEnumerator();
|
||||
_index = -1;
|
||||
done = !_enumerator.MoveNext();
|
||||
}
|
||||
|
||||
public void Complete()
|
||||
{
|
||||
_enumerator.Dispose();
|
||||
|
||||
try
|
||||
{
|
||||
if (_onComplete != null) {
|
||||
_onComplete(this);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void Next()
|
||||
{
|
||||
int counter = _iterations;
|
||||
|
||||
if (done)
|
||||
{
|
||||
return;
|
||||
}
|
||||
do
|
||||
{
|
||||
_index++;
|
||||
|
||||
try
|
||||
{
|
||||
if(_onIteration != null)
|
||||
{
|
||||
_onIteration(this);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
done = !_enumerator.MoveNext();
|
||||
}
|
||||
while (!done && --counter > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/AsyncJobSystem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5b5fc53001826741b2918682cb3c804
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/Plugins/Dreamteck/Utilities/DMath.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public static class DMath
|
||||
{
|
||||
public static double Sin(double a)
|
||||
{
|
||||
return Math.Sin(a);
|
||||
}
|
||||
|
||||
public static double Cos(double a)
|
||||
{
|
||||
return Math.Cos(a);
|
||||
}
|
||||
|
||||
public static double Tan(double a)
|
||||
{
|
||||
return Math.Tan(a);
|
||||
}
|
||||
|
||||
public static double Pow(double x, double y)
|
||||
{
|
||||
return Math.Pow(x, y);
|
||||
}
|
||||
|
||||
public static double Log(double a, double newBase)
|
||||
{
|
||||
return Math.Log(a, newBase);
|
||||
}
|
||||
|
||||
public static double Log10(double a)
|
||||
{
|
||||
return Math.Log10(a);
|
||||
}
|
||||
|
||||
public static double Clamp01(double a)
|
||||
{
|
||||
if (a > 1.0) return 1.0;
|
||||
if (a < 0.0) return 0.0;
|
||||
return a;
|
||||
}
|
||||
|
||||
public static double Clamp(double a, double min, double max)
|
||||
{
|
||||
if (a > max) return max;
|
||||
if (a < min) return min;
|
||||
return a;
|
||||
}
|
||||
|
||||
public static double Lerp(double a, double b, double t)
|
||||
{
|
||||
t = Clamp01(t);
|
||||
return a + (b - a) * t;
|
||||
}
|
||||
|
||||
public static double InverseLerp(double a, double b, double t)
|
||||
{
|
||||
if (a == b) return 0.0;
|
||||
return Clamp01((t-a)/(b-a));
|
||||
}
|
||||
|
||||
public static void LerpVector3NonAlloc(Vector3 a, Vector3 b, double t, ref Vector3 target)
|
||||
{
|
||||
t = Clamp01(t);
|
||||
Vector3 delta = (b - a);
|
||||
target.x = (float)(a.x + delta.x * t);
|
||||
target.y = (float)(a.y + delta.y * t);
|
||||
target.z = (float)(a.z + delta.z * t);
|
||||
}
|
||||
|
||||
public static Vector3 LerpVector3(Vector3 a, Vector3 b, double t)
|
||||
{
|
||||
Vector3 result = Vector3.zero;
|
||||
LerpVector3NonAlloc(a, b, t, ref result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double Round(double a)
|
||||
{
|
||||
return Math.Round(a);
|
||||
}
|
||||
|
||||
public static int RoundInt(double a)
|
||||
{
|
||||
return (int)Math.Round(a);
|
||||
}
|
||||
|
||||
public static double Ceil(double a)
|
||||
{
|
||||
return Math.Ceiling(a);
|
||||
}
|
||||
|
||||
public static int CeilInt(double a)
|
||||
{
|
||||
return (int)Math.Ceiling(a);
|
||||
}
|
||||
|
||||
public static double Floor(double a)
|
||||
{
|
||||
return Math.Floor(a);
|
||||
}
|
||||
|
||||
public static int FloorInt(double a)
|
||||
{
|
||||
return (int)Math.Floor(a);
|
||||
}
|
||||
|
||||
public static double Move(double current, double target, double amount)
|
||||
{
|
||||
if (target > current)
|
||||
{
|
||||
current += amount;
|
||||
if (current > target) return target;
|
||||
}
|
||||
else
|
||||
{
|
||||
current -= amount;
|
||||
if (current < target) return target;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
public static double Abs(double a)
|
||||
{
|
||||
if (a < 0.0) return a * -1.0;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Plugins/Dreamteck/Utilities/DMath.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 012b8f43a890d8248b810901033c66a3
|
||||
timeCreated: 1460233822
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Dreamteck.Utilities",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcf26afa24f209f48995057e40e2e83e
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Plugins/Dreamteck/Utilities/DuplicateUtility.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public static class DuplicateUtility
|
||||
{
|
||||
public static AnimationCurve DuplicateCurve(AnimationCurve input)
|
||||
{
|
||||
AnimationCurve target = new AnimationCurve();
|
||||
target.postWrapMode = input.postWrapMode;
|
||||
target.preWrapMode = input.preWrapMode;
|
||||
for (int i = 0; i < input.keys.Length; i++) target.AddKey(input.keys[i]);
|
||||
return target;
|
||||
}
|
||||
|
||||
public static Gradient DuplicateGradient(Gradient input)
|
||||
{
|
||||
//yet to implement
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/DuplicateUtility.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a72578399b94604b8ad3f608ef130ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Plugins/Dreamteck/Utilities/Editor.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 749c0646beaeed74da9787854fe67f79
|
||||
folderAsset: yes
|
||||
timeCreated: 1522397143
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Dreamteck.Utilities.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1858e8552db82d4dabda17b0cadb7dd
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
170
Assets/Plugins/Dreamteck/Utilities/Editor/DreamteckEditorGUI.cs
Normal file
@@ -0,0 +1,170 @@
|
||||
namespace Dreamteck
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class DreamteckEditorGUI
|
||||
{
|
||||
public static Texture2D blankImage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_blankImage == null)
|
||||
{
|
||||
_blankImage = new Texture2D(1, 1);
|
||||
_blankImage.SetPixel(0, 0, Color.white);
|
||||
_blankImage.Apply();
|
||||
}
|
||||
return _blankImage;
|
||||
}
|
||||
}
|
||||
private static Texture2D _blankImage = null;
|
||||
|
||||
public static readonly Color backgroundColor = new Color(0.95f, 0.95f, 0.95f);
|
||||
public static Color iconColor = Color.black;
|
||||
|
||||
public static readonly Color highlightColor = new Color(0f, 0.564f, 1f, 1f);
|
||||
public static readonly Color highlightContentColor = new Color(1f, 1f, 1f, 0.95f);
|
||||
|
||||
|
||||
public static readonly Color inactiveColor = new Color(0.7f, 0.7f, 0.7f, 0.5f);
|
||||
public static readonly Color activeColor = new Color(1f, 1f, 1f, 1f);
|
||||
|
||||
public static readonly Color baseColor = Color.white;
|
||||
public static readonly Color lightColor = Color.white;
|
||||
public static readonly Color lightDarkColor = Color.white;
|
||||
public static readonly Color darkColor = Color.white;
|
||||
public static readonly Color borderColor = Color.white;
|
||||
|
||||
private static List<int> layerNumbers = new List<int>();
|
||||
|
||||
public static readonly GUIStyle labelText = null;
|
||||
private static float scale = -1f;
|
||||
|
||||
static DreamteckEditorGUI()
|
||||
{
|
||||
baseColor = EditorGUIUtility.isProSkin ? new Color32(56, 56, 56, 255) : new Color32(194, 194, 194, 255);
|
||||
lightColor = EditorGUIUtility.isProSkin ? new Color32(84, 84, 84, 255) : new Color32(222, 222, 222, 255);
|
||||
lightDarkColor = EditorGUIUtility.isProSkin ? new Color32(30, 30, 30, 255) : new Color32(180, 180, 180, 255);
|
||||
darkColor = EditorGUIUtility.isProSkin ? new Color32(15, 15, 15, 255) : new Color32(152, 152, 152, 255);
|
||||
borderColor = EditorGUIUtility.isProSkin ? new Color32(5, 5, 5, 255) : new Color32(100, 100, 100, 255);
|
||||
backgroundColor = baseColor;
|
||||
backgroundColor -= new Color(0.1f, 0.1f, 0.1f, 0f);
|
||||
iconColor = GUI.skin.label.normal.textColor;
|
||||
|
||||
labelText = new GUIStyle(GUI.skin.GetStyle("label"));
|
||||
labelText.fontStyle = FontStyle.Bold;
|
||||
labelText.alignment = TextAnchor.MiddleRight;
|
||||
labelText.normal.textColor = Color.white;
|
||||
SetScale(1f);
|
||||
}
|
||||
|
||||
public static void SetScale(float newScale)
|
||||
{
|
||||
if (scale == newScale) return;
|
||||
scale = newScale;
|
||||
labelText.fontSize = Mathf.RoundToInt(12f * scale);
|
||||
}
|
||||
|
||||
public static void Label(Rect position, string text, bool active = true, GUIStyle style = null)
|
||||
{
|
||||
if (style == null) style = labelText;
|
||||
if (!active) GUI.color = inactiveColor;
|
||||
else GUI.color = activeColor;
|
||||
GUI.color = new Color(0f, 0f, 0f, GUI.color.a * 0.5f);
|
||||
GUI.Label(new Rect(position.x - 1, position.y + 1, position.width, position.height), text, style);
|
||||
if (!active) GUI.color = inactiveColor;
|
||||
else GUI.color = activeColor;
|
||||
GUI.Label(position, text, style);
|
||||
}
|
||||
|
||||
public static LayerMask LayermaskField(string label, LayerMask layerMask)
|
||||
{
|
||||
string[] layers = UnityEditorInternal.InternalEditorUtility.layers;
|
||||
|
||||
layerNumbers.Clear();
|
||||
|
||||
for (int i = 0; i < layers.Length; i++)
|
||||
{
|
||||
layerNumbers.Add(LayerMask.NameToLayer(layers[i]));
|
||||
}
|
||||
|
||||
int maskWithoutEmpty = 0;
|
||||
for (int i = 0; i < layerNumbers.Count; i++)
|
||||
{
|
||||
if (((1 << layerNumbers[i]) & layerMask.value) > 0)
|
||||
{
|
||||
maskWithoutEmpty |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
maskWithoutEmpty = EditorGUILayout.MaskField(label, maskWithoutEmpty, layers);
|
||||
|
||||
int mask = 0;
|
||||
for (int i = 0; i < layerNumbers.Count; i++)
|
||||
{
|
||||
if ((maskWithoutEmpty & (1 << i)) > 0)
|
||||
{
|
||||
mask |= (1 << layerNumbers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
layerMask.value = mask;
|
||||
|
||||
return layerMask;
|
||||
}
|
||||
|
||||
public static bool DropArea<T>(Rect rect, out T[] content, bool acceptProjectAssets = false)
|
||||
{
|
||||
content = new T[0];
|
||||
switch (Event.current.type)
|
||||
{
|
||||
case EventType.DragUpdated:
|
||||
case EventType.DragPerform:
|
||||
if (!rect.Contains(Event.current.mousePosition)) return false;
|
||||
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
|
||||
|
||||
if (Event.current.type == EventType.DragPerform)
|
||||
{
|
||||
DragAndDrop.AcceptDrag();
|
||||
List<T> contentList = new List<T>();
|
||||
foreach (object dragged_object in DragAndDrop.objectReferences)
|
||||
{
|
||||
if (dragged_object is GameObject)
|
||||
{
|
||||
GameObject gameObject = (GameObject)dragged_object;
|
||||
if (acceptProjectAssets || !AssetDatabase.Contains(gameObject))
|
||||
{
|
||||
if (gameObject.GetComponent<T>() != null) contentList.Add(gameObject.GetComponent<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
content = contentList.ToArray();
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static Gradient GradientField(string label, Gradient gradient, params GUILayoutOption[] options)
|
||||
{
|
||||
return EditorGUILayout.GradientField(label, gradient, options);
|
||||
}
|
||||
|
||||
public static void DrawSeparator()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
Rect rect = GUILayoutUtility.GetRect(Screen.width / 2f, 2f);
|
||||
EditorGUI.DrawRect(rect, darkColor);
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee0eafe76311d094680308d7a6735a26
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Assets/Plugins/Dreamteck/Utilities/Editor/EditorGUIEvents.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public class EditorGUIEvents
|
||||
{
|
||||
public bool mouseLeft = false;
|
||||
public bool mouseRight = false;
|
||||
public bool mouseLeftDown = false;
|
||||
public bool mouseRightDown = false;
|
||||
public bool mouseLeftUp = false;
|
||||
public bool mouseRightUp = false;
|
||||
public bool control = false;
|
||||
public bool shift = false;
|
||||
public bool alt = false;
|
||||
public bool enterDown = false;
|
||||
public bool v = false;
|
||||
public Vector2 mousPos = Vector2.zero;
|
||||
public Vector2 lastClickPoint = Vector2.zero;
|
||||
public Vector2 mouseClickDelta
|
||||
{
|
||||
get
|
||||
{
|
||||
return Event.current.mousePosition - lastClickPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void CommandHandler(string command);
|
||||
public delegate void KeyCodeHandler(KeyCode code);
|
||||
public delegate void MouseHandler(int button);
|
||||
public delegate void EmptyHandler();
|
||||
|
||||
public event CommandHandler onCommand;
|
||||
public event KeyCodeHandler onkeyDown;
|
||||
public event KeyCodeHandler onKeyUp;
|
||||
public event MouseHandler onMouseDown;
|
||||
public event MouseHandler onMouseUp;
|
||||
|
||||
public void Use()
|
||||
{
|
||||
mouseLeft = false;
|
||||
mouseRight = false;
|
||||
mouseLeftDown = false;
|
||||
mouseRightDown = false;
|
||||
mouseLeftUp = false;
|
||||
mouseRightUp = false;
|
||||
control = false;
|
||||
shift = false;
|
||||
alt = false;
|
||||
Event.current.Use();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
ListenInput(Event.current);
|
||||
}
|
||||
|
||||
public void Update(Event current)
|
||||
{
|
||||
ListenInput(current);
|
||||
}
|
||||
|
||||
void ListenInput(Event e)
|
||||
{
|
||||
//int controlID = GUIUtility.GetControlID(FocusType.Passive);
|
||||
mousPos = e.mousePosition;
|
||||
mouseLeftDown = mouseLeftUp = mouseRightDown = mouseRightUp = false;
|
||||
control = e.control;
|
||||
shift = e.shift;
|
||||
alt = e.alt;
|
||||
enterDown = false;
|
||||
switch (e.type)
|
||||
{
|
||||
case EventType.MouseDown:
|
||||
if (e.button == 0)
|
||||
{
|
||||
mouseLeftDown = true;
|
||||
mouseLeft = true;
|
||||
lastClickPoint = e.mousePosition;
|
||||
}
|
||||
if (e.button == 1) mouseRightDown = mouseRight = true;
|
||||
if (onMouseDown != null) onMouseDown(e.button);
|
||||
break;
|
||||
case EventType.MouseUp:
|
||||
if (e.button == 0)
|
||||
{
|
||||
mouseLeftUp = true;
|
||||
mouseLeft = false;
|
||||
}
|
||||
if (e.button == 1)
|
||||
{
|
||||
mouseRightDown = true;
|
||||
mouseRight = false;
|
||||
}
|
||||
if (onMouseUp != null) onMouseUp(e.button);
|
||||
break;
|
||||
|
||||
case EventType.KeyDown:
|
||||
if (onkeyDown != null) onkeyDown(e.keyCode);
|
||||
if (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter) enterDown = true;
|
||||
if (e.keyCode == KeyCode.V) v = true;
|
||||
break;
|
||||
|
||||
case EventType.KeyUp:
|
||||
if (onKeyUp != null) onKeyUp(e.keyCode);
|
||||
if (e.keyCode == KeyCode.V) v = false;
|
||||
break;
|
||||
}
|
||||
if (onCommand != null && e.commandName != "") onCommand(e.commandName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15a36dd80a7895246ae6870b7124a571
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
namespace Dreamteck
|
||||
{
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
public static class FindDerivedClasses
|
||||
{
|
||||
public static List<Type> GetAllDerivedClasses(this Type aBaseClass, string[] aExcludeAssemblies)
|
||||
{
|
||||
List<Type> result = new List<Type>();
|
||||
foreach (Assembly A in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
bool exclude = false;
|
||||
foreach (string S in aExcludeAssemblies)
|
||||
{
|
||||
if (A.GetName().FullName.StartsWith(S))
|
||||
{
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (exclude)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (aBaseClass.IsInterface)
|
||||
{
|
||||
foreach (Type C in A.GetExportedTypes())
|
||||
{
|
||||
foreach (Type I in C.GetInterfaces())
|
||||
{
|
||||
if (aBaseClass == I)
|
||||
{
|
||||
result.Add(C);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Type C in A.GetExportedTypes())
|
||||
{
|
||||
if (C.IsSubclassOf(aBaseClass))
|
||||
{
|
||||
result.Add(C);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch
|
||||
{
|
||||
Debug.LogWarning("Dreamteck was unable to scan " + A.FullName + " for derived classes");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<Type> GetAllDerivedClasses(this Type aBaseClass)
|
||||
{
|
||||
return GetAllDerivedClasses(aBaseClass, new string[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12a29dbe4d6c3f648aae86fce0402487
|
||||
timeCreated: 1450553632
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Plugins/Dreamteck/Utilities/Editor/Images.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa46a23fd0180d240bea350783ff82b5
|
||||
folderAsset: yes
|
||||
timeCreated: 1522493680
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/changelog.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,107 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 703957d2518de2c47a715a045b142ec6
|
||||
timeCreated: 1522535496
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/discord.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,107 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca2ec96e04914514ca532b6d55c85db4
|
||||
timeCreated: 1522493758
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/examples.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,107 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efab8674905315440a387b05c0ce5ff4
|
||||
timeCreated: 1522534229
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/get_started.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,107 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af24004f75afd39469d2be2087678650
|
||||
timeCreated: 1522495632
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/manual.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
112
Assets/Plugins/Dreamteck/Utilities/Editor/Images/manual.png.meta
Normal file
@@ -0,0 +1,112 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7004b4ab0ebf5ea43bd227e21913ba75
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/pdf.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,59 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3cd14c6e15dcfdb41b9a79ef8554198d
|
||||
timeCreated: 1477254890
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
linearTexture: 1
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 7
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/playmaker.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,107 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ad88cea831f74448b8fbce9f906c4ae
|
||||
timeCreated: 1522495786
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/rate.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,59 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d408c4aeee3cf742a05436998ade025
|
||||
timeCreated: 1477248547
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
linearTexture: 1
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 7
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/support.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,59 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 645a8bd65986fe24d863511d1d8ddc60
|
||||
timeCreated: 1477247161
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
linearTexture: 1
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 7
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/tmpro.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
122
Assets/Plugins/Dreamteck/Utilities/Editor/Images/tmpro.png.meta
Normal file
@@ -0,0 +1,122 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46f43b30b6801ed4d85d58179e7ab3b0
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/tutorials.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,112 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c2813fa4a97ab442b80f29592282375
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/Dreamteck/Utilities/Editor/Images/youtube.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,107 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a25750cc3c734140b2fd9dac637a8b3
|
||||
timeCreated: 1522495055
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
199
Assets/Plugins/Dreamteck/Utilities/Editor/ModuleInstaller.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
namespace Dreamteck.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
|
||||
public class ModuleInstaller
|
||||
{
|
||||
protected const string DREAMTECK_FOLDER_NAME = "Dreamteck";
|
||||
|
||||
/// <summary>
|
||||
/// Local directory within the Dreamteck folder of the unitypackage
|
||||
/// </summary>
|
||||
private string _packageDirectory = "";
|
||||
private string _packageName = "";
|
||||
private List<string> _scriptingDefines = new List<string>();
|
||||
private List<string> _uninstallDirectories = new List<string>();
|
||||
private Dictionary<string, List<string>> _assemblyLinks = new Dictionary<string, List<string>>();
|
||||
|
||||
public ModuleInstaller(string packageDirectory, string packageName)
|
||||
{
|
||||
_packageDirectory = packageDirectory;
|
||||
_packageName = packageName;
|
||||
}
|
||||
|
||||
public void AddAssemblyLink(string dreamteckAssemblyDirectory, string dreamteckAssemblyName, string addedAssemblyName)
|
||||
{
|
||||
string localFilePath = Path.Combine(DREAMTECK_FOLDER_NAME, dreamteckAssemblyDirectory, dreamteckAssemblyName + ".asmdef");
|
||||
if (_assemblyLinks.ContainsKey(localFilePath))
|
||||
{
|
||||
_assemblyLinks[localFilePath].Add(addedAssemblyName);
|
||||
} else
|
||||
{
|
||||
_assemblyLinks.Add(localFilePath, new List<string>(new string[] { addedAssemblyName }));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddUninstallDirectory(string dreamteckLocalDirectory)
|
||||
{
|
||||
if (!_uninstallDirectories.Contains(dreamteckLocalDirectory))
|
||||
{
|
||||
_uninstallDirectories.Add(dreamteckLocalDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddScriptingDefine(string define)
|
||||
{
|
||||
if (!_scriptingDefines.Contains(define))
|
||||
{
|
||||
_scriptingDefines.Add(define);
|
||||
}
|
||||
}
|
||||
|
||||
public void Install()
|
||||
{
|
||||
string globalPath = ResourceUtility.FindFolder(Application.dataPath, DREAMTECK_FOLDER_NAME + "/" + _packageDirectory);
|
||||
if (!Directory.Exists(globalPath))
|
||||
{
|
||||
EditorUtility.DisplayDialog("Missing Package", "Package directory not found: " + _packageDirectory, "OK");
|
||||
return;
|
||||
}
|
||||
globalPath = Path.Combine(globalPath, _packageName + ".unitypackage");
|
||||
if (!File.Exists(globalPath))
|
||||
{
|
||||
EditorUtility.DisplayDialog("Missing Package", "Package file not found: " + _packageDirectory, "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var key in _assemblyLinks.Keys)
|
||||
{
|
||||
for (int i = 0; i < _assemblyLinks[key].Count; i++)
|
||||
{
|
||||
AddAssemblyReference(key, _assemblyLinks[key][i]);
|
||||
}
|
||||
}
|
||||
|
||||
AssetDatabase.ImportPackage(globalPath, false);
|
||||
EditorUtility.DisplayDialog("Import Complete", _packageName + " is now installed.", "OK");
|
||||
for (int i = 0; i < _scriptingDefines.Count; i++)
|
||||
{
|
||||
ScriptingDefineUtility.Add(_scriptingDefines[i], EditorUserBuildSettings.selectedBuildTargetGroup, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
string dialogText = "The assets in the following folders will be removed: \n";
|
||||
for (int i = 0; i < _uninstallDirectories.Count; i++)
|
||||
{
|
||||
dialogText += _uninstallDirectories[i] + "\n";
|
||||
}
|
||||
bool result = EditorUtility.DisplayDialog("Uninstalling", dialogText, "OK", "Cancel");
|
||||
if (!result) return;
|
||||
|
||||
for (int i = 0; i < _uninstallDirectories.Count; i++)
|
||||
{
|
||||
string globalPath = ResourceUtility.FindFolder(Application.dataPath, DREAMTECK_FOLDER_NAME + "/" + _uninstallDirectories[i]);
|
||||
string relativePath = "Assets" + globalPath.Substring(Application.dataPath.Length);
|
||||
Debug.Log("Uninstalling " + relativePath);
|
||||
AssetDatabase.DeleteAsset(relativePath);
|
||||
}
|
||||
|
||||
foreach (var key in _assemblyLinks.Keys)
|
||||
{
|
||||
for (int i = 0; i < _assemblyLinks[key].Count; i++)
|
||||
{
|
||||
RemoveAssemblyReference(key, _assemblyLinks[key][i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < _scriptingDefines.Count; i++)
|
||||
{
|
||||
ScriptingDefineUtility.Remove(_scriptingDefines[i], EditorUserBuildSettings.selectedBuildTargetGroup, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddAssemblyReference(string dreamteckAssemblyPath, string addedAssemblyName)
|
||||
{
|
||||
var path = Path.Combine(Application.dataPath, dreamteckAssemblyPath);
|
||||
var data = "";
|
||||
using (var reader = new StreamReader(path))
|
||||
{
|
||||
data = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
var asmDef = AssemblyDefinition.CreateFromJSON(data);
|
||||
foreach (var reference in asmDef.references)
|
||||
{
|
||||
if (reference == addedAssemblyName) return;
|
||||
}
|
||||
|
||||
ArrayUtility.Add(ref asmDef.references, addedAssemblyName);
|
||||
Debug.Log("Adding " + addedAssemblyName + " to assembly " + dreamteckAssemblyPath);
|
||||
using (var writer = new StreamWriter(path, false))
|
||||
{
|
||||
writer.Write(asmDef.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void RemoveAssemblyReference(string dreamteckAssemblyPath, string addedAssemblyName)
|
||||
{
|
||||
var path = Path.Combine(Application.dataPath, dreamteckAssemblyPath);
|
||||
var data = "";
|
||||
using (var reader = new StreamReader(path))
|
||||
{
|
||||
data = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
var asmDef = AssemblyDefinition.CreateFromJSON(data);
|
||||
bool contains = false;
|
||||
foreach (var reference in asmDef.references)
|
||||
{
|
||||
if (reference != addedAssemblyName) continue;
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
if (!contains) return;
|
||||
|
||||
ArrayUtility.Remove(ref asmDef.references, addedAssemblyName);
|
||||
Debug.Log("Removing " + addedAssemblyName + " from assembly " + dreamteckAssemblyPath);
|
||||
using (var writer = new StreamWriter(path, false))
|
||||
{
|
||||
writer.Write(asmDef.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct AssemblyDefinition
|
||||
{
|
||||
public string name;
|
||||
public string rootNamespace;
|
||||
public string[] references;
|
||||
public string[] includePlatforms;
|
||||
public string[] exludePlatforms;
|
||||
public bool allowUnsafeCode;
|
||||
public bool overrideReferences;
|
||||
public string precompiledReferences;
|
||||
public bool autoReferenced;
|
||||
public string[] defineConstraints;
|
||||
public string[] versionDefines;
|
||||
public bool noEngineReferences;
|
||||
|
||||
public static AssemblyDefinition CreateFromJSON(string json)
|
||||
{
|
||||
return JsonUtility.FromJson<AssemblyDefinition>(json);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonUtility.ToJson(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1655cfc85dfb3d48a70c4544adfbfcf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e9dc735344bf0e43ba98718f54e0656
|
||||
timeCreated: 1458246009
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Dreamteck.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public static class ScriptingDefineUtility
|
||||
{
|
||||
public static void Add(string define, BuildTargetGroup target, bool log = false)
|
||||
{
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(target);
|
||||
if (definesString.Contains(define)) return;
|
||||
string[] allDefines = definesString.Split(';');
|
||||
ArrayUtility.Add(ref allDefines, define);
|
||||
definesString = string.Join(";", allDefines);
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(target, definesString);
|
||||
Debug.Log("Added \"" + define + "\" from " + EditorUserBuildSettings.selectedBuildTargetGroup + " Scripting define in Player Settings");
|
||||
}
|
||||
|
||||
public static void Remove(string define, BuildTargetGroup target, bool log = false)
|
||||
{
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(target);
|
||||
if (!definesString.Contains(define)) return;
|
||||
string[] allDefines = definesString.Split(';');
|
||||
ArrayUtility.Remove(ref allDefines, define);
|
||||
definesString = string.Join(";", allDefines);
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(target, definesString);
|
||||
Debug.Log("Removed \""+ define + "\" from " + EditorUserBuildSettings.selectedBuildTargetGroup + " Scripting define in Player Settings");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22ded5f1b11037c4aa36ec0f0e85c71e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/Plugins/Dreamteck/Utilities/Editor/Toolbar.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
namespace Dreamteck.Editor
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class Toolbar
|
||||
{
|
||||
GUIContent[] shownContent;
|
||||
GUIContent[] allContent;
|
||||
public bool center = true;
|
||||
public bool newLine = true;
|
||||
public float elementWidth = 0f;
|
||||
public float elementHeight = 23f;
|
||||
|
||||
public Toolbar(GUIContent[] iconsNormal, GUIContent[] iconsSelected, float elementWidth = 0f)
|
||||
{
|
||||
this.elementWidth = elementWidth;
|
||||
if(iconsNormal.Length != iconsSelected.Length)
|
||||
{
|
||||
Debug.LogError("Invalid icon count for toolbar ");
|
||||
return;
|
||||
}
|
||||
allContent = new GUIContent[iconsNormal.Length * 2];
|
||||
shownContent = new GUIContent[iconsNormal.Length];
|
||||
iconsNormal.CopyTo(allContent, 0);
|
||||
iconsSelected.CopyTo(allContent, iconsNormal.Length);
|
||||
}
|
||||
|
||||
public Toolbar(GUIContent[] contents, float elementWidth = 0f)
|
||||
{
|
||||
this.elementWidth = elementWidth;
|
||||
allContent = new GUIContent[contents.Length * 2];
|
||||
shownContent = new GUIContent[contents.Length];
|
||||
contents.CopyTo(allContent, 0);
|
||||
contents.CopyTo(allContent, contents.Length);
|
||||
}
|
||||
|
||||
public void SetContent(int index, GUIContent content)
|
||||
{
|
||||
allContent[index] = content;
|
||||
allContent[shownContent.Length + index] = content;
|
||||
}
|
||||
|
||||
public void SetContent(int index, GUIContent content, GUIContent contentSelected)
|
||||
{
|
||||
allContent[index] = content;
|
||||
allContent[shownContent.Length + index] = contentSelected;
|
||||
}
|
||||
|
||||
public void Draw(ref int selected)
|
||||
{
|
||||
for (int i = 0; i < shownContent.Length; i++)
|
||||
{
|
||||
shownContent[i] = selected == i ? allContent[shownContent.Length + i] : allContent[i];
|
||||
}
|
||||
if(newLine) EditorGUILayout.BeginHorizontal();
|
||||
if(center) GUILayout.FlexibleSpace();
|
||||
if(elementWidth > 0f) selected = GUILayout.Toolbar(selected, shownContent, GUILayout.Width(elementWidth * shownContent.Length), GUILayout.Height(elementHeight));
|
||||
else selected = GUILayout.Toolbar(selected, shownContent, GUILayout.Height(elementHeight));
|
||||
if (center) GUILayout.FlexibleSpace();
|
||||
if (newLine) EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/Editor/Toolbar.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9993d76bca1dcd47a94ad14a6eaf2f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
555
Assets/Plugins/Dreamteck/Utilities/Editor/WelcomeWindow.cs
Normal file
@@ -0,0 +1,555 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public class WelcomeWindow : EditorWindow
|
||||
{
|
||||
public delegate void EmptyHandler();
|
||||
protected WindowPanel[] panels = new WindowPanel[0];
|
||||
protected Texture2D header;
|
||||
protected static GUIStyle wrapText;
|
||||
protected static GUIStyle buttonTitleText;
|
||||
protected static GUIStyle warningText;
|
||||
protected static GUIStyle titleText;
|
||||
protected bool _hasSentImageRequest;
|
||||
protected List<UnityWebRequest> _textureWebRequests;
|
||||
protected Data _bannerData;
|
||||
protected string headerTitle = "";
|
||||
private static bool init = true;
|
||||
protected virtual Vector2 _windowSize => new Vector2(450, 500);
|
||||
|
||||
public virtual void Load()
|
||||
{
|
||||
minSize = maxSize = _windowSize;
|
||||
buttonTitleText = new GUIStyle(GUI.skin.GetStyle("label"));
|
||||
buttonTitleText.fontStyle = FontStyle.Bold;
|
||||
titleText = new GUIStyle(GUI.skin.GetStyle("label"));
|
||||
titleText.fontSize = 25;
|
||||
titleText.fontStyle = FontStyle.Bold;
|
||||
titleText.alignment = TextAnchor.MiddleLeft;
|
||||
titleText.normal.textColor = Color.white;
|
||||
warningText = new GUIStyle(GUI.skin.GetStyle("label"));
|
||||
warningText.fontSize = 18;
|
||||
warningText.fontStyle = FontStyle.Bold;
|
||||
warningText.normal.textColor = Color.red;
|
||||
warningText.alignment = TextAnchor.MiddleCenter;
|
||||
wrapText = new GUIStyle(GUI.skin.GetStyle("label"));
|
||||
wrapText.wordWrap = true;
|
||||
init = false;
|
||||
}
|
||||
|
||||
protected virtual void SetTitle(string titleBar, string header)
|
||||
{
|
||||
titleContent = new GUIContent(titleBar);
|
||||
headerTitle = header;
|
||||
}
|
||||
|
||||
protected virtual void GetHeader()
|
||||
{
|
||||
header = null;
|
||||
}
|
||||
|
||||
protected void OnEnable()
|
||||
{
|
||||
init = true;
|
||||
}
|
||||
|
||||
protected void OnGUI()
|
||||
{
|
||||
if (init)
|
||||
{
|
||||
Load();
|
||||
}
|
||||
if (header == null) GetHeader();
|
||||
GUI.DrawTexture(new Rect(0, 0, maxSize.x, 82), header, ScaleMode.StretchToFill);
|
||||
GUI.Label(new Rect(90, 15, Screen.width - 95, 50), headerTitle, titleText);
|
||||
for (int i = 0; i < panels.Length; i++)
|
||||
{
|
||||
panels[i].Draw();
|
||||
}
|
||||
Repaint();
|
||||
|
||||
}
|
||||
|
||||
protected Data LoadBannersData(string url, string savePrefKey)
|
||||
{
|
||||
var data = default(Data);
|
||||
|
||||
using (var mainDataReq = UnityWebRequest.Get(url))
|
||||
{
|
||||
mainDataReq.SendWebRequest();
|
||||
|
||||
while (!mainDataReq.isDone || mainDataReq.result == UnityWebRequest.Result.InProgress)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (mainDataReq.result == UnityWebRequest.Result.ProtocolError ||
|
||||
mainDataReq.result == UnityWebRequest.Result.DataProcessingError ||
|
||||
mainDataReq.result == UnityWebRequest.Result.ConnectionError)
|
||||
{
|
||||
Debug.LogError("An error occured while fetching the banners data.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var jObj = JsonUtility.FromJson<Data>(mainDataReq.downloadHandler.text);
|
||||
|
||||
data = new Data();
|
||||
data.version = jObj.version;
|
||||
data.banners = jObj.banners;
|
||||
|
||||
var currentVersion = EditorPrefs.GetInt(savePrefKey, -1);
|
||||
|
||||
if (currentVersion < 0 || currentVersion < data.version)
|
||||
{
|
||||
EditorPrefs.SetInt(savePrefKey, data.version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
protected void OnEditorUpdate()
|
||||
{
|
||||
if (!_hasSentImageRequest)
|
||||
{
|
||||
_hasSentImageRequest = false;
|
||||
EditorApplication.update -= OnEditorUpdate;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _textureWebRequests.Count; i++)
|
||||
{
|
||||
var request = _textureWebRequests[i];
|
||||
|
||||
if (!request.isDone || request.result == UnityWebRequest.Result.InProgress)
|
||||
{
|
||||
if (request.result == UnityWebRequest.Result.ConnectionError ||
|
||||
request.result == UnityWebRequest.Result.ProtocolError ||
|
||||
request.result == UnityWebRequest.Result.DataProcessingError)
|
||||
{
|
||||
_textureWebRequests.RemoveAt(i);
|
||||
i--;
|
||||
Debug.LogError("A banner request failed for the spline welcome screen! Please investigate!");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _textureWebRequests.Count; i++)
|
||||
{
|
||||
var request = _textureWebRequests[i];
|
||||
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
var texture = DownloadHandlerTexture.GetContent(request);
|
||||
var data = _bannerData.banners[i];
|
||||
var banner = new WindowPanel.Banner(texture, data.title, data.description, 400f, 70f, new ActionLink(data.forwardUrl));
|
||||
|
||||
panels[0].elements.Add(new WindowPanel.Space(400, 10));
|
||||
panels[0].elements.Add(banner);
|
||||
request.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
DrawFooter();
|
||||
_hasSentImageRequest = false;
|
||||
_textureWebRequests.Clear();
|
||||
_textureWebRequests = null;
|
||||
EditorApplication.update -= OnEditorUpdate;
|
||||
}
|
||||
|
||||
protected virtual void DrawFooter()
|
||||
{
|
||||
}
|
||||
|
||||
public class WindowPanel
|
||||
{
|
||||
public WindowPanel back = null;
|
||||
public float slideStart = 0f;
|
||||
public float slideDuration = 1f;
|
||||
public enum SlideDiretion { Left, Right, Up, Down }
|
||||
public SlideDiretion openDirection = SlideDiretion.Left;
|
||||
public SlideDiretion closeDirection = SlideDiretion.Right;
|
||||
private Vector2 origin = Vector2.zero;
|
||||
private bool open = false;
|
||||
private bool goingBack = false;
|
||||
public List<Element> elements = new List<Element>();
|
||||
|
||||
public WindowPanel(string title, bool o, float slideDur = 1f)
|
||||
{
|
||||
slideDuration = slideDur;
|
||||
SetState(o, false);
|
||||
}
|
||||
|
||||
public WindowPanel(string title, bool o, WindowPanel backPanel, float slideDur = 1f)
|
||||
{
|
||||
slideDuration = slideDur;
|
||||
SetState(o, false);
|
||||
back = backPanel;
|
||||
}
|
||||
|
||||
public bool isActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return open || Time.realtimeSinceStartup - slideStart <= slideDuration;
|
||||
}
|
||||
}
|
||||
|
||||
public void Back()
|
||||
{
|
||||
Close(true, true);
|
||||
back.Open(true, true);
|
||||
}
|
||||
|
||||
public void Close(bool useTransition, bool goBack = false)
|
||||
{
|
||||
SetState(false, useTransition, goBack);
|
||||
}
|
||||
|
||||
public void Open(bool useTransition, bool goBack = false)
|
||||
{
|
||||
goingBack = false;
|
||||
SetState(true, useTransition, goBack);
|
||||
}
|
||||
|
||||
Vector2 GetSize()
|
||||
{
|
||||
return new Vector2(Screen.width, Screen.height- 82);
|
||||
}
|
||||
|
||||
void HandleOrigin()
|
||||
{
|
||||
float percent = Mathf.Clamp01((Time.realtimeSinceStartup - slideStart) / slideDuration);
|
||||
Vector2 size = GetSize();
|
||||
SlideDiretion dir = openDirection;
|
||||
if (goingBack) dir = closeDirection;
|
||||
if (open)
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case SlideDiretion.Left:
|
||||
origin.x = Mathf.SmoothStep(size.x, 0f, percent);
|
||||
origin.y = 0f;
|
||||
break;
|
||||
|
||||
case SlideDiretion.Right:
|
||||
origin.x = Mathf.SmoothStep(-size.x, 0f, percent);
|
||||
origin.y = 0f;
|
||||
break;
|
||||
|
||||
case SlideDiretion.Up:
|
||||
origin.x = 0f;
|
||||
origin.y = Mathf.SmoothStep(size.y, 0f, percent);
|
||||
break;
|
||||
|
||||
case SlideDiretion.Down:
|
||||
origin.x = 0f;
|
||||
origin.y = Mathf.SmoothStep(-size.y, 0f, percent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case SlideDiretion.Left:
|
||||
origin.x = Mathf.SmoothStep(0f, -size.x, percent);
|
||||
origin.y = 0f;
|
||||
break;
|
||||
|
||||
case SlideDiretion.Right:
|
||||
origin.x = Mathf.SmoothStep(0f, size.x, percent);
|
||||
origin.y = 0f;
|
||||
break;
|
||||
|
||||
case SlideDiretion.Up:
|
||||
origin.x = 0f;
|
||||
origin.y = Mathf.SmoothStep(0f, -size.y, percent);
|
||||
break;
|
||||
|
||||
case SlideDiretion.Down:
|
||||
origin.x = 0f;
|
||||
origin.y = Mathf.SmoothStep(0f, -size.y, percent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetState(bool state, bool useTransition, bool goBack = false)
|
||||
{
|
||||
if (open == state) return;
|
||||
open = state;
|
||||
if (useTransition) slideStart = Time.realtimeSinceStartup;
|
||||
else slideStart = Time.realtimeSinceStartup + slideDuration;
|
||||
goingBack = goBack;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (!isActive) return;
|
||||
HandleOrigin();
|
||||
Vector2 size = GetSize();
|
||||
GUILayout.BeginArea(new Rect(origin.x + 25, origin.y + 85, size.x - 25, size.y));
|
||||
//Back button
|
||||
if (back != null)
|
||||
{
|
||||
if (GUILayout.Button("◄", GUILayout.Width(45), GUILayout.Height(25)))
|
||||
{
|
||||
Back();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < elements.Count; i++) elements[i].Draw();
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
|
||||
public class Element
|
||||
{
|
||||
protected Vector2 size = Vector2.zero;
|
||||
public ActionLink action = null;
|
||||
|
||||
public Element(float x, float y, ActionLink a = null)
|
||||
{
|
||||
size = new Vector2(x, y);
|
||||
action = a;
|
||||
}
|
||||
|
||||
internal virtual void Draw()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class Space : Element
|
||||
{
|
||||
public Space(float x, float y) : base(x, y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal override void Draw()
|
||||
{
|
||||
GUILayoutUtility.GetRect(size.x, size.y);
|
||||
}
|
||||
}
|
||||
|
||||
public class Button : Element
|
||||
{
|
||||
string text = "";
|
||||
|
||||
public Button(float x, float y, string t, ActionLink a) : base(x, y, a)
|
||||
{
|
||||
text = t;
|
||||
}
|
||||
|
||||
internal override void Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if(GUILayout.Button(text, GUILayout.Width(size.x), GUILayout.Height(size.y)))
|
||||
{
|
||||
if (action != null) action.Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Banner : Element
|
||||
{
|
||||
private string _title;
|
||||
private string _description;
|
||||
private Texture _image;
|
||||
|
||||
public Banner(float x, float y, ActionLink a = null) : base(x, y, a) { }
|
||||
|
||||
public Banner(Texture image, string title, string description, float x, float y, ActionLink a = null) : this(x, y, a)
|
||||
{
|
||||
_title = title;
|
||||
_description = description;
|
||||
_image = image;
|
||||
size = new Vector2(image.width, image.height);
|
||||
}
|
||||
|
||||
internal override void Draw()
|
||||
{
|
||||
Rect rect = GUILayoutUtility.GetRect(size.x, size.y);
|
||||
|
||||
EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);
|
||||
|
||||
GUI.BeginGroup(rect);
|
||||
if (GUI.Button(new Rect(0, 0, size.x, size.y), "")) action.Do();
|
||||
|
||||
GUI.DrawTexture(new Rect(Vector2.one, size), _image, ScaleMode.StretchToFill);
|
||||
|
||||
var hoverRect = new Rect(0, 0, size.x, size.y);
|
||||
if (hoverRect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
EditorGUI.DrawRect(hoverRect, new Color(1, 1, 1, 0.5f));
|
||||
}
|
||||
|
||||
var titleStyle = new GUIStyle();
|
||||
titleStyle.fontSize = 19;
|
||||
titleStyle.fontStyle = FontStyle.Bold;
|
||||
titleStyle.alignment = TextAnchor.MiddleLeft;
|
||||
titleStyle.normal.textColor = Color.white;
|
||||
EditorGUI.DropShadowLabel(new Rect(6, 5, 370 - 65, 18), _title, titleStyle);
|
||||
|
||||
var descriptionStyle = new GUIStyle();
|
||||
descriptionStyle.fontSize = 11;
|
||||
descriptionStyle.wordWrap = true;
|
||||
descriptionStyle.fontStyle = FontStyle.Bold;
|
||||
descriptionStyle.alignment = TextAnchor.MiddleLeft;
|
||||
descriptionStyle.normal.textColor = Color.white;
|
||||
|
||||
EditorGUI.DropShadowLabel(new Rect(6, 20, 380, 40), _description, descriptionStyle);
|
||||
|
||||
GUI.EndGroup();
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
}
|
||||
|
||||
public class Thumbnail : Element
|
||||
{
|
||||
private string thumbnailPath = "";
|
||||
private string thumbnailName = "";
|
||||
private Texture2D thumbnail = null;
|
||||
public string title = "";
|
||||
public string description = "";
|
||||
|
||||
public Thumbnail(string path, string fileName, string t, string d, ActionLink a, float x = 400, float y = 60) : base(x, y, a)
|
||||
{
|
||||
title = t;
|
||||
description = d;
|
||||
thumbnailPath = path;
|
||||
thumbnailName = fileName;
|
||||
|
||||
thumbnail = ResourceUtility.EditorLoadTexture(thumbnailPath, thumbnailName);
|
||||
}
|
||||
|
||||
internal override void Draw()
|
||||
{
|
||||
Rect rect = GUILayoutUtility.GetRect(size.x, size.y);
|
||||
Color buttonColor = Color.clear;
|
||||
if (rect.Contains(Event.current.mousePosition)) buttonColor = Color.white;
|
||||
GUI.BeginGroup(rect);
|
||||
GUI.color = buttonColor;
|
||||
if (GUI.Button(new Rect(0, 0, size.x, size.y), "")) action.Do();
|
||||
GUI.color = Color.white;
|
||||
if (thumbnail != null)
|
||||
{
|
||||
Vector2 offset = new Vector2(5, (size.y - 50) / 2);
|
||||
GUI.DrawTexture(new Rect(offset, Vector2.one * 50), thumbnail, ScaleMode.StretchToFill);
|
||||
}
|
||||
GUI.Label(new Rect(60, 5, 370 - 65, 16), title, buttonTitleText);
|
||||
GUI.Label(new Rect(60, 20, 370 - 65, 40), description, wrapText);
|
||||
GUI.EndGroup();
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
}
|
||||
|
||||
public class ScrollText : Element
|
||||
{
|
||||
Vector2 scroll = Vector2.zero;
|
||||
string text = "";
|
||||
|
||||
public ScrollText(float x, float y, string t) : base(x, y)
|
||||
{
|
||||
text = t;
|
||||
}
|
||||
|
||||
internal override void Draw()
|
||||
{
|
||||
base.Draw();
|
||||
scroll = GUILayout.BeginScrollView(scroll, GUILayout.Width(size.x), GUILayout.MaxHeight(size.y));
|
||||
EditorGUILayout.LabelField(text, wrapText, GUILayout.Width(size.x - 30));
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
}
|
||||
|
||||
public class Label : Element
|
||||
{
|
||||
string text = "";
|
||||
Color color;
|
||||
GUIStyle style = null;
|
||||
public Label(string t, GUIStyle s, Color col) : base(400, 30)
|
||||
{
|
||||
color = col;
|
||||
text = t;
|
||||
style = s;
|
||||
}
|
||||
|
||||
public Label(string t, GUIStyle s, Color col, float x, float y) : base(x, y)
|
||||
{
|
||||
color = col;
|
||||
text = t;
|
||||
style = s;
|
||||
}
|
||||
|
||||
internal override void Draw()
|
||||
{
|
||||
base.Draw();
|
||||
Color prev = GUI.color;
|
||||
GUI.color = color;
|
||||
if(style == null) EditorGUILayout.LabelField(text, GUILayout.Width(size.x), GUILayout.Height(size.y));
|
||||
else EditorGUILayout.LabelField(text, style, GUILayout.Width(size.x), GUILayout.Height(size.y));
|
||||
GUI.color = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionLink {
|
||||
private string URL = "";
|
||||
private WindowPanel currentPanel = null;
|
||||
private WindowPanel targetPanel = null;
|
||||
private EmptyHandler customHandler = null;
|
||||
|
||||
public ActionLink(string u)
|
||||
{
|
||||
URL = u;
|
||||
}
|
||||
|
||||
public ActionLink(EmptyHandler handler)
|
||||
{
|
||||
customHandler = handler;
|
||||
}
|
||||
|
||||
public ActionLink(WindowPanel target, WindowPanel current)
|
||||
{
|
||||
currentPanel = current;
|
||||
targetPanel = target;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
if (customHandler != null) customHandler();
|
||||
else if(URL != "") Application.OpenURL(URL);
|
||||
else if(targetPanel != null && currentPanel != null)
|
||||
{
|
||||
currentPanel.Close(true);
|
||||
targetPanel.Open(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Data
|
||||
{
|
||||
public BannerData[] banners;
|
||||
public int version;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class BannerData
|
||||
{
|
||||
public string title;
|
||||
public string description;
|
||||
public string bannerUrl;
|
||||
public string forwardUrl;
|
||||
public int height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bada76b30269a9144848e487cf253360
|
||||
timeCreated: 1522397149
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
201
Assets/Plugins/Dreamteck/Utilities/LICENSE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
7
Assets/Plugins/Dreamteck/Utilities/LICENSE.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c45b82a053ddfa4799eb9b554fffead
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
67
Assets/Plugins/Dreamteck/Utilities/LinearAlgebraUtility.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public static class LinearAlgebraUtility
|
||||
{
|
||||
public enum Axis
|
||||
{
|
||||
X = 0,
|
||||
Y = 1,
|
||||
Z = 2
|
||||
}
|
||||
|
||||
public static Vector3 ProjectOnLine(Vector3 fromPoint, Vector3 toPoint, Vector3 project)
|
||||
{
|
||||
Vector3 projectedPoint = Vector3.Project((project - fromPoint), (toPoint - fromPoint)) + fromPoint;
|
||||
Vector3 dir = toPoint - fromPoint;
|
||||
Vector3 projectedDir = projectedPoint - fromPoint;
|
||||
float dot = Vector3.Dot(projectedDir, dir);
|
||||
if(dot > 0f)
|
||||
{
|
||||
if(projectedDir.sqrMagnitude <= dir.sqrMagnitude) return projectedPoint;
|
||||
else return toPoint;
|
||||
} else return fromPoint;
|
||||
}
|
||||
|
||||
public static float InverseLerp(Vector3 a, Vector3 b, Vector3 value)
|
||||
{
|
||||
Vector3 ab = b - a;
|
||||
Vector3 av = value - a;
|
||||
return Vector3.Dot(av, ab) / Vector3.Dot(ab, ab);
|
||||
}
|
||||
|
||||
public static float DistanceOnSphere(Vector3 from, Vector3 to, float radius)
|
||||
{
|
||||
float distance = 0;
|
||||
|
||||
if (from == to)
|
||||
{
|
||||
distance = 0;
|
||||
}
|
||||
else if (from == -to)
|
||||
{
|
||||
distance = Mathf.PI * radius;
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = Mathf.Sqrt(2) * radius * Mathf.Sqrt(1.0f - Vector3.Dot(from, to));
|
||||
}
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
public static Vector3 FlattenVector(Vector3 input, Axis axis, float flatValue = 0f)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
case Axis.X: input.x = flatValue; break;
|
||||
case Axis.Y: input.y = flatValue; break;
|
||||
case Axis.Z: input.z = flatValue; break;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9db18633d04e91409973e2ca7ab9c76
|
||||
timeCreated: 1458246009
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
657
Assets/Plugins/Dreamteck/Utilities/MeshUtility.cs
Normal file
@@ -0,0 +1,657 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public class MeshUtility
|
||||
{
|
||||
private static Vector3[] tan1 = new Vector3[0];
|
||||
private static Vector3[] tan2 = new Vector3[0];
|
||||
|
||||
public static int[] GeneratePlaneTriangles(int x, int z, bool flip, int startTriangleIndex = 0, int startVertex = 0)
|
||||
{
|
||||
int nbFaces = x * (z - 1);
|
||||
int[] triangles = new int[nbFaces * 6];
|
||||
GeneratePlaneTriangles(ref triangles, x, z, flip);
|
||||
return triangles;
|
||||
}
|
||||
|
||||
public static int[] GeneratePlaneTriangles(ref int[] triangles, int x, int z, bool flip, int startTriangleIndex = 0, int startVertex = 0, bool reallocateArray = false)
|
||||
{
|
||||
int nbFaces = x * (z - 1);
|
||||
if (reallocateArray && triangles.Length != nbFaces * 6)
|
||||
{
|
||||
if(startTriangleIndex > 0)
|
||||
{
|
||||
int[] newTris = new int[startTriangleIndex + nbFaces * 6];
|
||||
for(int i = 0; i < startTriangleIndex; i++) newTris[i] = triangles[i];
|
||||
triangles = newTris;
|
||||
} else triangles = new int[nbFaces * 6];
|
||||
}
|
||||
int g = x + 1;
|
||||
int t = startTriangleIndex;
|
||||
for (int face = 0; face < nbFaces + z - 2; face++)
|
||||
{
|
||||
if ((float)(face + 1) % (float)g == 0f && face != 0) face++;
|
||||
if (flip)
|
||||
{
|
||||
triangles[t++] = face + x + 1 + startVertex;
|
||||
triangles[t++] = face + 1 + startVertex;
|
||||
triangles[t++] = face + startVertex;
|
||||
|
||||
triangles[t++] = face + x + 1 + startVertex;
|
||||
triangles[t++] = face + x + 2 + startVertex;
|
||||
triangles[t++] = face + 1 + startVertex;
|
||||
}
|
||||
else
|
||||
{
|
||||
triangles[t++] = face + startVertex;
|
||||
triangles[t++] = face + 1 + startVertex;
|
||||
triangles[t++] = face + x + 1 + startVertex;
|
||||
|
||||
triangles[t++] = face + 1 + startVertex;
|
||||
triangles[t++] = face + x + 2 + startVertex;
|
||||
triangles[t++] = face + x + 1 + startVertex;
|
||||
}
|
||||
}
|
||||
return triangles;
|
||||
}
|
||||
|
||||
public static void CalculateTangents(TS_Mesh mesh)
|
||||
{
|
||||
int triangleCount = mesh.triangles.Length / 3;
|
||||
if (mesh.tangents.Length != mesh.vertexCount) mesh.tangents = new Vector4[mesh.vertexCount];
|
||||
if (tan1.Length != mesh.vertexCount)
|
||||
{
|
||||
tan1 = new Vector3[mesh.vertexCount];
|
||||
tan2 = new Vector3[mesh.vertexCount];
|
||||
}
|
||||
|
||||
int tri = 0;
|
||||
for (int i = 0; i < triangleCount; i++)
|
||||
{
|
||||
int i1 = mesh.triangles[tri];
|
||||
int i2 = mesh.triangles[tri + 1];
|
||||
int i3 = mesh.triangles[tri + 2];
|
||||
|
||||
float x1 = mesh.vertices[i2].x - mesh.vertices[i1].x;
|
||||
float x2 = mesh.vertices[i3].x - mesh.vertices[i1].x;
|
||||
float y1 = mesh.vertices[i2].y - mesh.vertices[i1].y;
|
||||
float y2 = mesh.vertices[i3].y - mesh.vertices[i1].y;
|
||||
float z1 = mesh.vertices[i2].z - mesh.vertices[i1].z;
|
||||
float z2 = mesh.vertices[i3].z - mesh.vertices[i1].z;
|
||||
|
||||
float s1 = mesh.uv[i2].x - mesh.uv[i1].x;
|
||||
float s2 = mesh.uv[i3].x - mesh.uv[i1].x;
|
||||
float t1 = mesh.uv[i2].y - mesh.uv[i1].y;
|
||||
float t2 = mesh.uv[i3].y - mesh.uv[i1].y;
|
||||
|
||||
float div = s1 * t2 - s2 * t1;
|
||||
float r = div == 0f ? 0f : 1f / div;
|
||||
|
||||
Vector3 sdir = new Vector3((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r);
|
||||
Vector3 tdir = new Vector3((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r);
|
||||
|
||||
tan1[i1] += sdir;
|
||||
tan1[i2] += sdir;
|
||||
tan1[i3] += sdir;
|
||||
|
||||
tan2[i1] += tdir;
|
||||
tan2[i2] += tdir;
|
||||
tan2[i3] += tdir;
|
||||
|
||||
tri += 3;
|
||||
}
|
||||
|
||||
for (int i = 0; i < mesh.vertexCount; i++)
|
||||
{
|
||||
Vector3 n = mesh.normals[i];
|
||||
Vector3 t = tan1[i];
|
||||
Vector3.OrthoNormalize(ref n, ref t);
|
||||
mesh.tangents[i].x = t.x;
|
||||
mesh.tangents[i].y = t.y;
|
||||
mesh.tangents[i].z = t.z;
|
||||
mesh.tangents[i].w = (Vector3.Dot(Vector3.Cross(n, t), tan2[i]) < 0.0f) ? -1.0f : 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static void MakeDoublesided(Mesh input)
|
||||
{
|
||||
Vector3[] vertices = input.vertices;
|
||||
Vector3[] normals = input.normals;
|
||||
Vector2[] uvs = input.uv;
|
||||
Color[] colors = input.colors;
|
||||
int[] triangles = input.triangles;
|
||||
List<int[]> submeshes = new List<int[]>();
|
||||
for (int i = 0; i < input.subMeshCount; i++) submeshes.Add(input.GetTriangles(i));
|
||||
|
||||
Vector3[] newVertices = new Vector3[vertices.Length * 2];
|
||||
Vector3[] newNormals = new Vector3[normals.Length * 2];
|
||||
Vector2[] newUvs = new Vector2[uvs.Length * 2];
|
||||
Color[] newColors = new Color[colors.Length * 2];
|
||||
int[] newTris = new int[triangles.Length * 2];
|
||||
List<int[]> newSubmeshes = new List<int[]>();
|
||||
for (int i = 0; i < submeshes.Count; i++)
|
||||
{
|
||||
newSubmeshes.Add(new int[submeshes[i].Length * 2]);
|
||||
submeshes[i].CopyTo(newSubmeshes[i], 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
newVertices[i] = vertices[i];
|
||||
newNormals[i] = normals[i];
|
||||
newUvs[i] = uvs[i];
|
||||
if (colors.Length > i) newColors[i] = colors[i];
|
||||
|
||||
newVertices[i + vertices.Length] = vertices[i];
|
||||
newNormals[i + vertices.Length] = -normals[i];
|
||||
newUvs[i + vertices.Length] = uvs[i];
|
||||
if (colors.Length > i) newColors[i + vertices.Length] = colors[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < triangles.Length; i += 3)
|
||||
{
|
||||
int index1 = triangles[i];
|
||||
int index2 = triangles[i + 1];
|
||||
int index3 = triangles[i + 2];
|
||||
newTris[i] = index1;
|
||||
newTris[i + 1] = index2;
|
||||
newTris[i + 2] = index3;
|
||||
|
||||
newTris[i + triangles.Length] = index3 + vertices.Length;
|
||||
newTris[i + triangles.Length + 1] = index2 + vertices.Length;
|
||||
newTris[i + triangles.Length + 2] = index1 + vertices.Length;
|
||||
}
|
||||
|
||||
for (int i = 0; i < submeshes.Count; i++)
|
||||
{
|
||||
for (int n = 0; n < submeshes[i].Length; n += 3)
|
||||
{
|
||||
int index1 = submeshes[i][n];
|
||||
int index2 = submeshes[i][n + 1];
|
||||
int index3 = submeshes[i][n + 2];
|
||||
newSubmeshes[i][n] = index1;
|
||||
newSubmeshes[i][n + 1] = index2;
|
||||
newSubmeshes[i][n + 2] = index3;
|
||||
|
||||
newSubmeshes[i][n + submeshes[i].Length] = index3 + vertices.Length;
|
||||
newSubmeshes[i][n + submeshes[i].Length + 1] = index2 + vertices.Length;
|
||||
newSubmeshes[i][n + submeshes[i].Length + 2] = index1 + vertices.Length;
|
||||
}
|
||||
}
|
||||
|
||||
input.vertices = newVertices;
|
||||
input.normals = newNormals;
|
||||
input.uv = newUvs;
|
||||
input.colors = newColors;
|
||||
input.triangles = newTris;
|
||||
for (int i = 0; i < newSubmeshes.Count; i++) input.SetTriangles(newSubmeshes[i], i);
|
||||
}
|
||||
|
||||
public static void MakeDoublesided(TS_Mesh input)
|
||||
{
|
||||
Vector3[] vertices = input.vertices;
|
||||
Vector3[] normals = input.normals;
|
||||
Vector2[] uvs = input.uv;
|
||||
Color[] colors = input.colors;
|
||||
int[] triangles = input.triangles;
|
||||
List<int[]> submeshes = input.subMeshes;
|
||||
|
||||
Vector3[] newVertices = new Vector3[vertices.Length * 2];
|
||||
Vector3[] newNormals = new Vector3[normals.Length * 2];
|
||||
Vector2[] newUvs = new Vector2[uvs.Length * 2];
|
||||
Color[] newColors = new Color[colors.Length * 2];
|
||||
int[] newTris = new int[triangles.Length * 2];
|
||||
List<int[]> newSubmeshes = new List<int[]>();
|
||||
for(int i = 0; i < submeshes.Count; i++)
|
||||
{
|
||||
newSubmeshes.Add(new int[submeshes[i].Length * 2]);
|
||||
submeshes[i].CopyTo(newSubmeshes[i], 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
newVertices[i] = vertices[i];
|
||||
newNormals[i] = normals[i];
|
||||
newUvs[i] = uvs[i];
|
||||
if(colors.Length > i) newColors[i] = colors[i];
|
||||
|
||||
newVertices[i + vertices.Length] = vertices[i];
|
||||
newNormals[i + vertices.Length] = -normals[i];
|
||||
newUvs[i + vertices.Length] = uvs[i];
|
||||
if (colors.Length > i) newColors[i + vertices.Length] = colors[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < triangles.Length; i += 3)
|
||||
{
|
||||
int index1 = triangles[i];
|
||||
int index2 = triangles[i + 1];
|
||||
int index3 = triangles[i + 2];
|
||||
newTris[i] = index1;
|
||||
newTris[i + 1] = index2;
|
||||
newTris[i + 2] = index3;
|
||||
|
||||
newTris[i + triangles.Length] = index3 + vertices.Length;
|
||||
newTris[i + triangles.Length + 1] = index2 + vertices.Length;
|
||||
newTris[i + triangles.Length + 2] = index1 + vertices.Length;
|
||||
}
|
||||
|
||||
for(int i = 0; i < submeshes.Count; i++)
|
||||
{
|
||||
for(int n = 0; n < submeshes[i].Length; n+= 3)
|
||||
{
|
||||
int index1 = submeshes[i][n];
|
||||
int index2 = submeshes[i][n + 1];
|
||||
int index3 = submeshes[i][n + 2];
|
||||
newSubmeshes[i][n] = index1;
|
||||
newSubmeshes[i][n + 1] = index2;
|
||||
newSubmeshes[i][n + 2] = index3;
|
||||
|
||||
newSubmeshes[i][n + submeshes[i].Length] = index3 + vertices.Length;
|
||||
newSubmeshes[i][n + submeshes[i].Length + 1] = index2 + vertices.Length;
|
||||
newSubmeshes[i][n + submeshes[i].Length + 2] = index1 + vertices.Length;
|
||||
}
|
||||
}
|
||||
|
||||
input.vertices = newVertices;
|
||||
input.normals = newNormals;
|
||||
input.uv = newUvs;
|
||||
input.colors = newColors;
|
||||
input.triangles = newTris;
|
||||
input.subMeshes = newSubmeshes;
|
||||
}
|
||||
|
||||
public static void MakeDoublesidedHalf(TS_Mesh input)
|
||||
{
|
||||
int vertexHalf = input.vertices.Length / 2;
|
||||
int trisHalf = input.triangles.Length / 2;
|
||||
for (int i = 0; i < vertexHalf; i++)
|
||||
{
|
||||
input.vertices[i + vertexHalf] = input.vertices[i];
|
||||
if (input.normals.Length > i) input.normals[i + vertexHalf] = -input.normals[i];
|
||||
if (input.tangents.Length > i) input.tangents[i + vertexHalf] = input.tangents[i];
|
||||
if (input.uv.Length > i) input.uv[i + vertexHalf] = input.uv[i];
|
||||
if (input.uv2.Length > i) input.uv2[i + vertexHalf] = input.uv2[i];
|
||||
if (input.uv3.Length > i) input.uv3[i + vertexHalf] = input.uv3[i];
|
||||
if (input.uv4.Length > i) input.uv4[i + vertexHalf] = input.uv4[i];
|
||||
if (input.colors.Length > i) input.colors[i + vertexHalf] = input.colors[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < trisHalf; i += 3)
|
||||
{
|
||||
input.triangles[i + trisHalf + 2] = input.triangles[i] + vertexHalf;
|
||||
input.triangles[i + trisHalf + 1] = input.triangles[i + 1] + vertexHalf;
|
||||
input.triangles[i + trisHalf] = input.triangles[i + 2] + vertexHalf;
|
||||
}
|
||||
|
||||
for (int i = 0; i < input.subMeshes.Count; i++)
|
||||
{
|
||||
trisHalf = input.subMeshes[i].Length / 2;
|
||||
for (int n = 0; n < trisHalf; n += 3)
|
||||
{
|
||||
input.subMeshes[i][n + trisHalf + 2] = input.subMeshes[i][n] + vertexHalf;
|
||||
input.subMeshes[i][n + trisHalf + 1] = input.subMeshes[i][n + 1] + vertexHalf;
|
||||
input.subMeshes[i][n + trisHalf] = input.subMeshes[i][n + 2] + vertexHalf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void TransformMesh(TS_Mesh input, Matrix4x4 matrix)
|
||||
{
|
||||
if (input.vertices == null || input.normals == null) return;
|
||||
for (int i = 0; i < input.vertices.Length; i++)
|
||||
{
|
||||
input.vertices[i] = matrix.MultiplyPoint3x4(input.vertices[i]);
|
||||
input.normals[i] = matrix.MultiplyVector(input.normals[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void TransformMesh(Mesh input, Matrix4x4 matrix)
|
||||
{
|
||||
Vector3[] vertices = input.vertices;
|
||||
Vector3[] normals = input.vertices;
|
||||
if (input.vertices == null || input.normals == null) return;
|
||||
for (int i = 0; i < input.vertices.Length; i++)
|
||||
{
|
||||
vertices[i] = matrix.MultiplyPoint3x4(vertices[i]);
|
||||
normals[i] = matrix.MultiplyVector(normals[i]);
|
||||
}
|
||||
input.vertices = vertices;
|
||||
input.normals = normals;
|
||||
}
|
||||
|
||||
|
||||
public static void TransformVertices(Vector3[] vertices, Matrix4x4 matrix)
|
||||
{
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
vertices[i] = matrix.MultiplyPoint3x4(vertices[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void TransformNormals(Vector3[] normals, Matrix4x4 matrix)
|
||||
{
|
||||
for (int i = 0; i < normals.Length; i++)
|
||||
{
|
||||
normals[i] = matrix.MultiplyVector(normals[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToOBJString(Mesh mesh, Material[] materials)
|
||||
{
|
||||
int numVertices = 0;
|
||||
if (mesh == null)
|
||||
{
|
||||
return "####Error####";
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("g " + mesh.name +"\n");
|
||||
foreach (Vector3 v in mesh.vertices)
|
||||
{
|
||||
numVertices++;
|
||||
sb.Append(string.Format("v {0} {1} {2}\n", -v.x, v.y, v.z));
|
||||
}
|
||||
sb.Append("\n");
|
||||
foreach (Vector3 n in mesh.normals)
|
||||
{
|
||||
sb.Append(string.Format("vn {0} {1} {2}\n", -n.x, n.y, n.z));
|
||||
}
|
||||
sb.Append("\n");
|
||||
foreach (Vector3 v in mesh.uv)
|
||||
{
|
||||
sb.Append(string.Format("vt {0} {1}\n", v.x, v.y));
|
||||
}
|
||||
sb.Append("\n");
|
||||
foreach (Vector2 v in mesh.uv2)
|
||||
{
|
||||
sb.Append(string.Format("vt2 {0} {1}\n", v.x, v.y));
|
||||
}
|
||||
sb.Append("\n");
|
||||
foreach (Vector2 v in mesh.uv3)
|
||||
{
|
||||
sb.Append(string.Format("vt2 {0} {1}\n", v.x, v.y));
|
||||
}
|
||||
sb.Append("\n");
|
||||
foreach (Color c in mesh.colors)
|
||||
{
|
||||
sb.Append(string.Format("vc {0} {1} {2} {3}\n", c.r, c.g, c.b, c.a));
|
||||
}
|
||||
for (int material = 0; material < mesh.subMeshCount; material++)
|
||||
{
|
||||
sb.Append("\n");
|
||||
sb.Append("usemtl ").Append(materials[material].name).Append("\n");
|
||||
sb.Append("usemap ").Append(materials[material].name).Append("\n");
|
||||
|
||||
int[] triangles = mesh.GetTriangles(material);
|
||||
for (int i = 0; i < triangles.Length; i += 3)
|
||||
{
|
||||
sb.Append(string.Format("f {2}/{2}/{2} {1}/{1}/{1} {0}/{0}/{0}\n",
|
||||
triangles[i] + 1, triangles[i + 1] + 1, triangles[i + 2] + 1));
|
||||
}
|
||||
}
|
||||
return sb.ToString().Replace(',', '.');
|
||||
}
|
||||
|
||||
public static Mesh Copy(Mesh input)
|
||||
{
|
||||
Mesh copy = new Mesh();
|
||||
copy.name = input.name;
|
||||
copy.vertices = input.vertices;
|
||||
copy.normals = input.normals;
|
||||
copy.colors = input.colors;
|
||||
copy.uv = input.uv;
|
||||
copy.uv2 = input.uv2;
|
||||
copy.uv3 = input.uv3;
|
||||
copy.uv4 = input.uv4;
|
||||
copy.tangents = input.tangents;
|
||||
copy.boneWeights = input.boneWeights;
|
||||
copy.bindposes = input.bindposes;
|
||||
copy.triangles = input.triangles;
|
||||
copy.subMeshCount = input.subMeshCount;
|
||||
for (int i = 0; i < input.subMeshCount; i++)
|
||||
{
|
||||
copy.SetTriangles(input.GetTriangles(i), i);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static void Triangulate(Vector2[] points, ref int[] output)
|
||||
{
|
||||
List<int> indices = new List<int>();
|
||||
int pointsLength = points.Length;
|
||||
if (pointsLength < 3)
|
||||
{
|
||||
output = new int[0];
|
||||
return;
|
||||
}
|
||||
|
||||
int[] V = new int[pointsLength];
|
||||
if (Area(points, pointsLength) > 0)
|
||||
{
|
||||
for (int v = 0; v < pointsLength; v++)
|
||||
V[v] = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int v = 0; v < pointsLength; v++)
|
||||
V[v] = (pointsLength - 1) - v;
|
||||
}
|
||||
|
||||
int nv = pointsLength;
|
||||
int count = 2 * nv;
|
||||
for (int m = 0, v = nv - 1; nv > 2;)
|
||||
{
|
||||
if ((count--) <= 0)
|
||||
{
|
||||
if (output.Length != indices.Count) output = new int[indices.Count];
|
||||
indices.CopyTo(output, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
int u = v;
|
||||
if (nv <= u)
|
||||
u = 0;
|
||||
v = u + 1;
|
||||
if (nv <= v)
|
||||
v = 0;
|
||||
int w = v + 1;
|
||||
if (nv <= w)
|
||||
w = 0;
|
||||
|
||||
if (Snip(points, u, v, w, nv, V))
|
||||
{
|
||||
int a, b, c, s, t;
|
||||
a = V[u];
|
||||
b = V[v];
|
||||
c = V[w];
|
||||
indices.Add(c);
|
||||
indices.Add(b);
|
||||
indices.Add(a);
|
||||
m++;
|
||||
for (s = v, t = v + 1; t < nv; s++, t++)
|
||||
V[s] = V[t];
|
||||
nv--;
|
||||
count = 2 * nv;
|
||||
}
|
||||
}
|
||||
|
||||
indices.Reverse();
|
||||
if (output.Length != indices.Count) output = new int[indices.Count];
|
||||
indices.CopyTo(output, 0);
|
||||
}
|
||||
|
||||
public static void FlipTriangles(ref int[] triangles)
|
||||
{
|
||||
for (int i = 0; i < triangles.Length; i += 3)
|
||||
{
|
||||
int temp = triangles[i];
|
||||
triangles[i] = triangles[i + 2];
|
||||
triangles[i + 2] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
public static void FlipFaces(TS_Mesh input)
|
||||
{
|
||||
for (int i = 0; i < input.subMeshes.Count; i++)
|
||||
{
|
||||
int[] array = input.subMeshes[i];
|
||||
FlipTriangles(ref array);
|
||||
}
|
||||
FlipTriangles(ref input.triangles);
|
||||
for (int i = 0; i < input.normals.Length; i++)
|
||||
{
|
||||
input.normals[i] *= -1f;
|
||||
}
|
||||
}
|
||||
|
||||
public static void BreakMesh(Mesh input, bool keepNormals = true)
|
||||
{
|
||||
Vector3[] newVertices = new Vector3[input.triangles.Length];
|
||||
Vector3[] newNormals = new Vector3[newVertices.Length];
|
||||
Vector2[] newUVs = new Vector2[newVertices.Length];
|
||||
Vector4[] newTangents = new Vector4[newVertices.Length];
|
||||
Color[] newColors = new Color[newVertices.Length];
|
||||
BoneWeight[] newBoneWeights = new BoneWeight[newVertices.Length];
|
||||
|
||||
Vector3[] oldVertices = input.vertices;
|
||||
Vector2[] oldUvs = input.uv;
|
||||
Vector3[] oldNormals = input.normals;
|
||||
Vector4[] oldTangents = input.tangents;
|
||||
Color[] oldColors = input.colors;
|
||||
BoneWeight[] oldBoneWeights = input.boneWeights;
|
||||
|
||||
if (oldColors.Length != oldVertices.Length)
|
||||
{
|
||||
oldColors = new Color[oldVertices.Length];
|
||||
for (int i = 0; i < oldColors.Length; i++) oldColors[i] = Color.white;
|
||||
}
|
||||
|
||||
List<int[]> submeshList = new List<int[]>();
|
||||
int submeshes = input.subMeshCount;
|
||||
int vertIndex = 0;
|
||||
for (int i = 0; i < submeshes; i++)
|
||||
{
|
||||
int[] submesh = input.GetTriangles(i);
|
||||
for (int n = 0; n < submesh.Length; n += 3)
|
||||
{
|
||||
newVertices[vertIndex] = oldVertices[submesh[n]];
|
||||
newVertices[vertIndex + 1] = oldVertices[submesh[n + 1]];
|
||||
newVertices[vertIndex + 2] = oldVertices[submesh[n + 2]];
|
||||
|
||||
if (oldNormals.Length > submesh[n + 2])
|
||||
{
|
||||
if (!keepNormals)
|
||||
{
|
||||
newNormals[vertIndex] = newNormals[vertIndex + 1] = newNormals[vertIndex + 2] = (oldNormals[submesh[n]] + oldNormals[submesh[n + 1]] + oldNormals[submesh[n + 2]]).normalized;
|
||||
}
|
||||
else
|
||||
{
|
||||
newNormals[vertIndex] = oldNormals[submesh[n]];
|
||||
newNormals[vertIndex + 1] = oldNormals[submesh[n + 1]];
|
||||
newNormals[vertIndex + 2] = oldNormals[submesh[n + 2]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (oldColors.Length > submesh[n + 2])
|
||||
newColors[vertIndex] = newColors[vertIndex + 1] = newColors[vertIndex + 2] = (oldColors[submesh[n]] + oldColors[submesh[n + 1]] + oldColors[submesh[n + 2]]) / 3f;
|
||||
|
||||
if (oldUvs.Length > submesh[n + 2])
|
||||
{
|
||||
newUVs[vertIndex] = oldUvs[submesh[n]];
|
||||
newUVs[vertIndex + 1] = oldUvs[submesh[n + 1]];
|
||||
newUVs[vertIndex + 2] = oldUvs[submesh[n + 2]];
|
||||
}
|
||||
|
||||
if (oldTangents.Length > submesh[n + 2])
|
||||
{
|
||||
newTangents[vertIndex] = oldTangents[submesh[n]];
|
||||
newTangents[vertIndex + 1] = oldTangents[submesh[n + 1]];
|
||||
newTangents[vertIndex + 2] = oldTangents[submesh[n + 2]];
|
||||
}
|
||||
|
||||
if (oldBoneWeights.Length > submesh[n + 2])
|
||||
{
|
||||
newBoneWeights[vertIndex] = oldBoneWeights[submesh[n]];
|
||||
newBoneWeights[vertIndex + 1] = oldBoneWeights[submesh[n + 1]];
|
||||
newBoneWeights[vertIndex + 2] = oldBoneWeights[submesh[n + 2]];
|
||||
}
|
||||
|
||||
submesh[n] = vertIndex;
|
||||
submesh[n + 1] = vertIndex + 1;
|
||||
submesh[n + 2] = vertIndex + 2;
|
||||
vertIndex += 3;
|
||||
}
|
||||
submeshList.Add(submesh);
|
||||
}
|
||||
|
||||
input.vertices = newVertices;
|
||||
input.normals = newNormals;
|
||||
input.colors = newColors;
|
||||
input.uv = newUVs;
|
||||
input.tangents = newTangents;
|
||||
input.subMeshCount = submeshList.Count;
|
||||
input.boneWeights = newBoneWeights;
|
||||
for (int i = 0; i < submeshList.Count; i++)
|
||||
{
|
||||
input.SetTriangles(submeshList[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
private static float Area(Vector2[] points, int maxCount)
|
||||
{
|
||||
float A = 0.0f;
|
||||
for (int p = maxCount - 1, q = 0; q < maxCount; p = q++)
|
||||
{
|
||||
Vector2 pval = points[p];
|
||||
Vector2 qval = points[q];
|
||||
A += pval.x * qval.y - qval.x * pval.y;
|
||||
}
|
||||
return (A * 0.5f);
|
||||
}
|
||||
|
||||
private static bool Snip(Vector2[] points, int u, int v, int w, int n, int[] V)
|
||||
{
|
||||
int p;
|
||||
Vector2 A = points[V[u]];
|
||||
Vector2 B = points[V[v]];
|
||||
Vector2 C = points[V[w]];
|
||||
if (Mathf.Epsilon > (((B.x - A.x) * (C.y - A.y)) - ((B.y - A.y) * (C.x - A.x))))
|
||||
return false;
|
||||
for (p = 0; p < n; p++)
|
||||
{
|
||||
if ((p == u) || (p == v) || (p == w))
|
||||
continue;
|
||||
Vector2 P = points[V[p]];
|
||||
if (InsideTriangle(A, B, C, P))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool InsideTriangle(Vector2 A, Vector2 B, Vector2 C, Vector2 P)
|
||||
{
|
||||
float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
|
||||
float cCROSSap, bCROSScp, aCROSSbp;
|
||||
|
||||
ax = C.x - B.x; ay = C.y - B.y;
|
||||
bx = A.x - C.x; by = A.y - C.y;
|
||||
cx = B.x - A.x; cy = B.y - A.y;
|
||||
apx = P.x - A.x; apy = P.y - A.y;
|
||||
bpx = P.x - B.x; bpy = P.y - B.y;
|
||||
cpx = P.x - C.x; cpy = P.y - C.y;
|
||||
|
||||
aCROSSbp = ax * bpy - ay * bpx;
|
||||
cCROSSap = cx * apy - cy * apx;
|
||||
bCROSScp = bx * cpy - by * cpx;
|
||||
|
||||
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
12
Assets/Plugins/Dreamteck/Utilities/MeshUtility.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81cc5b669f819ca42a81d2c18c654e23
|
||||
timeCreated: 1450542790
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Assets/Plugins/Dreamteck/Utilities/PrivateSingleton.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
namespace Dreamteck
|
||||
{
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class PrivateSingleton<T> : MonoBehaviour where T : Component
|
||||
{
|
||||
[SerializeField] protected bool _dontDestryOnLoad = true;
|
||||
[SerializeField] protected bool _overrideInstance = false;
|
||||
|
||||
protected static T _instance;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (_instance != null && _instance != this)
|
||||
{
|
||||
if (_overrideInstance)
|
||||
{
|
||||
Destroy(_instance.gameObject);
|
||||
_instance = this as T;
|
||||
Init();
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_instance = this as T;
|
||||
|
||||
if (_dontDestryOnLoad)
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Init()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
if (_instance == this && !_overrideInstance)
|
||||
{
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/PrivateSingleton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb49526ef2768364fb4acea66dc04ffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2
Assets/Plugins/Dreamteck/Utilities/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# ultilities
|
||||
A collection of utility classes used for various Unity editor and runtime operations.
|
||||
7
Assets/Plugins/Dreamteck/Utilities/README.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e66a4f5bfa74d347aa6d489d75f2b00
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
Assets/Plugins/Dreamteck/Utilities/Randomizer.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
namespace Dreamteck.Utilities
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public class Randomizer
|
||||
{
|
||||
private int _seed;
|
||||
private System.Random _random;
|
||||
|
||||
public System.Random random => _random;
|
||||
|
||||
public Randomizer(int seed)
|
||||
{
|
||||
_seed = seed;
|
||||
_random = new System.Random(_seed);
|
||||
}
|
||||
|
||||
public float Random01()
|
||||
{
|
||||
return (float)_random.NextDouble();
|
||||
}
|
||||
|
||||
public float Random(float min, float max)
|
||||
{
|
||||
return (float)DMath.Lerp(min, max, _random.NextDouble());
|
||||
}
|
||||
|
||||
public int Random(int min, int max)
|
||||
{
|
||||
return (int)DMath.Lerp(min, max, _random.NextDouble());
|
||||
}
|
||||
|
||||
public Vector2 RandomVector2(float min, float max)
|
||||
{
|
||||
return new Vector2(Random(min, max), Random(min, max));
|
||||
}
|
||||
|
||||
public Vector3 RandomVector3(float min, float max)
|
||||
{
|
||||
return new Vector3(Random(min, max), Random(min, max), Random(min, max));
|
||||
}
|
||||
|
||||
public Vector3 OnUnitSphere()
|
||||
{
|
||||
return Quaternion.Euler(Random(0f, 360f), Random(0f, 360f), Random(0f, 360f)) * Vector3.forward;
|
||||
}
|
||||
|
||||
public Vector3 OnUnitCircle()
|
||||
{
|
||||
return Quaternion.AngleAxis(Random(0f, 360f), Vector3.forward) * Vector3.up;
|
||||
}
|
||||
|
||||
public Vector3 InsideUnitSphere()
|
||||
{
|
||||
return OnUnitSphere() * Random01();
|
||||
}
|
||||
|
||||
public Vector3 InsideUnitCircle()
|
||||
{
|
||||
return OnUnitCircle() * Random01();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_random = new System.Random(_seed);
|
||||
}
|
||||
|
||||
public void Reset(int seed)
|
||||
{
|
||||
_random = new System.Random(seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/Randomizer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d76cd13905daa94587b47d8dc4d2ee5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Assets/Plugins/Dreamteck/Utilities/SceneUtility.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
namespace Dreamteck
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public static class SceneUtility
|
||||
{
|
||||
public static List<Transform> childrenList = new List<Transform>();
|
||||
|
||||
public static void GetChildrenRecursively(Transform current)
|
||||
{
|
||||
childrenList.Clear();
|
||||
GetChildrenRecursivelyInternal(current);
|
||||
}
|
||||
|
||||
private static void GetChildrenRecursivelyInternal(Transform current)
|
||||
{
|
||||
childrenList.Add(current);
|
||||
int childCount = current.childCount;
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
GetChildrenRecursivelyInternal(current.GetChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static T[] GetComponentsInChildrenRecusrively<T>(this GameObject gameObject) where T : Component
|
||||
{
|
||||
GetChildrenRecursively(gameObject.transform);
|
||||
List<T> components = new List<T>();
|
||||
for (int i = 0; i < childrenList.Count; i++)
|
||||
{
|
||||
T component = childrenList[i].GetComponent<T>();
|
||||
if(component != null)
|
||||
{
|
||||
components.Add(component);
|
||||
}
|
||||
}
|
||||
return components.ToArray();
|
||||
}
|
||||
|
||||
public static void GetChildrenRecursively(Transform current, ref List<Transform> transformList)
|
||||
{
|
||||
transformList.Add(current);
|
||||
foreach (Transform child in current) GetChildrenRecursively(child, ref transformList);
|
||||
}
|
||||
|
||||
public static T GetComponentInScene<T>(this Scene scene, string objectName = null) where T : Component
|
||||
{
|
||||
var component = default(T);
|
||||
var rootObjects = scene.GetRootGameObjects();
|
||||
|
||||
foreach (var obj in rootObjects)
|
||||
{
|
||||
if (objectName != null && obj.name != objectName) continue;
|
||||
component = obj.GetComponentInChildren<T>();
|
||||
if(component != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public static T[] GetComponentsInScene<T>(this Scene scene, string objectName = null, bool includeInactive = false)
|
||||
{
|
||||
var rootObjects = scene.GetRootGameObjects();
|
||||
var components = new List<T>();
|
||||
|
||||
foreach (var obj in rootObjects)
|
||||
{
|
||||
var rootComponent = obj.GetComponent<T>();
|
||||
|
||||
if (rootComponent != null && (objectName == null || (objectName != null && obj.gameObject.name == obj.name)))
|
||||
{
|
||||
components.Add(rootComponent);
|
||||
}
|
||||
|
||||
var foundComponents = obj.GetComponentsInChildren<T>(includeInactive);
|
||||
|
||||
for (int i = 0; i < foundComponents.Length; i++)
|
||||
{
|
||||
var component = foundComponents[i] as Component;
|
||||
|
||||
if (objectName != null && component != null && component.gameObject.name != objectName) continue;
|
||||
|
||||
components.Add(foundComponents[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return components.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Plugins/Dreamteck/Utilities/SceneUtility.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5c6af18f0a94e34b8500b13d07331d6
|
||||
timeCreated: 1504129319
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
#if UNITY_EDITOR
|
||||
namespace Dreamteck {
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public static class ScriptableObjectUtility
|
||||
{
|
||||
public static T CreateAsset<T>(string name = "", bool selectAfterCreation = true) where T : ScriptableObject
|
||||
{
|
||||
T asset = ScriptableObject.CreateInstance<T>();
|
||||
SaveAsset(asset, name, selectAfterCreation);
|
||||
return asset;
|
||||
}
|
||||
|
||||
public static ScriptableObject CreateAsset(string type, string name = "", bool selectAfterCreation = true)
|
||||
{
|
||||
ScriptableObject asset = ScriptableObject.CreateInstance(type);
|
||||
SaveAsset<ScriptableObject>(asset, name, selectAfterCreation);
|
||||
return asset;
|
||||
}
|
||||
|
||||
static void SaveAsset<T>(T asset, string name = "", bool selectAfterCreation = true) where T : ScriptableObject
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
|
||||
if (path == "")
|
||||
{
|
||||
path = "Assets";
|
||||
}
|
||||
else if (Path.GetExtension(path) != "")
|
||||
{
|
||||
path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
|
||||
}
|
||||
string assetName = "New " + typeof(T).ToString();
|
||||
if (name != "") assetName = name;
|
||||
if(!path.EndsWith("/"))
|
||||
{
|
||||
path += "/";
|
||||
}
|
||||
string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + assetName + ".asset");
|
||||
AssetDatabase.CreateAsset(asset, assetPathAndName);
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.FocusProjectWindow();
|
||||
if (selectAfterCreation)
|
||||
{
|
||||
Selection.activeObject = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85e4f0317c6ed394cb416b5bf4fe4c59
|
||||
timeCreated: 1470333114
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Plugins/Dreamteck/Utilities/Singleton.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace Dreamteck
|
||||
{
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class Singleton<T> : PrivateSingleton<T> where T : Component
|
||||
{
|
||||
public static T instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = Object.FindObjectsOfType<T>().FirstOrDefault();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/Singleton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 656f05929b8fd1b4eb519de915c24212
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
66
Assets/Plugins/Dreamteck/Utilities/TS_Bounds.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
[System.Serializable]
|
||||
public class TS_Bounds
|
||||
{
|
||||
public Vector3 center = Vector3.zero;
|
||||
public Vector3 extents = Vector3.zero;
|
||||
public Vector3 max = Vector3.zero;
|
||||
public Vector3 min = Vector3.zero;
|
||||
public Vector3 size = Vector3.zero;
|
||||
|
||||
public TS_Bounds()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TS_Bounds(Bounds bounds)
|
||||
{
|
||||
center = bounds.center;
|
||||
extents = bounds.extents;
|
||||
max = bounds.max;
|
||||
min = bounds.min;
|
||||
size = bounds.size;
|
||||
}
|
||||
|
||||
public TS_Bounds(Vector3 c, Vector3 s)
|
||||
{
|
||||
center = c;
|
||||
size = s;
|
||||
extents = s / 2;
|
||||
max = center + extents;
|
||||
min = center - extents;
|
||||
}
|
||||
|
||||
public TS_Bounds(Vector3 min, Vector3 max, Vector3 center)
|
||||
{
|
||||
size = new Vector3(max.x - min.x, max.y - min.y, max.z - min.z);
|
||||
extents = size / 2f;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
public void CreateFromMinMax(Vector3 min, Vector3 max)
|
||||
{
|
||||
size.x = max.x - min.x;
|
||||
size.y = max.y - min.y;
|
||||
size.z = max.z - min.z;
|
||||
extents = size / 2f;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
center = (Vector3.Lerp(min, max, 0.5f));
|
||||
}
|
||||
|
||||
public bool Contains(Vector3 point)
|
||||
{
|
||||
if (point.x < min.x || point.x > max.x) return false;
|
||||
if (point.y < min.y || point.y > max.y) return false;
|
||||
if (point.z < min.z || point.z > max.z) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Plugins/Dreamteck/Utilities/TS_Bounds.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c28a6bb56e8cee4fb7dd9a493afbf83
|
||||
timeCreated: 1463695116
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
392
Assets/Plugins/Dreamteck/Utilities/TS_Mesh.cs
Normal file
@@ -0,0 +1,392 @@
|
||||
namespace Dreamteck
|
||||
{
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
//Thread-safe mesh & bounds classes for working with threads.
|
||||
public class TS_Mesh
|
||||
{
|
||||
public int vertexCount
|
||||
{
|
||||
get { return vertices.Length; }
|
||||
set { }
|
||||
}
|
||||
public Vector3[] vertices = new Vector3[0];
|
||||
public Vector3[] normals = new Vector3[0];
|
||||
public Vector4[] tangents = new Vector4[0];
|
||||
public Color[] colors = new Color[0];
|
||||
public Vector2[] uv = new Vector2[0];
|
||||
public Vector2[] uv2 = new Vector2[0];
|
||||
public Vector2[] uv3 = new Vector2[0];
|
||||
public Vector2[] uv4 = new Vector2[0];
|
||||
public int[] triangles = new int[0];
|
||||
public List<int[]> subMeshes = new List<int[]>();
|
||||
public TS_Bounds bounds = new TS_Bounds(Vector3.zero, Vector3.zero);
|
||||
public UnityEngine.Rendering.IndexFormat indexFormat = UnityEngine.Rendering.IndexFormat.UInt16;
|
||||
|
||||
public volatile bool hasUpdate = false;
|
||||
|
||||
private int[] _submeshTrisCount = new int[0];
|
||||
private int[] _submeshOffsets = new int[0];
|
||||
|
||||
|
||||
public TS_Mesh()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TS_Mesh(Mesh mesh)
|
||||
{
|
||||
CreateFromMesh(mesh);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
vertices = new Vector3[0];
|
||||
normals = new Vector3[0];
|
||||
tangents = new Vector4[0];
|
||||
colors = new Color[0];
|
||||
uv = new Vector2[0];
|
||||
uv2 = new Vector2[0];
|
||||
uv3 = new Vector2[0];
|
||||
uv4 = new Vector2[0];
|
||||
triangles = new int[0];
|
||||
subMeshes = new List<int[]>();
|
||||
bounds = new TS_Bounds(Vector3.zero, Vector3.zero);
|
||||
}
|
||||
|
||||
public void CreateFromMesh(Mesh mesh)
|
||||
{
|
||||
vertices = mesh.vertices;
|
||||
normals = mesh.normals;
|
||||
tangents = mesh.tangents;
|
||||
colors = mesh.colors;
|
||||
uv = mesh.uv;
|
||||
uv2 = mesh.uv2;
|
||||
uv3 = mesh.uv3;
|
||||
uv4 = mesh.uv4;
|
||||
triangles = mesh.triangles;
|
||||
bounds = new TS_Bounds(mesh.bounds);
|
||||
indexFormat = mesh.indexFormat;
|
||||
for (int i = 0; i < mesh.subMeshCount; i++)
|
||||
{
|
||||
subMeshes.Add(mesh.GetTriangles(i));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the combineMeshes array to the current TS_Mesh object and tries to not allocate memory
|
||||
/// </summary>
|
||||
/// <param name="combineMeshes"></param>
|
||||
public void Combine(List<TS_Mesh> combineMeshes)
|
||||
{
|
||||
int totalVertexCount = 0;
|
||||
int totalTrisCount = 0;
|
||||
int addedSubmeshCount = 0;
|
||||
|
||||
for (int i = 0; i < combineMeshes.Count; i++)
|
||||
{
|
||||
totalVertexCount += combineMeshes[i].vertices.Length;
|
||||
totalTrisCount += combineMeshes[i].triangles.Length;
|
||||
if (combineMeshes[i].subMeshes.Count > addedSubmeshCount)
|
||||
{
|
||||
addedSubmeshCount = combineMeshes[i].subMeshes.Count;
|
||||
}
|
||||
}
|
||||
|
||||
if (_submeshTrisCount.Length != addedSubmeshCount)
|
||||
{
|
||||
_submeshTrisCount = new int[addedSubmeshCount];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _submeshTrisCount.Length; i++)
|
||||
{
|
||||
_submeshTrisCount[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < combineMeshes.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < combineMeshes[i].subMeshes.Count; j++)
|
||||
{
|
||||
_submeshTrisCount[j] += combineMeshes[i].subMeshes[j].Length;
|
||||
}
|
||||
}
|
||||
|
||||
if (vertices.Length != totalVertexCount) vertices = new Vector3[totalVertexCount];
|
||||
if (normals.Length != totalVertexCount) normals = new Vector3[totalVertexCount];
|
||||
if (uv.Length != totalVertexCount) uv = new Vector2[totalVertexCount];
|
||||
if (uv2.Length != totalVertexCount) uv2 = new Vector2[totalVertexCount];
|
||||
if (uv3.Length != totalVertexCount) uv3 = new Vector2[totalVertexCount];
|
||||
if (uv4.Length != totalVertexCount) uv4 = new Vector2[totalVertexCount];
|
||||
if (colors.Length != totalVertexCount) colors = new Color[totalVertexCount];
|
||||
if (tangents.Length != totalVertexCount) tangents = new Vector4[totalVertexCount];
|
||||
if (triangles.Length != totalTrisCount) triangles = new int[totalTrisCount];
|
||||
if (subMeshes.Count > addedSubmeshCount) subMeshes.Clear();
|
||||
|
||||
int vertexOffset = 0;
|
||||
int trisOffset = 0;
|
||||
|
||||
if(_submeshOffsets.Length != addedSubmeshCount)
|
||||
{
|
||||
_submeshOffsets = new int[addedSubmeshCount];
|
||||
} else
|
||||
{
|
||||
for (int i = 0; i < _submeshOffsets.Length; i++)
|
||||
{
|
||||
_submeshOffsets[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < combineMeshes.Count; i++)
|
||||
{
|
||||
combineMeshes[i].vertices.CopyTo(vertices, vertexOffset);
|
||||
combineMeshes[i].normals.CopyTo(normals, vertexOffset);
|
||||
combineMeshes[i].uv.CopyTo(uv, vertexOffset);
|
||||
combineMeshes[i].uv2.CopyTo(uv2, vertexOffset);
|
||||
combineMeshes[i].uv3.CopyTo(uv3, vertexOffset);
|
||||
combineMeshes[i].uv4.CopyTo(uv4, vertexOffset);
|
||||
combineMeshes[i].colors.CopyTo(colors, vertexOffset);
|
||||
combineMeshes[i].tangents.CopyTo(tangents, vertexOffset);
|
||||
|
||||
for (int t = 0; t < combineMeshes[i].triangles.Length; t++)
|
||||
{
|
||||
int index = t + trisOffset;
|
||||
triangles[index] = combineMeshes[i].triangles[t] + vertexOffset;
|
||||
}
|
||||
|
||||
trisOffset += combineMeshes[i].triangles.Length;
|
||||
|
||||
for (int j = 0; j < combineMeshes[i].subMeshes.Count; j++)
|
||||
{
|
||||
if (j >= subMeshes.Count)
|
||||
{
|
||||
subMeshes.Add(new int[_submeshTrisCount[j]]);
|
||||
}
|
||||
else if (subMeshes[j].Length != _submeshTrisCount[j])
|
||||
{
|
||||
subMeshes[j] = new int[_submeshTrisCount[j]];
|
||||
}
|
||||
int[] submesh = combineMeshes[i].subMeshes[j];
|
||||
|
||||
for (int x = 0; x < submesh.Length; x++)
|
||||
{
|
||||
int index = _submeshOffsets[j] + x;
|
||||
subMeshes[j][index] = submesh[x] + vertexOffset;
|
||||
}
|
||||
_submeshOffsets[j] += submesh.Length;
|
||||
}
|
||||
vertexOffset += combineMeshes[i].vertices.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the provieded mesh list to the current mesh and allocates memory
|
||||
/// </summary>
|
||||
/// <param name="addedMeshes"></param>
|
||||
public void AddMeshes(List<TS_Mesh> addedMeshes)
|
||||
{
|
||||
int newVerts = 0;
|
||||
int newTris = 0;
|
||||
int submeshCount = 0;
|
||||
for (int i = 0; i < addedMeshes.Count; i++)
|
||||
{
|
||||
newVerts += addedMeshes[i].vertexCount;
|
||||
newTris += addedMeshes[i].triangles.Length;
|
||||
if (addedMeshes[i].subMeshes.Count > submeshCount)
|
||||
{
|
||||
submeshCount = addedMeshes[i].subMeshes.Count;
|
||||
}
|
||||
}
|
||||
int[] submeshTrisCount = new int[submeshCount];
|
||||
int[] submeshOffsets = new int[submeshCount];
|
||||
for (int i = 0; i < addedMeshes.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < addedMeshes[i].subMeshes.Count; j++)
|
||||
{
|
||||
submeshTrisCount[j] += addedMeshes[i].subMeshes[j].Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vector3[] newVertices = new Vector3[vertices.Length + newVerts];
|
||||
Vector3[] newNormals = new Vector3[vertices.Length + newVerts];
|
||||
Vector2[] newUvs = new Vector2[vertices.Length + newVerts];
|
||||
Vector2[] newUvs2 = new Vector2[vertices.Length + newVerts];
|
||||
Vector2[] newUvs3 = new Vector2[vertices.Length + newVerts];
|
||||
Vector2[] newUvs4 = new Vector2[vertices.Length + newVerts];
|
||||
Color[] newColors = new Color[vertices.Length + newVerts];
|
||||
Vector4[] newTangents = new Vector4[tangents.Length + newVerts];
|
||||
int[] newTriangles = new int[triangles.Length + newTris];
|
||||
List<int[]> newSubmeshes = new List<int[]>();
|
||||
|
||||
for (int i = 0; i < submeshTrisCount.Length; i++)
|
||||
{
|
||||
newSubmeshes.Add(new int[submeshTrisCount[i]]);
|
||||
if (i < subMeshes.Count)
|
||||
{
|
||||
submeshTrisCount[i] = subMeshes[i].Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
submeshTrisCount[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
newVerts = vertexCount;
|
||||
newTris = triangles.Length;
|
||||
vertices.CopyTo(newVertices, 0);
|
||||
normals.CopyTo(newNormals, 0);
|
||||
uv.CopyTo(newUvs, 0);
|
||||
uv2.CopyTo(newUvs2, 0);
|
||||
uv3.CopyTo(newUvs3, 0);
|
||||
uv4.CopyTo(newUvs4, 0);
|
||||
colors.CopyTo(newColors, 0);
|
||||
tangents.CopyTo(newTangents, 0);
|
||||
triangles.CopyTo(newTriangles, 0);
|
||||
|
||||
for (int i = 0; i < addedMeshes.Count; i++)
|
||||
{
|
||||
addedMeshes[i].vertices.CopyTo(newVertices, newVerts);
|
||||
addedMeshes[i].normals.CopyTo(newNormals, newVerts);
|
||||
addedMeshes[i].uv.CopyTo(newUvs, newVerts);
|
||||
addedMeshes[i].uv2.CopyTo(newUvs2, newVerts);
|
||||
addedMeshes[i].uv3.CopyTo(newUvs3, newVerts);
|
||||
addedMeshes[i].uv4.CopyTo(newUvs4, newVerts);
|
||||
addedMeshes[i].colors.CopyTo(newColors, newVerts);
|
||||
addedMeshes[i].tangents.CopyTo(newTangents, newVerts);
|
||||
|
||||
for (int n = newTris; n < newTris + addedMeshes[i].triangles.Length; n++)
|
||||
{
|
||||
newTriangles[n] = addedMeshes[i].triangles[n - newTris] + newVerts;
|
||||
}
|
||||
|
||||
|
||||
for (int n = 0; n < addedMeshes[i].subMeshes.Count; n++)
|
||||
{
|
||||
for (int x = submeshTrisCount[n]; x < submeshTrisCount[n] + addedMeshes[i].subMeshes[n].Length; x++)
|
||||
{
|
||||
newSubmeshes[n][x] = addedMeshes[i].subMeshes[n][x - submeshTrisCount[n]] + newVerts;
|
||||
}
|
||||
submeshTrisCount[n] += addedMeshes[i].subMeshes[n].Length;
|
||||
}
|
||||
newTris += addedMeshes[i].triangles.Length;
|
||||
newVerts += addedMeshes[i].vertexCount;
|
||||
}
|
||||
|
||||
vertices = newVertices;
|
||||
normals = newNormals;
|
||||
uv = newUvs;
|
||||
uv2 = newUvs2;
|
||||
uv3 = newUvs3;
|
||||
uv4 = newUvs4;
|
||||
colors = newColors;
|
||||
tangents = newTangents;
|
||||
triangles = newTriangles;
|
||||
subMeshes = newSubmeshes;
|
||||
}
|
||||
|
||||
public static TS_Mesh Copy(TS_Mesh input)
|
||||
{
|
||||
TS_Mesh result = new TS_Mesh();
|
||||
result.vertices = new Vector3[input.vertices.Length];
|
||||
input.vertices.CopyTo(result.vertices, 0);
|
||||
result.normals = new Vector3[input.normals.Length];
|
||||
input.normals.CopyTo(result.normals, 0);
|
||||
result.uv = new Vector2[input.uv.Length];
|
||||
input.uv.CopyTo(result.uv, 0);
|
||||
result.uv2 = new Vector2[input.uv2.Length];
|
||||
input.uv2.CopyTo(result.uv2, 0);
|
||||
result.uv3 = new Vector2[input.uv3.Length];
|
||||
input.uv3.CopyTo(result.uv3, 0);
|
||||
result.uv4 = new Vector2[input.uv4.Length];
|
||||
input.uv4.CopyTo(result.uv4, 0);
|
||||
result.colors = new Color[input.colors.Length];
|
||||
input.colors.CopyTo(result.colors, 0);
|
||||
result.tangents = new Vector4[input.tangents.Length];
|
||||
input.tangents.CopyTo(result.tangents, 0);
|
||||
result.triangles = new int[input.triangles.Length];
|
||||
input.triangles.CopyTo(result.triangles, 0);
|
||||
result.subMeshes = new List<int[]>();
|
||||
for(int i = 0; i < input.subMeshes.Count; i++)
|
||||
{
|
||||
result.subMeshes.Add(new int[input.subMeshes[i].Length]);
|
||||
input.subMeshes[i].CopyTo(result.subMeshes[i], 0);
|
||||
}
|
||||
result.bounds = new TS_Bounds(input.bounds.center, input.bounds.size);
|
||||
result.indexFormat = input.indexFormat;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Absorb(TS_Mesh input)
|
||||
{
|
||||
if (vertices.Length != input.vertexCount) vertices = new Vector3[input.vertexCount];
|
||||
if (normals.Length != input.normals.Length) normals = new Vector3[input.normals.Length];
|
||||
if (colors.Length != input.colors.Length) colors = new Color[input.colors.Length];
|
||||
if (uv.Length != input.uv.Length) uv = new Vector2[input.uv.Length];
|
||||
if (uv2.Length != input.uv2.Length) uv2 = new Vector2[input.uv2.Length];
|
||||
if (uv3.Length != input.uv3.Length) uv3 = new Vector2[input.uv3.Length];
|
||||
if (uv4.Length != input.uv4.Length) uv4 = new Vector2[input.uv4.Length];
|
||||
if (tangents.Length != input.tangents.Length) tangents = new Vector4[input.tangents.Length];
|
||||
if (triangles.Length != input.triangles.Length) triangles = new int[input.triangles.Length];
|
||||
|
||||
input.vertices.CopyTo(vertices, 0);
|
||||
input.normals.CopyTo(normals, 0);
|
||||
input.colors.CopyTo(colors, 0);
|
||||
input.uv.CopyTo(uv, 0);
|
||||
input.uv2.CopyTo(uv2, 0);
|
||||
input.uv3.CopyTo(uv3, 0);
|
||||
input.uv4.CopyTo(uv4, 0);
|
||||
input.tangents.CopyTo(tangents, 0);
|
||||
input.triangles.CopyTo(triangles, 0);
|
||||
|
||||
if (subMeshes.Count == input.subMeshes.Count)
|
||||
{
|
||||
for (int i = 0; i < subMeshes.Count; i++)
|
||||
{
|
||||
if (input.subMeshes[i].Length != subMeshes[i].Length) subMeshes[i] = new int[input.subMeshes[i].Length];
|
||||
input.subMeshes[i].CopyTo(subMeshes[i], 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
subMeshes = new List<int[]>();
|
||||
for (int i = 0; i < input.subMeshes.Count; i++)
|
||||
{
|
||||
subMeshes.Add(new int[input.subMeshes[i].Length]);
|
||||
input.subMeshes[i].CopyTo(subMeshes[i], 0);
|
||||
}
|
||||
}
|
||||
bounds = new TS_Bounds(input.bounds.center, input.bounds.size);
|
||||
}
|
||||
|
||||
public void WriteMesh(ref Mesh input)
|
||||
{
|
||||
if (input == null) input = new Mesh();
|
||||
input.Clear();
|
||||
input.indexFormat = indexFormat;
|
||||
input.vertices = vertices;
|
||||
input.normals = normals;
|
||||
if (tangents.Length == vertices.Length) input.tangents = tangents;
|
||||
if (colors.Length == vertices.Length) input.colors = colors;
|
||||
if (uv.Length == vertices.Length) input.uv = uv;
|
||||
if (uv2.Length == vertices.Length) input.uv2 = uv2;
|
||||
if (uv3.Length == vertices.Length) input.uv3 = uv3;
|
||||
if (uv4.Length == vertices.Length) input.uv4 = uv4;
|
||||
input.triangles = triangles;
|
||||
if (subMeshes.Count > 0)
|
||||
{
|
||||
input.subMeshCount = subMeshes.Count;
|
||||
for (int i = 0; i < subMeshes.Count; i++)
|
||||
{
|
||||
input.SetTriangles(subMeshes[i], i);
|
||||
}
|
||||
}
|
||||
input.RecalculateBounds();
|
||||
hasUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Plugins/Dreamteck/Utilities/TS_Mesh.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ca64fd6869620449bcb61d4f66c798e
|
||||
timeCreated: 1447354835
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
317
Assets/Plugins/Dreamteck/Utilities/TS_Transform.cs
Normal file
@@ -0,0 +1,317 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
[System.Serializable]
|
||||
public class TS_Transform
|
||||
{
|
||||
public Vector3 position
|
||||
{
|
||||
get { return new Vector3(posX, posY, posZ); }
|
||||
set
|
||||
{
|
||||
setPosition = true;
|
||||
setLocalPosition = false;
|
||||
posX = value.x;
|
||||
posY = value.y;
|
||||
posZ = value.z;
|
||||
}
|
||||
}
|
||||
public Quaternion rotation
|
||||
{
|
||||
get { return new Quaternion(rotX, rotY, rotZ, rotW); }
|
||||
set
|
||||
{
|
||||
setRotation = true;
|
||||
setLocalRotation = false;
|
||||
rotX = value.x;
|
||||
rotY = value.y;
|
||||
rotZ = value.z;
|
||||
rotW = value.w;
|
||||
}
|
||||
}
|
||||
public Vector3 scale
|
||||
{
|
||||
get { return new Vector3(scaleX, scaleY, scaleZ); }
|
||||
set
|
||||
{
|
||||
setScale = true;
|
||||
scaleX = value.x;
|
||||
scaleY = value.y;
|
||||
scaleZ = value.z;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 lossyScale
|
||||
{
|
||||
get { return new Vector3(lossyScaleX, lossyScaleY, lossyScaleZ); }
|
||||
set
|
||||
{
|
||||
setScale = true;
|
||||
lossyScaleX = value.x;
|
||||
lossyScaleY = value.y;
|
||||
lossyScaleZ = value.z;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 localPosition
|
||||
{
|
||||
get { return new Vector3(lposX, lposY, lposZ); }
|
||||
set
|
||||
{
|
||||
setLocalPosition = true;
|
||||
setPosition = false;
|
||||
lposX = value.x;
|
||||
lposY = value.y;
|
||||
lposZ = value.z;
|
||||
}
|
||||
}
|
||||
public Quaternion localRotation
|
||||
{
|
||||
get { return new Quaternion(lrotX, lrotY, lrotZ, lrotW); }
|
||||
set
|
||||
{
|
||||
setLocalRotation = true;
|
||||
setRotation = false;
|
||||
lrotX = value.x;
|
||||
lrotY = value.y;
|
||||
lrotZ = value.z;
|
||||
lrotW = value.w;
|
||||
}
|
||||
}
|
||||
|
||||
private bool setPosition = false;
|
||||
private bool setRotation = false;
|
||||
private bool setScale = false;
|
||||
private bool setLocalPosition = false;
|
||||
private bool setLocalRotation = false;
|
||||
|
||||
public Transform transform
|
||||
{
|
||||
get
|
||||
{
|
||||
return _transform;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private Transform _transform;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float posX = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float posY = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float posZ = 0f;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float scaleX = 1f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float scaleY = 1f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float scaleZ = 1f;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lossyScaleX = 1f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lossyScaleY = 1f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lossyScaleZ = 1f;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float rotX = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float rotY = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float rotZ = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float rotW = 0f;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lposX = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lposY = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lposZ = 0f;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lrotX = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lrotY = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lrotZ = 0f;
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private volatile float lrotW = 0f;
|
||||
#if UNITY_EDITOR
|
||||
private volatile bool isPlaying = false;
|
||||
#endif
|
||||
|
||||
public TS_Transform(Transform input)
|
||||
{
|
||||
SetTransform(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the TS_Transform. Call this regularly on every frame you need it to update. Should ALWAYS be called from the main thread
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
if (transform == null) return;
|
||||
#if UNITY_EDITOR
|
||||
isPlaying = Application.isPlaying;
|
||||
#endif
|
||||
if (setPosition) _transform.position = position;
|
||||
else if (setLocalPosition) _transform.localPosition = localPosition;
|
||||
else
|
||||
{
|
||||
position = _transform.position;
|
||||
localPosition = _transform.localPosition;
|
||||
}
|
||||
|
||||
if (setScale) _transform.localScale = scale;
|
||||
else scale = _transform.localScale;
|
||||
lossyScale = _transform.lossyScale;
|
||||
|
||||
|
||||
if (setRotation) _transform.rotation = rotation;
|
||||
else if (setLocalRotation) _transform.localRotation = localRotation;
|
||||
else
|
||||
{
|
||||
rotation = _transform.rotation;
|
||||
localRotation = _transform.localRotation;
|
||||
}
|
||||
setPosition = setLocalPosition = setRotation = setLocalRotation = setScale = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the transform reference. Should ALWAYS be called from the main thread
|
||||
/// </summary>
|
||||
/// <param name="input">Transform reference</param>
|
||||
public void SetTransform(Transform input)
|
||||
{
|
||||
_transform = input;
|
||||
setPosition = setLocalPosition = setRotation = setLocalRotation = setScale = false;
|
||||
Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there's any change in the transform. Should ALWAYS be called from the main thread
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool HasChange()
|
||||
{
|
||||
return HasPositionChange() || HasRotationChange() || HasScaleChange();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there's a change in the position. Should ALWAYS be called from the main thread
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool HasPositionChange()
|
||||
{
|
||||
return posX != _transform.position.x || posY != _transform.position.y || posZ != _transform.position.z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there is a change in the rotation. Should ALWAYS be called from the main thread
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool HasRotationChange()
|
||||
{
|
||||
return rotX != _transform.rotation.x || rotY != _transform.rotation.y || rotZ != _transform.rotation.z || rotW != _transform.rotation.w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there is a change in the scale. Should ALWAYS be called from the main thread
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool HasScaleChange()
|
||||
{
|
||||
return lossyScaleX != _transform.lossyScale.x || lossyScaleY != _transform.lossyScale.y || lossyScaleZ != _transform.lossyScale.z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thread-safe TransformPoint
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <returns></returns>
|
||||
public Vector3 TransformPoint(Vector3 point)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!isPlaying) return transform.TransformPoint(point);
|
||||
#endif
|
||||
Vector3 scaled = new Vector3(point.x * lossyScaleX, point.y * lossyScaleY, point.z * lossyScaleZ);
|
||||
Vector3 rotated = rotation * scaled;
|
||||
return position + rotated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thread-safe TransformDirection
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public Vector3 TransformDirection(Vector3 direction)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!isPlaying) return transform.TransformDirection(direction);
|
||||
#endif
|
||||
return TransformPoint(direction) - position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thread-safe InverseTransformPoint
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <returns></returns>
|
||||
public Vector3 InverseTransformPoint(Vector3 point)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!isPlaying) return transform.InverseTransformPoint(point);
|
||||
#endif
|
||||
return InverseTransformDirection(point - position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thread-safe InverseTransformDirection
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public Vector3 InverseTransformDirection(Vector3 direction)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!isPlaying) return transform.InverseTransformDirection(direction);
|
||||
#endif
|
||||
Vector3 rotated = Quaternion.Inverse(rotation) * direction;
|
||||
return new Vector3(rotated.x / lossyScaleX, rotated.y / lossyScaleY, rotated.z / lossyScaleZ);
|
||||
}
|
||||
|
||||
public T GetComponent<T>()
|
||||
{
|
||||
return _transform.GetComponent<T>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Plugins/Dreamteck/Utilities/TS_Transform.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c22a5076c8dce1b40a2a12e5bc7abc69
|
||||
timeCreated: 1463604029
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Assets/Plugins/Dreamteck/Utilities/TransformUtility.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Dreamteck
|
||||
{
|
||||
public static class TransformUtility
|
||||
{
|
||||
public static Vector3 GetPosition(Matrix4x4 m)
|
||||
{
|
||||
return m.GetColumn(3);
|
||||
}
|
||||
|
||||
public static Quaternion GetRotation(Matrix4x4 m)
|
||||
{
|
||||
return Quaternion.LookRotation(m.GetColumn(2), m.GetColumn(1));
|
||||
}
|
||||
|
||||
public static Vector3 GetScale(Matrix4x4 m)
|
||||
{
|
||||
return new Vector3(m.GetColumn(0).magnitude, m.GetColumn(1).magnitude, m.GetColumn(2).magnitude);
|
||||
}
|
||||
|
||||
public static void SetPosition(ref Matrix4x4 m, ref Vector3 p)
|
||||
{
|
||||
m.SetColumn(3, new Vector4(p.x, p.y, p.z, 1f));
|
||||
}
|
||||
|
||||
public static void GetChildCount(Transform parent, ref int count)
|
||||
{
|
||||
foreach (Transform child in parent)
|
||||
{
|
||||
count++;
|
||||
GetChildCount(child, ref count);
|
||||
}
|
||||
}
|
||||
|
||||
public static void MergeBoundsRecursively(this Transform rootParent, Transform tr, ref Bounds bounds, string nameToIgnore = null)
|
||||
{
|
||||
foreach (Transform child in tr)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(nameToIgnore) && child.name == nameToIgnore)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
rootParent.MergeBoundsRecursively(child, ref bounds);
|
||||
|
||||
var meshFilter = child.GetComponent<MeshFilter>();
|
||||
|
||||
if (meshFilter == null) continue;
|
||||
if (meshFilter.sharedMesh == null)
|
||||
{
|
||||
Debug.LogError("MESH FILTER " + meshFilter.name + " IS MISSING A MESH");
|
||||
continue;
|
||||
}
|
||||
var min = child.TransformPoint(meshFilter.sharedMesh.bounds.min);
|
||||
var max = child.TransformPoint(meshFilter.sharedMesh.bounds.max);
|
||||
|
||||
bounds.Encapsulate(rootParent.InverseTransformPoint(min));
|
||||
bounds.Encapsulate(rootParent.InverseTransformPoint(max));
|
||||
}
|
||||
}
|
||||
|
||||
public static void DestroyChildren(this Transform src)
|
||||
{
|
||||
int count = src.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
UnityEngine.Object.Destroy(src.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsParent(Transform child, Transform parent)
|
||||
{
|
||||
Transform current = child;
|
||||
while(current.parent != null)
|
||||
{
|
||||
current = current.parent;
|
||||
if (current == parent) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/TransformUtility.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 157259bef35b27e4ebcccdd7e3eee86b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/Plugins/Dreamteck/Utilities/Utilities.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Dreamteck.Utilities
|
||||
{
|
||||
public static class Utilities
|
||||
{
|
||||
public static T SerializableClone<T>(this T obj)
|
||||
{
|
||||
return JsonUtility.FromJson<T>(JsonUtility.ToJson(obj));
|
||||
}
|
||||
|
||||
public static void Shuffle<T>(this IList<T> list)
|
||||
{
|
||||
int n = list.Count;
|
||||
while (n > 1)
|
||||
{
|
||||
n--;
|
||||
int k = UnityEngine.Random.Range(0, n + 1);
|
||||
list.Swap(k, n);
|
||||
}
|
||||
}
|
||||
public static void RemoveAtUnsorted<T>(this List<T> list, int i)
|
||||
{
|
||||
var last = list.Count - 1;
|
||||
list[i--] = list[last];
|
||||
list.RemoveAt(last);
|
||||
}
|
||||
|
||||
public static T PopLast<T>(this IList<T> list)
|
||||
{
|
||||
T last = list[list.Count - 1];
|
||||
list.RemoveAt(list.Count - 1);
|
||||
return last;
|
||||
}
|
||||
|
||||
public static void Swap<T>(this IList<T> list, int left, int right)
|
||||
{
|
||||
T value = list[left];
|
||||
list[left] = list[right];
|
||||
list[right] = value;
|
||||
}
|
||||
|
||||
public static void SafeInvoke(this Delegate del, params object[] parameters)
|
||||
{
|
||||
foreach (var handler in del.GetInvocationList())
|
||||
{
|
||||
try
|
||||
{
|
||||
handler.Method.Invoke(handler.Target, parameters);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogException(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static T PopRandom<T>(this List<T> list)
|
||||
{
|
||||
if (list.Count > 0)
|
||||
{
|
||||
int index = UnityEngine.Random.Range(0, list.Count);
|
||||
T element = list[index];
|
||||
list.RemoveAt(index);
|
||||
return element;
|
||||
}
|
||||
|
||||
throw new ArgumentException("Attempting to remove an element from an empty list");
|
||||
}
|
||||
|
||||
public static bool HasCommandLineArgument(string name)
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (args[i] == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Dreamteck/Utilities/Utilities.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d12765602d6ee04cbcfeb790254c378
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||