mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Merge pull request #33 from ALEXTANGXIAO/TEngine_v_3.0.0
TEngine v 3.0.0
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
"name": "BattleCore.Runtime",
|
"name": "BattleCore.Runtime",
|
||||||
"rootNamespace": "BattleCore.Runtime",
|
"rootNamespace": "BattleCore.Runtime",
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:aa06d4cc755c979489c256c1bcca1dfb"
|
"GUID:aa06d4cc755c979489c256c1bcca1dfb",
|
||||||
|
"GUID:d8b63aba1907145bea998dd612889d6b"
|
||||||
],
|
],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
|
3
Assets/GameScripts/HotFix/BattleCore/ECSExtension.meta
Normal file
3
Assets/GameScripts/HotFix/BattleCore/ECSExtension.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 890abd3a957e406ab422fc468ba6c169
|
||||||
|
timeCreated: 1682353243
|
@@ -0,0 +1,6 @@
|
|||||||
|
namespace BattleCore.Runtime
|
||||||
|
{
|
||||||
|
public static class EntityExtension
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b4ef2dfa5ceac99458eb1745131a9c83
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -0,0 +1,27 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using Unity.Mathematics;
|
||||||
|
|
||||||
|
namespace BattleCore.Runtime
|
||||||
|
{
|
||||||
|
public static class MathematicsExt
|
||||||
|
{
|
||||||
|
public static int2 ToInt2(this Vector2Int vec) => new int2(vec.x, vec.y);
|
||||||
|
public static int3 ToInt3(this Vector3Int vec) => new int3(vec.x, vec.y, vec.z);
|
||||||
|
public static float2 ToFloat2(this Vector2 vec) => new float2(vec.x, vec.y);
|
||||||
|
public static float3 ToFloat3(this Vector3 vec) => new float3(vec.x, vec.y, vec.z);
|
||||||
|
|
||||||
|
public static bool IsEquals(this int2 a, int2 b) => math.all(a == b);
|
||||||
|
public static bool IsEquals(this int3 a, int3 b) => math.all(a == b);
|
||||||
|
|
||||||
|
|
||||||
|
public static Vector2Int ToVec2(this int2 vec) => new Vector2Int(vec.x, vec.y);
|
||||||
|
public static Vector3Int ToVec3(this int2 vec) => new Vector3Int(vec.x, vec.y, 0);
|
||||||
|
public static Vector3Int ToVec3(this int3 vec) => new Vector3Int(vec.x, vec.y, vec.z);
|
||||||
|
public static Vector2 ToVec2(this float2 vec) => new Vector2(vec.x, vec.y);
|
||||||
|
public static Vector3 ToVec3(this float3 vec) => new Vector3(vec.x, vec.y, vec.z);
|
||||||
|
public static int ManhattanDist(this int2 vec) => vec.x + vec.y;
|
||||||
|
public static int ManhattanDist(this int3 vec) => vec.x + vec.y + vec.z;
|
||||||
|
public static float ManhattanDist(this float2 vec) => vec.x + vec.y;
|
||||||
|
public static float ManhattanDist(this float3 vec) => vec.x + vec.y + vec.z;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b0e288b918a41698571ec3d36059851
|
||||||
|
timeCreated: 1682353251
|
276
Assets/TEngine/Runtime/Extension/EditorExtUtil.cs
Normal file
276
Assets/TEngine/Runtime/Extension/EditorExtUtil.cs
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
|
namespace TEngine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器运行时工具。
|
||||||
|
/// </summary>
|
||||||
|
public static class EditorExtUtil
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏物体保存为预制体。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="asset">游戏物体。</param>
|
||||||
|
public static void SavePrefabAsset(GameObject asset)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
PrefabUtility.SavePrefabAsset(asset);
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="asset">游戏物体。</param>
|
||||||
|
/// <param name="path">资源路径。</param>
|
||||||
|
public static void CreateAsset(Object asset, string path)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
AssetDatabase.CreateAsset(asset, path);
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件路径转化成guid。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">文件路径</param>
|
||||||
|
/// <returns>guid。</returns>
|
||||||
|
public static string AssetPathToGUID(string path)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.AssetDatabase.AssetPathToGUID(path);
|
||||||
|
#else
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源来源预制体。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">资源实例。</param>
|
||||||
|
/// <returns>来源预制体。</returns>
|
||||||
|
public static UnityEngine.Object GetPrefabParent(UnityEngine.Object obj)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(obj);
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源路径。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">资源。</param>
|
||||||
|
/// <returns>路径。</returns>
|
||||||
|
public static string GetAssetPath(GameObject obj)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.AssetDatabase.GetAssetPath(obj);
|
||||||
|
#else
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源路径。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">资源。</param>
|
||||||
|
/// <returns>路径。</returns>
|
||||||
|
public static string GetAssetPath(ScriptableObject obj)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.AssetDatabase.GetAssetPath(obj);
|
||||||
|
#else
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取AB包中的资源依赖。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetBundleName">The name of the AssetBundle for which dependencies are required.</param>
|
||||||
|
/// <param name="recursive">If false, returns only AssetBundles which are direct dependencies of the input; if true, includes all indirect dependencies of the input.</param>
|
||||||
|
/// <returns>returns the list of AssetBundles that it depends on.</returns>
|
||||||
|
public static string[] GetAssetBundleDependencies(string assetBundleName, bool recursive)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.AssetDatabase.GetAssetBundleDependencies(assetBundleName, recursive);
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// guid转化成文件路径。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="guid">guid。</param>
|
||||||
|
/// <returns>文件路径。</returns>
|
||||||
|
public static string GUIDToAssetPath(string guid)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下加载资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetPath">资源地址。</param>
|
||||||
|
/// <typeparam name="T">资源类型。</typeparam>
|
||||||
|
/// <returns>资源实例。</returns>
|
||||||
|
public static T LoadAssetAtPath<T>(string assetPath) where T : Object
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.AssetDatabase.LoadAssetAtPath<T>(assetPath);
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包名称里的资源列表。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetBundleName">资源包名称。</param>
|
||||||
|
public static string[] GetAssetPathsFromAssetBundle(string assetBundleName)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return UnityEditor.AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName);
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开关宏定义。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="def">宏定义。</param>
|
||||||
|
/// <param name="isOn">是否开启。</param>
|
||||||
|
public static void ToggleScriptingDefineSymbols(string def, bool isOn)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
ToggleScriptingDefineSymbols(def, isOn, (int)BuildTargetGroup.Standalone);
|
||||||
|
ToggleScriptingDefineSymbols(def, isOn, (int)BuildTargetGroup.Android);
|
||||||
|
ToggleScriptingDefineSymbols(def, isOn, (int)BuildTargetGroup.iOS);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开关宏定义。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="def">宏定义。</param>
|
||||||
|
/// <param name="isOn">是否开启。</param>
|
||||||
|
/// <param name="type">BuildTargetGroup打包平台类型。</param>
|
||||||
|
public static void ToggleScriptingDefineSymbols(string def, bool isOn, int type)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
var targetGroup = (BuildTargetGroup)type;
|
||||||
|
string ori = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
|
||||||
|
List<string> defineSymbols = new List<string>(ori.Split(';'));
|
||||||
|
if (isOn)
|
||||||
|
{
|
||||||
|
if (!defineSymbols.Contains(def))
|
||||||
|
{
|
||||||
|
defineSymbols.Add(def);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defineSymbols.Remove(def);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", defineSymbols.ToArray()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置脏标记。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">ScriptableObject。</param>
|
||||||
|
public static void SetDirty(this ScriptableObject obj)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.EditorUtility.SetDirty(obj);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导入资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">资源定位地址。</param>
|
||||||
|
public static void ImportAsset(string path)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.AssetDatabase.ImportAsset(path);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 把ScriptableObject保存为CSV表格。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">ScriptableObject。</param>
|
||||||
|
public static void SaveTblConfig(this ScriptableObject config)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
EditorUtility.SetDirty(config);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
var path = AssetDatabase.GetAssetPath(config);
|
||||||
|
AssetDatabase.ImportAsset(path);
|
||||||
|
AssetDatabase.ImportAsset(path.Replace(".asset", ".csv"));
|
||||||
|
EditorWindow.focusedWindow?.ShowNotification(new GUIContent("Done"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 实例化游戏物体操作。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="original">来源游戏物体。</param>
|
||||||
|
/// <param name="position">实例化的位置。</param>
|
||||||
|
/// <param name="rotation">实例化的四元数。</param>
|
||||||
|
/// <param name="parent">实例化的父节点。</param>
|
||||||
|
/// <returns>实例化游戏物体。</returns>
|
||||||
|
public static GameObject Instantiate(
|
||||||
|
GameObject original,
|
||||||
|
Vector3 position,
|
||||||
|
Quaternion rotation,
|
||||||
|
Transform parent)
|
||||||
|
{
|
||||||
|
if (original == null) return null;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (Application.isPlaying)
|
||||||
|
{
|
||||||
|
return Object.Instantiate(original, position, rotation, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
var go = PrefabUtility.InstantiatePrefab(original, parent) as GameObject;
|
||||||
|
go.transform.position = position;
|
||||||
|
go.transform.rotation = rotation;
|
||||||
|
return go;
|
||||||
|
#else
|
||||||
|
return Object.Instantiate( original, position, rotation, parent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 停止运行游戏。
|
||||||
|
/// </summary>
|
||||||
|
public static void StopGame()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.EditorApplication.isPlaying = false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/TEngine/Runtime/Extension/EditorExtUtil.cs.meta
Normal file
11
Assets/TEngine/Runtime/Extension/EditorExtUtil.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 99efa5e84d614e74e960fcedb001ee0a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
134
Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs
Normal file
134
Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
#if !ODIN_INSPECTOR
|
||||||
|
namespace Sirenix.OdinInspector
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public class ButtonAttribute : Attribute
|
||||||
|
{
|
||||||
|
public ButtonAttribute()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ButtonAttribute(string name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public sealed class ReadOnlyAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public class ShowInInspectorAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public sealed class HideIfAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string MemberName;
|
||||||
|
public object Value;
|
||||||
|
public bool Animate;
|
||||||
|
|
||||||
|
public HideIfAttribute(string memberName, bool animate = true)
|
||||||
|
{
|
||||||
|
this.MemberName = memberName;
|
||||||
|
this.Animate = animate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DontApplyToListElements]
|
||||||
|
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public sealed class OnValueChangedAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string MethodName;
|
||||||
|
|
||||||
|
public bool IncludeChildren;
|
||||||
|
|
||||||
|
public OnValueChangedAttribute(string methodName, bool includeChildren = false)
|
||||||
|
{
|
||||||
|
this.MethodName = methodName;
|
||||||
|
this.IncludeChildren = includeChildren;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public class TableListAttribute : Attribute
|
||||||
|
{
|
||||||
|
public int DefaultMinColumnWidth = 40;
|
||||||
|
public bool DrawScrollView = true;
|
||||||
|
|
||||||
|
public int MinScrollViewHeight = 350;
|
||||||
|
|
||||||
|
public int CellPadding = 2;
|
||||||
|
|
||||||
|
public int NumberOfItemsPerPage;
|
||||||
|
|
||||||
|
public bool IsReadOnly;
|
||||||
|
|
||||||
|
public bool ShowIndexLabels;
|
||||||
|
|
||||||
|
public int MaxScrollViewHeight;
|
||||||
|
|
||||||
|
public bool AlwaysExpanded;
|
||||||
|
|
||||||
|
public bool HideToolbar;
|
||||||
|
|
||||||
|
[SerializeField] [HideInInspector] private bool showPagingHasValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public sealed class DontApplyToListElementsAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||||
|
[DontApplyToListElements]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public class PropertySpaceAttribute : Attribute
|
||||||
|
{
|
||||||
|
public float SpaceBefore;
|
||||||
|
public float SpaceAfter;
|
||||||
|
|
||||||
|
public PropertySpaceAttribute()
|
||||||
|
{
|
||||||
|
this.SpaceBefore = 8f;
|
||||||
|
this.SpaceAfter = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpaceAttribute(float spaceBefore)
|
||||||
|
{
|
||||||
|
this.SpaceBefore = spaceBefore;
|
||||||
|
this.SpaceAfter = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpaceAttribute(float spaceBefore, float spaceAfter)
|
||||||
|
{
|
||||||
|
this.SpaceBefore = spaceBefore;
|
||||||
|
this.SpaceAfter = spaceAfter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||||
|
[Conditional("UNITY_EDITOR")]
|
||||||
|
public class LabelTextAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Text;
|
||||||
|
|
||||||
|
public LabelTextAttribute(string text)
|
||||||
|
{
|
||||||
|
this.Text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1b7dfd2b954f77047a61bf4c505f8cc1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
34
Assets/TEngine/Runtime/Extension/TransformExtension.cs
Normal file
34
Assets/TEngine/Runtime/Extension/TransformExtension.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace TEngine
|
||||||
|
{
|
||||||
|
public static partial class TransformExtension
|
||||||
|
{
|
||||||
|
public static float YDeg(this Transform tran)
|
||||||
|
{
|
||||||
|
return tran.eulerAngles.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveAllChildren(this Transform tran)
|
||||||
|
{
|
||||||
|
var count = tran.childCount;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
GameObject.DestroyImmediate(tran.GetChild(0).gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Transform> GetAllChildren(this Transform tran)
|
||||||
|
{
|
||||||
|
var count = tran.childCount;
|
||||||
|
List<Transform> allTrans = new List<Transform>();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
allTrans.Add(tran.GetChild(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return allTrans;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/TEngine/Runtime/Extension/TransformExtension.cs.meta
Normal file
11
Assets/TEngine/Runtime/Extension/TransformExtension.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59821d6add0226e40a841e85a2cba8ec
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
61
Assets/TEngine/Runtime/GameFramework/Utility/Utility.Bit.cs
Normal file
61
Assets/TEngine/Runtime/GameFramework/Utility/Utility.Bit.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
namespace TEngine
|
||||||
|
{
|
||||||
|
public static partial class Utility
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 位运算相关的实用函数。
|
||||||
|
/// </summary>
|
||||||
|
public static class Bit
|
||||||
|
{
|
||||||
|
public static bool HasBit(long val, int idx)
|
||||||
|
{
|
||||||
|
return (val & 1L << idx) != 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetBit(ref long val, int idx, bool isSet)
|
||||||
|
{
|
||||||
|
if (isSet)
|
||||||
|
{
|
||||||
|
val |= (1L << idx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val &= ~(1L << idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasBit(int val, int idx)
|
||||||
|
{
|
||||||
|
return (val & 1 << idx) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void SetBit(ref int val, int idx, bool isSet)
|
||||||
|
{
|
||||||
|
if (isSet)
|
||||||
|
{
|
||||||
|
val |= (1 << idx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val &= ~(1 << idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasBit(byte val, byte idx)
|
||||||
|
{
|
||||||
|
return (val & 1 << idx) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetBit(ref byte val, byte idx)
|
||||||
|
{
|
||||||
|
val |= (byte)(1 << idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte ToByte(byte idx)
|
||||||
|
{
|
||||||
|
return (byte)(1 << idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 95d9fac2a8ff467e864aab4cd2650dfc
|
||||||
|
timeCreated: 1682352897
|
9
Books/0-RunAble.md
Normal file
9
Books/0-RunAble.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# TEngine
|
||||||
|
|
||||||
|
### 日志记录编辑器下运行
|
||||||
|

|
||||||
|
|
||||||
|
### TODO - 安卓环境运行
|
||||||
|
|
||||||
|
|
||||||
|
### TODO - IOS环境运行
|
Before Width: | Height: | Size: 302 KiB After Width: | Height: | Size: 302 KiB |
Reference in New Issue
Block a user