基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
8
Assets/Plugins/CW/Shared/Common/Required/Scripts.meta
Normal file
8
Assets/Plugins/CW/Shared/Common/Required/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebb371642e8bcb141a02849e93f43a37
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwCommon.cs
Normal file
16
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwCommon.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CW.Common
|
||||
{
|
||||
/// <summary>This class contains some useful methods used by this asset.</summary>
|
||||
internal static class CwShared
|
||||
{
|
||||
public const string HelpUrlPrefix = "https://carloswilkes.com/Documentation/Common#";
|
||||
|
||||
public const string ComponentMenuPrefix = "Common/CW ";
|
||||
|
||||
public const string GameObjectMenuPrefix = "GameObject/CW/Common/";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0de2c3cc880c084084779b3c82e4391
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
519
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwEditor.cs
Normal file
519
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwEditor.cs
Normal file
@@ -0,0 +1,519 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CW.Common
|
||||
{
|
||||
/// <summary>This is the base class for all inspectors.</summary>
|
||||
public abstract class CwEditor : UnityEditor.Editor
|
||||
{
|
||||
private static Stack<object> datas = new Stack<object>();
|
||||
|
||||
private static GUIContent customContent = new GUIContent();
|
||||
|
||||
private static List<Color> colors = new List<Color>();
|
||||
|
||||
private static List<float> labelWidths = new List<float>();
|
||||
|
||||
private static List<bool> mixedValues = new List<bool>();
|
||||
|
||||
public void GetTargets<T>(out T tgt, out T[] tgts)
|
||||
where T : Object
|
||||
{
|
||||
tgt = (T)target;
|
||||
tgts = System.Array.ConvertAll(targets, item => (T)item);
|
||||
}
|
||||
|
||||
public static void BeginData(SerializedObject newData)
|
||||
{
|
||||
datas.Push(newData);
|
||||
}
|
||||
|
||||
public static void BeginData(SerializedProperty newData)
|
||||
{
|
||||
datas.Push(newData);
|
||||
}
|
||||
|
||||
public static void EndData()
|
||||
{
|
||||
datas.Pop();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
BeginData(serializedObject);
|
||||
|
||||
ClearStacks();
|
||||
|
||||
Separator();
|
||||
|
||||
OnInspector();
|
||||
|
||||
Separator();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
EndData();
|
||||
}
|
||||
|
||||
protected void Each<T>(T[] tgts, System.Action<T> update, bool dirty = false, bool apply = false, string undo = null)
|
||||
where T : Object
|
||||
{
|
||||
if (string.IsNullOrEmpty(undo) == false)
|
||||
{
|
||||
Undo.RecordObjects(tgts, undo);
|
||||
}
|
||||
|
||||
if (apply == true)
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
foreach (var t in tgts)
|
||||
{
|
||||
update(t);
|
||||
|
||||
if (dirty == true)
|
||||
{
|
||||
EditorUtility.SetDirty(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected bool Any<T>(T[] tgts, System.Func<T, bool> check)
|
||||
where T : Object
|
||||
{
|
||||
foreach (var t in tgts)
|
||||
{
|
||||
if (check(t) == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool All<T>(T[] tgts, System.Func<T, bool> check)
|
||||
where T : Object
|
||||
{
|
||||
foreach (var t in tgts)
|
||||
{
|
||||
if (check(t) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Rect Reserve(float height = 19.0f)
|
||||
{
|
||||
var rect =
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.LabelField(string.Empty, GUILayout.Height(height), GUILayout.ExpandWidth(true), GUILayout.MinWidth(0.0f));
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static void Info(string message)
|
||||
{
|
||||
EditorGUILayout.HelpBox(StripRichText(message), MessageType.Info); // Help boxes can't display rich text for some reason, so strip it
|
||||
}
|
||||
|
||||
public static void Warning(string message)
|
||||
{
|
||||
EditorGUILayout.HelpBox(StripRichText(message), MessageType.Warning); // Help boxes can't display rich text for some reason, so strip it
|
||||
}
|
||||
|
||||
public static void Error(string message)
|
||||
{
|
||||
EditorGUILayout.HelpBox(StripRichText(message), MessageType.Error); // Help boxes can't display rich text for some reason, so strip it
|
||||
}
|
||||
|
||||
public static void Separator()
|
||||
{
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
|
||||
public static void BeginIndent()
|
||||
{
|
||||
EditorGUI.indentLevel += 1;
|
||||
}
|
||||
|
||||
public static void EndIndent()
|
||||
{
|
||||
EditorGUI.indentLevel -= 1;
|
||||
}
|
||||
|
||||
public static bool Button(string text)
|
||||
{
|
||||
return GUILayout.Button(text);
|
||||
}
|
||||
|
||||
public static bool HelpButton(string helpText, UnityEditor.MessageType type, string buttonText, float buttonWidth)
|
||||
{
|
||||
var clicked = false;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.HelpBox(helpText, type);
|
||||
|
||||
var style = new GUIStyle(GUI.skin.button); style.wordWrap = true;
|
||||
|
||||
clicked = GUILayout.Button(buttonText, style, GUILayout.ExpandHeight(true), GUILayout.Width(buttonWidth));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
return clicked;
|
||||
}
|
||||
|
||||
public static void ClearStacks()
|
||||
{
|
||||
while (colors.Count > 0)
|
||||
{
|
||||
EndColor();
|
||||
}
|
||||
|
||||
while (labelWidths.Count > 0)
|
||||
{
|
||||
EndLabelWidth();
|
||||
}
|
||||
|
||||
while (mixedValues.Count > 0)
|
||||
{
|
||||
EndMixedValue();
|
||||
}
|
||||
}
|
||||
|
||||
public static void BeginMixedValue(bool mixed = true)
|
||||
{
|
||||
mixedValues.Add(EditorGUI.showMixedValue);
|
||||
|
||||
EditorGUI.showMixedValue = mixed;
|
||||
}
|
||||
|
||||
public static void EndMixedValue()
|
||||
{
|
||||
if (mixedValues.Count > 0)
|
||||
{
|
||||
var index = mixedValues.Count - 1;
|
||||
|
||||
EditorGUI.showMixedValue = mixedValues[index];
|
||||
|
||||
mixedValues.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public static void BeginDisabled(bool disabled = true)
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(disabled);
|
||||
}
|
||||
|
||||
public static void EndDisabled()
|
||||
{
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
public static void BeginError(bool error = true)
|
||||
{
|
||||
BeginColor(Color.red, error);
|
||||
}
|
||||
|
||||
public static void EndError()
|
||||
{
|
||||
EndColor();
|
||||
}
|
||||
|
||||
public static void BeginColor(Color color, bool show = true)
|
||||
{
|
||||
colors.Add(GUI.color);
|
||||
|
||||
GUI.color = show == true ? color : colors[0];
|
||||
}
|
||||
|
||||
public static void EndColor()
|
||||
{
|
||||
if (colors.Count > 0)
|
||||
{
|
||||
var index = colors.Count - 1;
|
||||
|
||||
GUI.color = colors[index];
|
||||
|
||||
colors.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public static void BeginLabelWidth(float width)
|
||||
{
|
||||
labelWidths.Add(EditorGUIUtility.labelWidth);
|
||||
|
||||
EditorGUIUtility.labelWidth = width;
|
||||
}
|
||||
|
||||
public static void EndLabelWidth()
|
||||
{
|
||||
if (labelWidths.Count > 0)
|
||||
{
|
||||
var index = labelWidths.Count - 1;
|
||||
|
||||
EditorGUIUtility.labelWidth = labelWidths[index];
|
||||
|
||||
labelWidths.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DrawFoldout(string overrideText, string overrideTooltip, string propertyPath = "m_Name")
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
|
||||
property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, customContent);
|
||||
|
||||
return property.isExpanded;
|
||||
}
|
||||
|
||||
public static bool DrawExpand(string propertyPath, ref bool modified, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
var rect = EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(string.Empty, GUILayout.Height(EditorGUI.GetPropertyHeight(property))); EditorGUILayout.EndVertical();
|
||||
var rectF = rect; rectF.height = 16;
|
||||
|
||||
property.isExpanded = EditorGUI.Foldout(rectF, property.isExpanded, GUIContent.none);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUI.PropertyField(rect, property, customContent, true);
|
||||
|
||||
modified = EditorGUI.EndChangeCheck();
|
||||
|
||||
return property.isExpanded;
|
||||
}
|
||||
|
||||
public static bool DrawExpand(string propertyPath, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var modified = false; return DrawExpand(propertyPath, ref modified, overrideTooltip, overrideText);
|
||||
}
|
||||
|
||||
public static bool Draw(string propertyPath, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(property, customContent, true);
|
||||
|
||||
return EditorGUI.EndChangeCheck();
|
||||
}
|
||||
|
||||
public static void Draw(string propertyPath, ref bool dirty, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
if (Draw(propertyPath, overrideTooltip, overrideText) == true)
|
||||
{
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Draw(string propertyPath, ref bool dirty1, ref bool dirty2, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
if (Draw(propertyPath, overrideTooltip, overrideText) == true)
|
||||
{
|
||||
dirty1 = true;
|
||||
dirty2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DrawSlider(string propertyPath, float min, float max, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
var value = property.floatValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
value = EditorGUILayout.Slider(customContent, value, min, max);
|
||||
|
||||
if (EditorGUI.EndChangeCheck() == true)
|
||||
{
|
||||
property.floatValue = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool DrawIntSlider(string propertyPath, int min, int max, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
var value = property.intValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
value = EditorGUILayout.IntSlider(customContent, value, min, max);
|
||||
|
||||
if (EditorGUI.EndChangeCheck() == true)
|
||||
{
|
||||
property.intValue = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static bool DrawMinMax(string propertyPath, float min, float max, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
var value = property.vector2Value;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.MinMaxSlider(customContent, ref value.x, ref value.y, min, max);
|
||||
|
||||
if (EditorGUI.EndChangeCheck() == true)
|
||||
{
|
||||
property.vector2Value = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool DrawVector4(string propertyPath, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
var value = property.vector4Value;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
value = EditorGUILayout.Vector4Field(customContent, value);
|
||||
|
||||
if (EditorGUI.EndChangeCheck() == true)
|
||||
{
|
||||
property.vector4Value = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool DrawIntPopup(int[] values, GUIContent[] contents, string propertyPath, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.IntPopup(property, contents, values, customContent);
|
||||
|
||||
return EditorGUI.EndChangeCheck();
|
||||
}
|
||||
|
||||
public static void DrawIntPopup(int[] values, GUIContent[] contents, string propertyPath, ref bool modified, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
if (DrawIntPopup(values, contents, propertyPath, overrideTooltip, overrideText) == true)
|
||||
{
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DrawLayer(string propertyPath, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
var value = property.intValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
value = EditorGUILayout.LayerField(customContent, value);
|
||||
|
||||
if (EditorGUI.EndChangeCheck() == true)
|
||||
{
|
||||
property.intValue = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool DrawEulerAngles(string propertyPath, string overrideTooltip = null, string overrideText = null)
|
||||
{
|
||||
var property = GetPropertyAndSetCustomContent(propertyPath, overrideTooltip, overrideText);
|
||||
var value = property.quaternionValue.eulerAngles;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
BeginMixedValue(property.hasMultipleDifferentValues);
|
||||
value = EditorGUILayout.Vector3Field(customContent, value);
|
||||
EndMixedValue();
|
||||
|
||||
if (EditorGUI.EndChangeCheck() == true)
|
||||
{
|
||||
property.quaternionValue = Quaternion.Euler(value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void DirtyAndUpdate()
|
||||
{
|
||||
for (var i = targets.Length - 1; i >= 0; i--)
|
||||
{
|
||||
EditorUtility.SetDirty(targets[i]);
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
}
|
||||
|
||||
public static SerializedProperty GetProperty(string propertyPath)
|
||||
{
|
||||
var data = datas.Peek();
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
var dataA = data as SerializedObject;
|
||||
|
||||
if (dataA != null)
|
||||
{
|
||||
return dataA.FindProperty(propertyPath);
|
||||
}
|
||||
|
||||
var dataB = data as SerializedProperty;
|
||||
|
||||
if (dataB != null)
|
||||
{
|
||||
return dataB.FindPropertyRelative(propertyPath);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static SerializedProperty GetPropertyAndSetCustomContent(string propertyPath, string overrideTooltip, string overrideText)
|
||||
{
|
||||
var property = GetProperty(propertyPath);
|
||||
|
||||
customContent.text = string.IsNullOrEmpty(overrideText ) == false ? overrideText : property.displayName;
|
||||
customContent.tooltip = string.IsNullOrEmpty(overrideTooltip) == false ? overrideTooltip : property.tooltip;
|
||||
customContent.tooltip = StripRichText(customContent.tooltip); // Tooltips can't display rich text for some reason, so strip it
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
private static string StripRichText(string s)
|
||||
{
|
||||
return s.Replace("<b>", "").Replace("</b>", "");
|
||||
}
|
||||
|
||||
protected virtual void OnInspector()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6db2e50665ae04147b7ef6bf70fa0756
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
192
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwGuide.cs
Normal file
192
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwGuide.cs
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40a2a791e0ffb554885467adbda44772
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1009
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwHelper.cs
Normal file
1009
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwHelper.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45942563aa8bfe64bbeace4d9aa80a91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
336
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwInput.cs
Normal file
336
Assets/Plugins/CW/Shared/Common/Required/Scripts/CwInput.cs
Normal file
@@ -0,0 +1,336 @@
|
||||
#if ENABLE_INPUT_SYSTEM && __INPUTSYSTEM__
|
||||
#define USE_NEW_INPUT_SYSTEM
|
||||
using NewCode = UnityEngine.InputSystem.Key;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace CW.Common
|
||||
{
|
||||
/// <summary>This class wraps <b>UnityEngine.Input</b> and <b>UnityEngine.InputSystem</b> so they can both be used from the same interface.</summary>
|
||||
public static class CwInput
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
private static System.Collections.Generic.Dictionary<KeyCode, NewCode> keyMapping = new System.Collections.Generic.Dictionary<KeyCode, NewCode>()
|
||||
{
|
||||
//{ KeyCode.None, NewCode.None },
|
||||
{ KeyCode.Backspace, NewCode.Backspace },
|
||||
{ KeyCode.Tab, NewCode.Tab },
|
||||
{ KeyCode.Clear, NewCode.None },
|
||||
{ KeyCode.Return, NewCode.Enter },
|
||||
{ KeyCode.Pause, NewCode.Pause },
|
||||
{ KeyCode.Escape, NewCode.Escape },
|
||||
{ KeyCode.Space, NewCode.Space },
|
||||
{ KeyCode.Exclaim, NewCode.None },
|
||||
{ KeyCode.DoubleQuote, NewCode.None },
|
||||
{ KeyCode.Hash, NewCode.None },
|
||||
{ KeyCode.Dollar, NewCode.None },
|
||||
{ KeyCode.Percent, NewCode.None },
|
||||
{ KeyCode.Ampersand, NewCode.None },
|
||||
{ KeyCode.Quote, NewCode.Quote },
|
||||
{ KeyCode.LeftParen, NewCode.None },
|
||||
{ KeyCode.RightParen, NewCode.None },
|
||||
{ KeyCode.Asterisk, NewCode.None },
|
||||
{ KeyCode.Plus, NewCode.None },
|
||||
{ KeyCode.Comma, NewCode.Comma },
|
||||
{ KeyCode.Minus, NewCode.Minus },
|
||||
{ KeyCode.Period, NewCode.Period },
|
||||
{ KeyCode.Slash, NewCode.Slash },
|
||||
{ KeyCode.Alpha1, NewCode.Digit1 },
|
||||
{ KeyCode.Alpha2, NewCode.Digit2 },
|
||||
{ KeyCode.Alpha3, NewCode.Digit3 },
|
||||
{ KeyCode.Alpha4, NewCode.Digit4 },
|
||||
{ KeyCode.Alpha5, NewCode.Digit5 },
|
||||
{ KeyCode.Alpha6, NewCode.Digit6 },
|
||||
{ KeyCode.Alpha7, NewCode.Digit7 },
|
||||
{ KeyCode.Alpha8, NewCode.Digit8 },
|
||||
{ KeyCode.Alpha9, NewCode.Digit9 },
|
||||
{ KeyCode.Alpha0, NewCode.Digit0 },
|
||||
{ KeyCode.Colon, NewCode.None },
|
||||
{ KeyCode.Semicolon, NewCode.Semicolon },
|
||||
{ KeyCode.Less, NewCode.None },
|
||||
{ KeyCode.Equals, NewCode.Equals },
|
||||
{ KeyCode.Greater, NewCode.None },
|
||||
{ KeyCode.Question, NewCode.None },
|
||||
{ KeyCode.At, NewCode.None },
|
||||
{ KeyCode.LeftBracket, NewCode.LeftBracket },
|
||||
{ KeyCode.Backslash, NewCode.Backslash },
|
||||
{ KeyCode.RightBracket, NewCode.RightBracket },
|
||||
{ KeyCode.Caret, NewCode.None },
|
||||
{ KeyCode.Underscore, NewCode.None },
|
||||
{ KeyCode.BackQuote, NewCode.Backquote },
|
||||
{ KeyCode.A, NewCode.A },
|
||||
{ KeyCode.B, NewCode.B },
|
||||
{ KeyCode.C, NewCode.C },
|
||||
{ KeyCode.D, NewCode.D },
|
||||
{ KeyCode.E, NewCode.E },
|
||||
{ KeyCode.F, NewCode.F },
|
||||
{ KeyCode.G, NewCode.G },
|
||||
{ KeyCode.H, NewCode.H },
|
||||
{ KeyCode.I, NewCode.I },
|
||||
{ KeyCode.J, NewCode.J },
|
||||
{ KeyCode.K, NewCode.K },
|
||||
{ KeyCode.L, NewCode.L },
|
||||
{ KeyCode.M, NewCode.M },
|
||||
{ KeyCode.N, NewCode.N },
|
||||
{ KeyCode.O, NewCode.O },
|
||||
{ KeyCode.P, NewCode.P },
|
||||
{ KeyCode.Q, NewCode.Q },
|
||||
{ KeyCode.R, NewCode.R },
|
||||
{ KeyCode.S, NewCode.S },
|
||||
{ KeyCode.T, NewCode.T },
|
||||
{ KeyCode.U, NewCode.U },
|
||||
{ KeyCode.V, NewCode.V },
|
||||
{ KeyCode.W, NewCode.W },
|
||||
{ KeyCode.X, NewCode.X },
|
||||
{ KeyCode.Y, NewCode.Y },
|
||||
{ KeyCode.Z, NewCode.Z },
|
||||
{ KeyCode.LeftCurlyBracket, NewCode.None },
|
||||
{ KeyCode.Pipe, NewCode.None },
|
||||
{ KeyCode.RightCurlyBracket, NewCode.None },
|
||||
{ KeyCode.Tilde, NewCode.None },
|
||||
{ KeyCode.Delete, NewCode.Delete },
|
||||
{ KeyCode.Keypad0, NewCode.Numpad0 },
|
||||
{ KeyCode.Keypad1, NewCode.Numpad1 },
|
||||
{ KeyCode.Keypad2, NewCode.Numpad2 },
|
||||
{ KeyCode.Keypad3, NewCode.Numpad3 },
|
||||
{ KeyCode.Keypad4, NewCode.Numpad4 },
|
||||
{ KeyCode.Keypad5, NewCode.Numpad5 },
|
||||
{ KeyCode.Keypad6, NewCode.Numpad6 },
|
||||
{ KeyCode.Keypad7, NewCode.Numpad7 },
|
||||
{ KeyCode.Keypad8, NewCode.Numpad8 },
|
||||
{ KeyCode.Keypad9, NewCode.Numpad9 },
|
||||
{ KeyCode.KeypadPeriod, NewCode.NumpadPeriod },
|
||||
{ KeyCode.KeypadDivide, NewCode.NumpadDivide },
|
||||
{ KeyCode.KeypadMultiply, NewCode.NumpadMultiply },
|
||||
{ KeyCode.KeypadMinus, NewCode.NumpadMinus },
|
||||
{ KeyCode.KeypadPlus, NewCode.NumpadPlus },
|
||||
{ KeyCode.KeypadEnter, NewCode.NumpadEnter },
|
||||
{ KeyCode.KeypadEquals, NewCode.NumpadEquals },
|
||||
{ KeyCode.UpArrow, NewCode.UpArrow },
|
||||
{ KeyCode.DownArrow, NewCode.DownArrow },
|
||||
{ KeyCode.RightArrow, NewCode.RightArrow },
|
||||
{ KeyCode.LeftArrow, NewCode.LeftArrow },
|
||||
{ KeyCode.Insert, NewCode.Insert },
|
||||
{ KeyCode.Home, NewCode.Home },
|
||||
{ KeyCode.End, NewCode.End },
|
||||
{ KeyCode.PageUp, NewCode.PageUp },
|
||||
{ KeyCode.PageDown, NewCode.PageDown },
|
||||
{ KeyCode.F1, NewCode.F1 },
|
||||
{ KeyCode.F2, NewCode.F2 },
|
||||
{ KeyCode.F3, NewCode.F3 },
|
||||
{ KeyCode.F4, NewCode.F4 },
|
||||
{ KeyCode.F5, NewCode.F5 },
|
||||
{ KeyCode.F6, NewCode.F6 },
|
||||
{ KeyCode.F7, NewCode.F7 },
|
||||
{ KeyCode.F8, NewCode.F8 },
|
||||
{ KeyCode.F9, NewCode.F9 },
|
||||
{ KeyCode.F10, NewCode.F10 },
|
||||
{ KeyCode.F11, NewCode.F11 },
|
||||
{ KeyCode.F12, NewCode.F12 },
|
||||
{ KeyCode.F13, NewCode.None },
|
||||
{ KeyCode.F14, NewCode.None },
|
||||
{ KeyCode.F15, NewCode.None },
|
||||
{ KeyCode.Numlock, NewCode.NumLock },
|
||||
{ KeyCode.CapsLock, NewCode.CapsLock },
|
||||
{ KeyCode.ScrollLock, NewCode.ScrollLock },
|
||||
{ KeyCode.RightShift, NewCode.RightShift },
|
||||
{ KeyCode.LeftShift, NewCode.LeftShift },
|
||||
{ KeyCode.RightControl, NewCode.RightCtrl },
|
||||
{ KeyCode.LeftControl, NewCode.LeftCtrl },
|
||||
{ KeyCode.RightAlt, NewCode.RightAlt },
|
||||
{ KeyCode.LeftAlt, NewCode.LeftAlt },
|
||||
{ KeyCode.RightCommand, NewCode.RightCommand },
|
||||
//{ KeyCode.RightApple, NewCode.RightApple },
|
||||
{ KeyCode.LeftCommand, NewCode.LeftCommand },
|
||||
//{ KeyCode.LeftApple, NewCode.LeftApple },
|
||||
{ KeyCode.LeftWindows, NewCode.LeftWindows },
|
||||
{ KeyCode.RightWindows, NewCode.RightWindows },
|
||||
{ KeyCode.AltGr, NewCode.AltGr },
|
||||
{ KeyCode.Help, NewCode.None },
|
||||
{ KeyCode.Print, NewCode.PrintScreen },
|
||||
{ KeyCode.SysReq, NewCode.None },
|
||||
{ KeyCode.Break, NewCode.None },
|
||||
{ KeyCode.Menu, NewCode.ContextMenu },
|
||||
};
|
||||
|
||||
[UnityEngine.RuntimeInitializeOnLoadMethod]
|
||||
static void Enable()
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
|
||||
}
|
||||
|
||||
private static UnityEngine.InputSystem.Controls.ButtonControl GetMouseButtonControl(int index)
|
||||
{
|
||||
if (UnityEngine.InputSystem.Mouse.current != null)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return UnityEngine.InputSystem.Mouse.current.leftButton;
|
||||
case 1: return UnityEngine.InputSystem.Mouse.current.rightButton;
|
||||
case 2: return UnityEngine.InputSystem.Mouse.current.middleButton;
|
||||
case 3: return UnityEngine.InputSystem.Mouse.current.forwardButton;
|
||||
case 4: return UnityEngine.InputSystem.Mouse.current.backButton;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static UnityEngine.InputSystem.Controls.ButtonControl GetButtonControl(KeyCode oldKey)
|
||||
{
|
||||
if (UnityEngine.InputSystem.Mouse.current != null)
|
||||
{
|
||||
switch (oldKey)
|
||||
{
|
||||
case KeyCode.Mouse0: return UnityEngine.InputSystem.Mouse.current.leftButton;
|
||||
case KeyCode.Mouse1: return UnityEngine.InputSystem.Mouse.current.rightButton;
|
||||
case KeyCode.Mouse2: return UnityEngine.InputSystem.Mouse.current.middleButton;
|
||||
case KeyCode.Mouse3: return UnityEngine.InputSystem.Mouse.current.forwardButton;
|
||||
case KeyCode.Mouse4: return UnityEngine.InputSystem.Mouse.current.backButton;
|
||||
}
|
||||
}
|
||||
|
||||
if (UnityEngine.InputSystem.Keyboard.current != null)
|
||||
{
|
||||
var newKey = default(UnityEngine.InputSystem.Key);
|
||||
|
||||
if (keyMapping.TryGetValue(oldKey, out newKey) == true)
|
||||
{
|
||||
return UnityEngine.InputSystem.Keyboard.current[newKey];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static int GetTouchCount()
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
if (UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.enabled == false)
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
|
||||
}
|
||||
|
||||
return UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches.Count;
|
||||
#else
|
||||
return UnityEngine.Input.touchCount;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void GetTouch(int index, out int id, out UnityEngine.Vector2 position, out float pressure, out bool set)
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
var touch = UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches[index];
|
||||
|
||||
id = touch.finger.index;
|
||||
position = touch.screenPosition;
|
||||
pressure = touch.pressure;
|
||||
set =
|
||||
touch.phase == UnityEngine.InputSystem.TouchPhase.Began ||
|
||||
touch.phase == UnityEngine.InputSystem.TouchPhase.Stationary ||
|
||||
touch.phase == UnityEngine.InputSystem.TouchPhase.Moved;
|
||||
#else
|
||||
var touch = UnityEngine.Input.GetTouch(index);
|
||||
|
||||
id = touch.fingerId;
|
||||
position = touch.position;
|
||||
pressure = touch.pressure;
|
||||
set =
|
||||
touch.phase == UnityEngine.TouchPhase.Began ||
|
||||
touch.phase == UnityEngine.TouchPhase.Stationary ||
|
||||
touch.phase == UnityEngine.TouchPhase.Moved;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static UnityEngine.Vector2 GetMousePosition()
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
return UnityEngine.InputSystem.Mouse.current != null ? UnityEngine.InputSystem.Mouse.current.position.ReadValue() : default(UnityEngine.Vector2);
|
||||
#else
|
||||
return UnityEngine.Input.mousePosition;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetKeyWentDown(KeyCode oldKey)
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
var buttonControl = GetButtonControl(oldKey); return buttonControl != null ? buttonControl.wasPressedThisFrame : false;
|
||||
#else
|
||||
return UnityEngine.Input.GetKeyDown(oldKey);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetKeyIsHeld(KeyCode oldKey)
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
var buttonControl = GetButtonControl(oldKey); return buttonControl != null ? buttonControl.isPressed : false;
|
||||
#else
|
||||
return UnityEngine.Input.GetKey(oldKey);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetKeyWentUp(KeyCode oldKey)
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
var buttonControl = GetButtonControl(oldKey); return buttonControl != null ? buttonControl.wasReleasedThisFrame : false;
|
||||
#else
|
||||
return UnityEngine.Input.GetKeyUp(oldKey);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetMouseWentDown(int index)
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
var buttonControl = GetMouseButtonControl(index); return buttonControl != null ? buttonControl.wasPressedThisFrame : false;
|
||||
#else
|
||||
return UnityEngine.Input.GetMouseButtonDown(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetMouseIsHeld(int index)
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
var buttonControl = GetMouseButtonControl(index); return buttonControl != null ? buttonControl.isPressed : false;
|
||||
#else
|
||||
return UnityEngine.Input.GetMouseButton(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetMouseWentUp(int index)
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
var buttonControl = GetMouseButtonControl(index); return buttonControl != null ? buttonControl.wasReleasedThisFrame : false;
|
||||
#else
|
||||
return UnityEngine.Input.GetMouseButtonUp(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static float GetMouseWheelDelta()
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
return UnityEngine.InputSystem.Mouse.current.scroll != null ? UnityEngine.InputSystem.Mouse.current.scroll.ReadValue().y : 0.0f;
|
||||
#else
|
||||
return UnityEngine.Input.mouseScrollDelta.y;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetMouseExists()
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
return UnityEngine.InputSystem.Mouse.current != null;
|
||||
#else
|
||||
return UnityEngine.Input.mousePresent;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetKeyboardExists()
|
||||
{
|
||||
#if USE_NEW_INPUT_SYSTEM
|
||||
return UnityEngine.InputSystem.Keyboard.current != null;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbb4d9a834e3b5b43801419bceffc9cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/CW/Shared/Common/Required/Shaders.meta
Normal file
8
Assets/Plugins/CW/Shared/Common/Required/Shaders.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 416a4697695e69a4f8517d1e5968f979
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
Shader "Hidden/CW/ShapeOutline"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex Vert
|
||||
#pragma fragment Frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _CW_ShapeTex;
|
||||
float4 _CW_ShapeChannel;
|
||||
float4 _CW_ShapeCoords;
|
||||
float4 _CW_ShapeColor;
|
||||
|
||||
void Vert (in appdata i, out v2f o)
|
||||
{
|
||||
o.vertex = UnityObjectToClipPos(i.vertex);
|
||||
o.uv = i.uv;
|
||||
}
|
||||
|
||||
fixed4 Frag (v2f i) : SV_Target
|
||||
{
|
||||
float u = lerp(_CW_ShapeCoords.x, _CW_ShapeCoords.z, i.uv.x);
|
||||
float v = lerp(_CW_ShapeCoords.y, _CW_ShapeCoords.w, i.uv.y);
|
||||
float shape = dot(tex2D(_CW_ShapeTex, float2(u, v)), _CW_ShapeChannel);
|
||||
float side = shape + abs(ddx(shape)) + abs(ddy(shape));
|
||||
|
||||
if (shape >= 0.5f || side < 0.5f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
return _CW_ShapeColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c55a8fe4b61dcfb41a8aaa1869b89fed
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user