diff --git a/Assets/NGUI/Scripts/UI/UIInput.cs b/Assets/NGUI/Scripts/UI/UIInput.cs
index 838d7bd..70fc0f8 100644
--- a/Assets/NGUI/Scripts/UI/UIInput.cs
+++ b/Assets/NGUI/Scripts/UI/UIInput.cs
@@ -70,6 +70,7 @@ [DoNotObfuscateNGUI] public enum OnReturnKey
}
public delegate char OnValidate (string text, int charIndex, char addedChar);
+ public delegate void OnKeyDelegate();
///
/// Currently active input field. Only valid during callbacks.
@@ -185,6 +186,7 @@ [DoNotObfuscateNGUI] public enum OnReturnKey
///
public OnValidate onValidate;
+ public OnKeyDelegate onTabCallback;
///
/// Input field's value.
@@ -850,6 +852,11 @@ protected virtual void Update ()
if (!mCam.useKeyboard && UICamera.GetKeyUp(KeyCode.Tab))
OnKey(KeyCode.Tab);
+
+ if (onTabCallback != null && UICamera.GetKeyUp(KeyCode.Tab))
+ {
+ onTabCallback();
+ }
}
}
diff --git a/Assets/Resources/Material/PixelMaskCut.mat b/Assets/Resources/Material/PixelMaskCut.mat
new file mode 100644
index 0000000..aeca649
--- /dev/null
+++ b/Assets/Resources/Material/PixelMaskCut.mat
@@ -0,0 +1,84 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+ serializedVersion: 6
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_Name: PixelMaskCut
+ m_Shader: {fileID: 4800000, guid: 0575c9a6c829af54b8afea2e0da24048, type: 3}
+ m_ShaderKeywords:
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 0
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: -1
+ stringTagMap: {}
+ disabledShaderPasses: []
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _BumpMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailAlbedoMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailMask:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailNormalMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _EmissionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MaskTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MetallicGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _OcclusionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _ParallaxMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Floats:
+ - _BumpScale: 1
+ - _Cutoff: 0.5
+ - _DetailNormalMapScale: 1
+ - _DstBlend: 0
+ - _GlossMapScale: 1
+ - _Glossiness: 0.5
+ - _GlossyReflections: 1
+ - _Metallic: 0
+ - _Mode: 0
+ - _OcclusionStrength: 1
+ - _Parallax: 0.02
+ - _PosX: 0
+ - _PosY: 0
+ - _SizeX: 0
+ - _SizeY: 0
+ - _SmoothnessTextureChannel: 0
+ - _SpecularHighlights: 1
+ - _SrcBlend: 1
+ - _UVSec: 0
+ - _ZWrite: 1
+ m_Colors:
+ - _Color: {r: 1, g: 1, b: 1, a: 1}
+ - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
diff --git a/Assets/Resources/Material/PixelMaskCut.mat.meta b/Assets/Resources/Material/PixelMaskCut.mat.meta
new file mode 100644
index 0000000..4fc1c4e
--- /dev/null
+++ b/Assets/Resources/Material/PixelMaskCut.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: ff00d1e4275faa84ca7d104f11fd527e
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Resources/Shader/Frame/PixelMaskCut.shader b/Assets/Resources/Shader/Frame/PixelMaskCut.shader
new file mode 100644
index 0000000..fb4ce40
--- /dev/null
+++ b/Assets/Resources/Shader/Frame/PixelMaskCut.shader
@@ -0,0 +1,97 @@
+// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
+
+Shader "PixelMaskCut"
+{
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ _MaskTex ("Texture", 2D) = "white" {}
+ _SizeX("Size X", float) = 0.0
+ _SizeY("Size Y", float) = 0.0
+ _PosX("Pos X", float) = 0.0
+ _PosY("Pos Y", float) = 0.0
+ }
+ SubShader
+ {
+ LOD 200
+
+ Tags
+ {
+ "Queue" = "Transparent"
+ "IgnoreProjector" = "True"
+ "RenderType" = "Transparent"
+ "LightMode"="ForwardBase"
+ }
+
+ // No culling or depth
+ Cull Off
+ Lighting Off
+ ZWrite Off
+ Offset -1, -1
+ Fog { Mode Off }
+ ColorMask RGB
+ Blend SrcAlpha OneMinusSrcAlpha
+
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
+ #pragma target 3.0
+
+ #include "UnityCG.cginc"
+
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ half4 color : COLOR;
+ float2 uv : TEXCOORD0;
+ };
+ struct v2f
+ {
+ float4 vertex : SV_POSITION;
+ half4 color : COLOR;
+ float2 uv : TEXCOORD0;
+ };
+
+ sampler2D _MainTex;
+ sampler2D _MaskTex;
+ float4 _MainTex_ST;
+ uniform half4 _MainTex_TexelSize; // 主纹理的像素尺寸
+ uniform half4 _MaskTex_TexelSize; // 遮挡纹理的像素尺寸
+ float _SizeX;
+ float _SizeY;
+ float _PosX;
+ float _PosY;
+
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv.xy * _MainTex_ST.xy + _MainTex_ST.zw;
+ o.color = v.color;
+ return o;
+ }
+
+ fixed4 frag (v2f i) : SV_Target
+ {
+ // _PosX是MaskTex中心点相对于MainTex中心的像素坐标
+ fixed4 srcColor = tex2D(_MainTex, i.uv);
+ // 计算对应的遮挡纹理坐标
+ float2 curPixelPos = i.uv * _MainTex_TexelSize.zw;
+ float2 relative = _MainTex_TexelSize.zw / 2 - float2(_SizeX, _SizeY) / 2;
+ float2 maskPixelPos = curPixelPos - (relative + float2(_PosX, _PosY));
+ float2 newUV = maskPixelPos * _MaskTex_TexelSize.xy;
+ // 当遮挡纹理坐标在0~1之间时才会取红色分量作为透明度,否则透明度为0
+ float alpha = 0;
+ if (newUV.x >= 0 && newUV.x <= 1.0 && newUV.y >= 0 && newUV.y <= 1.0)
+ {
+ alpha = tex2D(_MaskTex, newUV).r;
+ }
+ return fixed4(srcColor.rgb, alpha * i.color.a * srcColor.a);
+ }
+ ENDCG
+ }
+ }
+ Fallback "Diffuse"
+}
diff --git a/Assets/Resources/Shader/Frame/PixelMaskCut.shader.meta b/Assets/Resources/Shader/Frame/PixelMaskCut.shader.meta
new file mode 100644
index 0000000..bf2ae24
--- /dev/null
+++ b/Assets/Resources/Shader/Frame/PixelMaskCut.shader.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 0575c9a6c829af54b8afea2e0da24048
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Frame/Character/CharacterManager.cs b/Assets/Scripts/Frame/Character/CharacterManager.cs
index 59390f9..b31b164 100644
--- a/Assets/Scripts/Frame/Character/CharacterManager.cs
+++ b/Assets/Scripts/Frame/Character/CharacterManager.cs
@@ -191,16 +191,11 @@ protected void addCharacterToList(Character character)
// 加入到全部角色列表
mCharacterList.Add(character.getName(), character);
// 加入到角色分类列表
- if (mCharacterTypeList.ContainsKey(character.getType()))
- {
- mCharacterTypeList[character.getType()].Add(character.getName(), character);
- }
- else
+ if (!mCharacterTypeList.ContainsKey(character.getType()))
{
- Dictionary characterMap = new Dictionary();
- characterMap.Add(character.getName(), character);
- mCharacterTypeList.Add(character.getType(), characterMap);
+ mCharacterTypeList.Add(character.getType(), new Dictionary());
}
+ mCharacterTypeList[character.getType()].Add(character.getName(), character);
// 加入ID索引表
int characterID = character.getCharacterData().mGUID;
if (!mCharacterGUIDList.ContainsKey(characterID))
diff --git a/Assets/Scripts/Frame/Common/CommonDefine.cs b/Assets/Scripts/Frame/Common/CommonDefine.cs
index f69c7a8..522ba9a 100644
--- a/Assets/Scripts/Frame/Common/CommonDefine.cs
+++ b/Assets/Scripts/Frame/Common/CommonDefine.cs
@@ -64,6 +64,7 @@ public enum SOUND_OWNER
public enum CHARACTER_TYPE
{
CT_NORMAL,
+ CT_NPC,
CT_AI,
CT_OTHER,
CT_MYSELF,
@@ -163,6 +164,7 @@ public class CommonDefine
public const string SA_NGUI_SUB_PREFAB_PATH = SA_LAYOUT_PATH + NGUI_SUB_PREFAB + "/";
// 相对路径,相对于Resources,R_开头,表示Resources
public const string R_ATLAS_PATH = ATLAS + "/";
+ public const string R_ATLAS_GAME_ATLAS_PATH = R_ATLAS_PATH + GAME_ATLAS + "/";
public const string R_ATLAS_TEXTURE_ANIM_PATH = R_ATLAS_PATH + TEXTURE_ANIM + "/";
public const string R_SOUND_PATH = SOUND + "/";
public const string R_LAYOUT_PATH = LAYOUT + "/";
diff --git a/Assets/Scripts/Frame/Common/DoubleBuffer.cs b/Assets/Scripts/Frame/Common/DoubleBuffer.cs
index 5640140..a1f4cae 100644
--- a/Assets/Scripts/Frame/Common/DoubleBuffer.cs
+++ b/Assets/Scripts/Frame/Common/DoubleBuffer.cs
@@ -10,6 +10,7 @@ public class DoubleBuffer : GameBase
protected int mWriteIndex;
protected int mReadIndex;
protected ThreadLock mBufferLock;
+ protected int mWriteListLimit;
public DoubleBuffer()
{
mBufferList = new List[2];
@@ -17,6 +18,7 @@ public DoubleBuffer()
mBufferList[1] = new List();
mWriteIndex = 0;
mReadIndex = 1;
+ mWriteListLimit = 0;
mBufferLock = new ThreadLock();
}
// 切换缓冲区,获得可读列表,在遍历可读列表期间,不能再次调用getReadList,否则会出现不可预知的错误,并且该函数只能在一个线程中调用
@@ -31,7 +33,14 @@ public List getReadList()
public void addToBuffer(T value)
{
mBufferLock.waitForUnlock();
- mBufferList[mWriteIndex].Add(value);
+ if(mWriteListLimit == 0 || mBufferList[mWriteIndex].Count < mWriteListLimit)
+ {
+ mBufferList[mWriteIndex].Add(value);
+ }
mBufferLock.unlock();
}
+ public void setWriteListLimit(int limit)
+ {
+ mWriteListLimit = limit;
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/Common/FrameBase.cs b/Assets/Scripts/Frame/Common/FrameBase.cs
index c58b941..5b030f0 100644
--- a/Assets/Scripts/Frame/Common/FrameBase.cs
+++ b/Assets/Scripts/Frame/Common/FrameBase.cs
@@ -28,6 +28,7 @@ public class FrameBase : FileUtility
public static SceneSystem mSceneSystem = null;
public static IFrameLogSystem mFrameLogSystem = null;
public static ClassObjectPool mClassObjectPool = null;
+ public static AndroidAssetLoader mAndroidAssetLoader = null;
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
public static LocalLog mLocalLog = null;
#endif
@@ -38,26 +39,27 @@ public virtual void notifyConstructDone()
if (mGameFramework == null)
{
mGameFramework = GameFramework.instance;
- mCommandSystem = mGameFramework.getSystem();
- mAudioManager = mGameFramework.getSystem();
- mGameSceneManager = mGameFramework.getSystem();
- mCharacterManager = mGameFramework.getSystem();
- mLayoutManager = mGameFramework.getSystem();
- mKeyFrameManager = mGameFramework.getSystem();
- mGlobalTouchSystem = mGameFramework.getSystem();
- mShaderManager = mGameFramework.getSystem();
- mSQLite = mGameFramework.getSystem();
- mDataBase = mGameFramework.getSystem();
- mCameraManager = mGameFramework.getSystem();
- mResourceManager = mGameFramework.getSystem();
- mLayoutSubPrefabManager = mGameFramework.getSystem();
- mApplicationConfig = mGameFramework.getSystem();
- mFrameConfig = mGameFramework.getSystem();
- mObjectManager = mGameFramework.getSystem();
- mInputManager = mGameFramework.getSystem();
- mSceneSystem = mGameFramework.getSystem();
- mClassObjectPool = mGameFramework.getSystem();
- mSQLiteSound = mSQLite.getTable();
+ mGameFramework.getSystem(out mCommandSystem);
+ mGameFramework.getSystem(out mAudioManager);
+ mGameFramework.getSystem(out mGameSceneManager);
+ mGameFramework.getSystem(out mCharacterManager);
+ mGameFramework.getSystem(out mLayoutManager);
+ mGameFramework.getSystem(out mKeyFrameManager);
+ mGameFramework.getSystem(out mGlobalTouchSystem);
+ mGameFramework.getSystem(out mShaderManager);
+ mGameFramework.getSystem(out mSQLite);
+ mGameFramework.getSystem(out mDataBase);
+ mGameFramework.getSystem(out mCameraManager);
+ mGameFramework.getSystem(out mResourceManager);
+ mGameFramework.getSystem(out mLayoutSubPrefabManager);
+ mGameFramework.getSystem(out mApplicationConfig);
+ mGameFramework.getSystem(out mFrameConfig);
+ mGameFramework.getSystem(out mObjectManager);
+ mGameFramework.getSystem(out mInputManager);
+ mGameFramework.getSystem(out mSceneSystem);
+ mGameFramework.getSystem(out mClassObjectPool);
+ mGameFramework.getSystem(out mAndroidAssetLoader);
+ mSQLite.getTable(out mSQLiteSound);
}
}
// 方便书写代码添加的命令相关函数
diff --git a/Assets/Scripts/Frame/Common/Serialize/SerializedData.cs b/Assets/Scripts/Frame/Common/Serialize/SerializedData.cs
index 90fcf01..3f99a19 100644
--- a/Assets/Scripts/Frame/Common/Serialize/SerializedData.cs
+++ b/Assets/Scripts/Frame/Common/Serialize/SerializedData.cs
@@ -63,6 +63,10 @@ protected void zeroParams()
}
protected void pushParam(OBJECT param)
{
+ if(param == null)
+ {
+ logError("param is null!");
+ }
mParameterInfoList.Add(param);
}
};
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/Common/Serialize/USHORT.cs b/Assets/Scripts/Frame/Common/Serialize/USHORT.cs
new file mode 100644
index 0000000..fdef452
--- /dev/null
+++ b/Assets/Scripts/Frame/Common/Serialize/USHORT.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+public class USHORT : OBJECT
+{
+ public ushort mValue;
+ public USHORT()
+ {
+ mType = typeof(ushort);
+ mSize = sizeof(ushort);
+ }
+ public USHORT(ushort value)
+ {
+ mValue = value;
+ mType = typeof(ushort);
+ mSize = sizeof(ushort);
+ }
+ public override void zero()
+ {
+ mValue = 0;
+ }
+ public override void readFromBuffer(byte[] buffer, ref int index)
+ {
+ mValue = readUShort(buffer, ref index);
+ }
+ public override void writeToBuffer(byte[] buffer, ref int index)
+ {
+ writeUShort(buffer, ref index, mValue);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/Common/Serialize/USHORT.cs.meta b/Assets/Scripts/Frame/Common/Serialize/USHORT.cs.meta
new file mode 100644
index 0000000..35b58fb
--- /dev/null
+++ b/Assets/Scripts/Frame/Common/Serialize/USHORT.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ef661d17574c33c42b96c966441b3094
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Frame/Common/Utility/BinaryUtility.cs b/Assets/Scripts/Frame/Common/Utility/BinaryUtility.cs
index 1d3afd8..53ad516 100644
--- a/Assets/Scripts/Frame/Common/Utility/BinaryUtility.cs
+++ b/Assets/Scripts/Frame/Common/Utility/BinaryUtility.cs
@@ -270,19 +270,29 @@ public static bool writeByte(byte[] buffer, ref int index, byte value)
}
public static bool writeShort(byte[] buffer, ref int index, short value, bool inverse = false)
{
- if (buffer.Length < index + sizeof(short))
+ int typeSize = sizeof(short);
+ if (buffer.Length < index + typeSize)
{
return false;
}
- if(inverse)
+ for (int i = 0; i < typeSize; ++i)
{
- buffer[index++] = (byte)((0xff00 & value) >> 8);
- buffer[index++] = (byte)((0x00ff & value) >> 0);
+ int bitsOffset = inverse ? 8 * (typeSize - i - 1) : 8 * i;
+ buffer[index++] = (byte)(((0xFF << bitsOffset) & value) >> bitsOffset);
}
- else
+ return true;
+ }
+ public static bool writeUShort(byte[] buffer, ref int index, ushort value, bool inverse = false)
+ {
+ int typeSize = sizeof(ushort);
+ if (buffer.Length < index + typeSize)
+ {
+ return false;
+ }
+ for (int i = 0; i < typeSize; ++i)
{
- buffer[index++] = (byte)((0x00ff & value) >> 0);
- buffer[index++] = (byte)((0xff00 & value) >> 8);
+ int bitsOffset = inverse ? 8 * (typeSize - i - 1) : 8 * i;
+ buffer[index++] = (byte)(((0xFF << bitsOffset) & value) >> bitsOffset);
}
return true;
}
diff --git a/Assets/Scripts/Frame/Common/Utility/FileUtility.cs b/Assets/Scripts/Frame/Common/Utility/FileUtility.cs
index 29b174e..baee3e4 100644
--- a/Assets/Scripts/Frame/Common/Utility/FileUtility.cs
+++ b/Assets/Scripts/Frame/Common/Utility/FileUtility.cs
@@ -46,7 +46,7 @@ public static void openFile(string fileName, ref byte[] fileBuffer)
}
else
{
- logError("openFile invalid path : " + fileName);
+ UnityUtility.logError("openFile invalid path : " + fileName);
}
#endif
}
@@ -86,7 +86,7 @@ public static string openTxtFile(string fileName)
}
else
{
- logError("openTxtFile invalid path : " + fileName);
+ UnityUtility.logError("openTxtFile invalid path : " + fileName);
}
return "";
#endif
@@ -134,7 +134,7 @@ public static void writeTxtFile(string fileName, string content, bool appendData
public static bool renameFile(string fileName, string newName)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not rename file on android!");
+ UnityUtility.logError("can not rename file on android!");
return false;
#endif
if (isFileExist(fileName) || isFileExist(newName))
@@ -147,7 +147,7 @@ public static bool renameFile(string fileName, string newName)
public static void deleteFolder(string path)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not delete dir on android!");
+ UnityUtility.logError("can not delete dir on android!");
return;
#endif
validPath(ref path);
@@ -169,7 +169,7 @@ public static void deleteFolder(string path)
public static bool deleteEmptyFolder(string path, bool deleteSelfIfEmpty = true)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not delete empty dir on android!");
+ UnityUtility.logError("can not delete empty dir on android!");
return false;
#endif
validPath(ref path);
@@ -190,7 +190,7 @@ public static bool deleteEmptyFolder(string path, bool deleteSelfIfEmpty = true)
public static void moveFile(string source, string dest, bool overwrite = true)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not copy file on android!");
+ UnityUtility.logError("can not copy file on android!");
return;
#endif
if (isFileExist(dest))
@@ -216,7 +216,7 @@ public static void moveFile(string source, string dest, bool overwrite = true)
public static void copyFile(string source, string dest, bool overwrite = true)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not copy file on android!");
+ UnityUtility.logError("can not copy file on android!");
return;
#endif
// 如果目标文件所在的目录不存在,则先创建目录
@@ -259,7 +259,7 @@ public static bool isDirExist(string dir)
}
else
{
- logError("isDirExist invalid path : " + dir);
+ UnityUtility.logError("isDirExist invalid path : " + dir);
}
return false;
#endif
@@ -283,7 +283,7 @@ public static bool isFileExist(string fileName)
}
else
{
- logError("isFileExist invalid path : " + fileName);
+ UnityUtility.logError("isFileExist invalid path : " + fileName);
}
return false;
#endif
@@ -311,7 +311,7 @@ public static void createDir(string dir)
public static void findResourcesFiles(string path, ref List fileList, string pattern, bool recursive = true)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not find resouces files on android!");
+ UnityUtility.logError("can not find resouces files on android!");
return;
#endif
List patternList = new List();
@@ -322,7 +322,7 @@ public static void findResourcesFiles(string path, ref List fileList, st
public static void findResourcesFiles(string path, ref List fileList, List patterns = null, bool recursive = true)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not find resouces files on android!");
+ UnityUtility.logError("can not find resouces files on android!");
return;
#endif
validPath(ref path);
@@ -366,7 +366,7 @@ public static void findFiles(string path, ref List fileList, string patt
public static void findFiles(string path, ref List fileList, List patterns = null, bool recursive = true)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not findFiles on android!");
+ UnityUtility.logError("can not findFiles on android!");
return;
#endif
validPath(ref path);
@@ -431,7 +431,7 @@ public static bool findDirectory(string path, ref List dirList, bool rec
public static void deleteFile(string path)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not delete file on android!");
+ UnityUtility.logError("can not delete file on android!");
return;
#endif
File.Delete(path);
@@ -439,7 +439,7 @@ public static void deleteFile(string path)
public static string generateFileMD5(string fileName, bool upperOrLower = true)
{
#if UNITY_ANDROID && !UNITY_EDITOR
- logError("can not generate file md5 on android!");
+ UnityUtility.logError("can not generate file md5 on android!");
return "";
#endif
FileStream file = new FileStream(fileName, FileMode.Open);
diff --git a/Assets/Scripts/Frame/Common/Utility/StringUtility.cs b/Assets/Scripts/Frame/Common/Utility/StringUtility.cs
index 6f6a610..1c3e437 100644
--- a/Assets/Scripts/Frame/Common/Utility/StringUtility.cs
+++ b/Assets/Scripts/Frame/Common/Utility/StringUtility.cs
@@ -486,6 +486,28 @@ public static string floatToString(float value, int precision = 4, bool removeTa
}
return str;
}
+ // 给数字字符串以千为单位添加逗号
+ public static void insertNumberComma(ref string str)
+ {
+ int length = str.Length;
+ int commaCount = length / 3;
+ if(length > 0 && length % 3 == 0)
+ {
+ commaCount -= 1;
+ }
+ int insertStart = length % 3;
+ if(insertStart == 0)
+ {
+ insertStart = 3;
+ }
+ insertStart += 3 * (commaCount - 1);
+ // 从后往前插入
+ for (int i = 0; i < commaCount; ++i)
+ {
+ str = str.Insert(insertStart, ",");
+ insertStart -= 3;
+ }
+ }
public static string intToString(int value, int limitLen = 0)
{
string retString = value.ToString();
diff --git a/Assets/Scripts/Frame/Common/Utility/UnityUtility.cs b/Assets/Scripts/Frame/Common/Utility/UnityUtility.cs
index f4fac11..4a9ffa0 100644
--- a/Assets/Scripts/Frame/Common/Utility/UnityUtility.cs
+++ b/Assets/Scripts/Frame/Common/Utility/UnityUtility.cs
@@ -25,11 +25,13 @@ public enum LOG_LEVEL
public class UnityUtility : FrameComponent
{
+ public delegate void onLog(string time, string info, LOG_LEVEL level, bool isError);
protected static GameCamera mForeEffectCamera;
protected static GameCamera mBackEffectCamera;
protected static LOG_LEVEL mLogLevel;
protected static bool mShowMessageBox = true;
protected static int mIDMaker;
+ public static onLog mOnLog;
public UnityUtility(string name)
:base(name)
{
@@ -65,26 +67,32 @@ public static LOG_LEVEL getLogLevel()
// 运行一次只显示一次提示框,避免在循环中报错时一直弹窗
mShowMessageBox = false;
}
+ string time = getTime();
string trackStr = new StackTrace().ToString();
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
// windows平台打包后使用LocalLog打印日志
if (mLocalLog != null)
{
- mLocalLog.log("error : " + info + ", stack : " + trackStr);
+ mLocalLog.log(time + "error : " + info + ", stack : " + trackStr);
}
#else
- UnityEngine.Debug.LogError("error : " + info + ", stack : " + trackStr);
+ UnityEngine.Debug.LogError(time + "error : " + info + ", stack : " + trackStr);
#endif
// 游戏中的错误日志
if (mFrameLogSystem != null)
{
mFrameLogSystem.logGameError(info);
- }
+ }
+ if (mOnLog != null)
+ {
+ mOnLog(time, "error : " + info + ", stack : " + trackStr, LOG_LEVEL.LL_FORCE, true);
+ }
}
public static new void logInfo(string info, LOG_LEVEL level = LOG_LEVEL.LL_NORMAL)
{
if ((int)level <= (int)mLogLevel)
{
+ string time = getTime();
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
// windows平台打包后使用LocalLog打印日志
if(mLocalLog != null)
@@ -92,8 +100,12 @@ public static LOG_LEVEL getLogLevel()
mLocalLog.log(getTime() + " : " + info);
}
#else
- UnityEngine.Debug.Log(getTime() + " : " + info);
+ UnityEngine.Debug.Log(time + " : " + info);
#endif
+ if(mOnLog != null)
+ {
+ mOnLog(time, info, level, false);
+ }
}
}
public static string getTime()
diff --git a/Assets/Scripts/Frame/DataBase/SQLite/SQLite.cs b/Assets/Scripts/Frame/DataBase/SQLite/SQLite.cs
index 18376c4..48c0ab1 100644
--- a/Assets/Scripts/Frame/DataBase/SQLite/SQLite.cs
+++ b/Assets/Scripts/Frame/DataBase/SQLite/SQLite.cs
@@ -93,12 +93,12 @@ public void queryNonReader(string queryString)
}
catch(Exception){}
}
- public T getTable()where T : SQLiteTable
+ public void getTable(out T table) where T : SQLiteTable
{
- if(mTableList.ContainsKey(typeof(T)))
+ table = null;
+ if (mTableList.ContainsKey(typeof(T)))
{
- return mTableList[typeof(T)] as T;
+ table = mTableList[typeof(T)] as T;
}
- return null;
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/GameFramework/GameFramework.cs b/Assets/Scripts/Frame/GameFramework/GameFramework.cs
index 555167c..0f4c75f 100644
--- a/Assets/Scripts/Frame/GameFramework/GameFramework.cs
+++ b/Assets/Scripts/Frame/GameFramework/GameFramework.cs
@@ -30,6 +30,7 @@ public void Start()
FrameBase.mLocalLog = new LocalLog();
FrameBase.mLocalLog.init();
#endif
+ UnityUtility.mOnLog = getLogCallback();
if (instance != null)
{
UnityUtility.logError("game framework can not start again!");
@@ -162,14 +163,14 @@ public virtual void keyProcess()
UnityUtility.setLogLevel((LOG_LEVEL)newLevel);
}
}
- public T getSystem()where T : FrameComponent
+ public void getSystem(out T component) where T : FrameComponent
{
+ component = null;
string name = typeof(T).ToString();
if(mFrameComponentMap.ContainsKey(name))
{
- return mFrameComponentMap[name] as T;
+ component = mFrameComponentMap[name] as T;
}
- return null;
}
public void setPasueFrame(bool value) { mPauseFrame = value; }
public bool getPasueFrame() { return mPauseFrame; }
@@ -203,6 +204,7 @@ protected virtual void lateUpdate(float elapsedTime)
mFrameComponentList[i].lateUpdate(elapsedTime);
}
}
+ protected virtual UnityUtility.onLog getLogCallback() { return null; }
protected virtual void notifyBase()
{
// 所有类都构造完成后通知FrameBase
@@ -328,6 +330,7 @@ protected void processScreen(int width, int height, int screenCount, ADAPT_SCREE
height = CommonDefine.STANDARD_HEIGHT;
#endif
Screen.SetResolution(width, height, fullScreen == 1 || fullScreen == 3);
+#if UNITY_EDITOR || (!UNITY_ANDROID && !UNITY_IOS)
// 设置为无边框窗口
if (fullScreen == 2)
{
@@ -338,6 +341,7 @@ protected void processScreen(int width, int height, int screenCount, ADAPT_SCREE
curStyle &= ~CommonDefine.WS_DLGFRAME;
User32.SetWindowLong(User32.GetForegroundWindow(), CommonDefine.GWL_STYLE, curStyle);
}
+#endif
GameObject uiRootObj = UnityUtility.getGameObject(null, "NGUIRoot");
GameObject rootMultiScreen = UnityUtility.getGameObject(null, "NGUIRootMultiScreen");
GameObject rootStretch = UnityUtility.getGameObject(null, "NGUIRootStretch");
diff --git a/Assets/Scripts/Frame/LayoutSystem/LayoutScript.cs b/Assets/Scripts/Frame/LayoutSystem/LayoutScript.cs
index e1f2c1d..4f08316 100644
--- a/Assets/Scripts/Frame/LayoutSystem/LayoutScript.cs
+++ b/Assets/Scripts/Frame/LayoutSystem/LayoutScript.cs
@@ -32,6 +32,7 @@ public override void destroy()
LayoutRegister.onScriptChanged(this, false);
base.destroy();
}
+ public bool isVisible() { return mLayout.isVisible(); }
public LAYOUT_TYPE getType() { return mType; }
public GameLayout getLayout() { return mLayout; }
public void setRoot(txUIObject root) { mRoot = root; }
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIEditbox.cs b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIEditbox.cs
index c4f36c6..fb33e1e 100644
--- a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIEditbox.cs
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIEditbox.cs
@@ -25,8 +25,16 @@ public string getText()
{
return mInput.value;
}
- public void setInputChangedCallback(EventDelegate.Callback callback)
+ public void setInputSubmitCallback(EventDelegate.Callback callback)
{
EventDelegate.Add(mInput.onSubmit, callback);
}
+ public void setOnValidateCallback(UIInput.OnValidate validate)
+ {
+ mInput.onValidate = validate;
+ }
+ public void setOnTabCallback(UIInput.OnKeyDelegate onTabDelegate)
+ {
+ mInput.onTabCallback = onTabDelegate;
+ }
}
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUISprite.cs b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUISprite.cs
index e21846c..9917e4f 100644
--- a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUISprite.cs
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUISprite.cs
@@ -30,7 +30,10 @@ public string getSpriteName()
}
public virtual void setAtlas(UIAtlas atlas)
{
- mSprite.atlas = atlas;
+ if(mSprite.atlas != atlas)
+ {
+ mSprite.atlas = atlas;
+ }
}
public void setSpriteName(string name, bool useSize = false)
{
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureAnimWithShader.cs b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureAnimWithShader.cs
index 5967c0e..cfb1beb 100644
--- a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureAnimWithShader.cs
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureAnimWithShader.cs
@@ -92,4 +92,13 @@ public override void init(GameLayout layout, GameObject go, txUIObject parent)
base.init(layout, go, parent);
setWindowShader();
}
+}
+//---------------------------------------------------------------------------------------------------------------------------
+public class txNGUITextureAnimPixelMaskCut : txNGUITextureAnim
+{
+ public override void init(GameLayout layout, GameObject go, txUIObject parent)
+ {
+ base.init(layout, go, parent);
+ setWindowShader();
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureWithShader.cs b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureWithShader.cs
index f7b1ee6..70246ef 100644
--- a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureWithShader.cs
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUITextureWithShader.cs
@@ -92,4 +92,13 @@ public override void init(GameLayout layout, GameObject go, txUIObject parent)
base.init(layout, go, parent);
setWindowShader();
}
+}
+//---------------------------------------------------------------------------------------------------------------------------
+public class txNGUITexturePixelMaskCut : txNGUITexture
+{
+ public override void init(GameLayout layout, GameObject go, txUIObject parent)
+ {
+ base.init(layout, go, parent);
+ setWindowShader();
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIVideo.cs b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIVideo.cs
index 0ac0651..0f54dd6 100644
--- a/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIVideo.cs
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/NGUI/txNGUIVideo.cs
@@ -115,9 +115,9 @@ public bool setFileURL(string url)
mFileName = getFileName(url);
mMediaPlayer.Events.RemoveAllListeners();
mTexture.mainTexture = null;
- mMediaPlayer.OpenVideoFromFile(MediaPlayer.FileLocation.AbsolutePathOrURL, url, false);
+ bool ret = mMediaPlayer.OpenVideoFromFile(MediaPlayer.FileLocation.AbsolutePathOrURL, url, false);
mMediaPlayer.Events.AddListener(onVideoEvent);
- return true;
+ return ret;
}
public string getFileName()
{
@@ -227,6 +227,7 @@ protected void clearAndCallEvent(ref VideoCallback callback, bool isBreak)
}
protected void onVideoEvent(MediaPlayer player, MediaPlayerEvent.EventType eventType, ErrorCode errorCode)
{
+ logInfo("video event : " + eventType, LOG_LEVEL.LL_HIGH);
if (eventType == MediaPlayerEvent.EventType.FinishedPlaying)
{
// 播放完后设置为停止状态
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShader.cs b/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShader.cs
index 36ca032..0571fe9 100644
--- a/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShader.cs
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShader.cs
@@ -4,7 +4,7 @@
using System.Text;
using UnityEngine;
-public class WindowShader
+public class WindowShader : GameBase
{
public WindowShader()
{}
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShaderPixelMaskCut.cs b/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShaderPixelMaskCut.cs
new file mode 100644
index 0000000..837da57
--- /dev/null
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShaderPixelMaskCut.cs
@@ -0,0 +1,38 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+public class WindowShaderPixelMaskCut : WindowShader
+{
+ protected Texture mMask;
+ protected Vector2 mMaskSize = Vector2.zero;
+ protected Vector2 mMaskPos = Vector2.zero;
+ public WindowShaderPixelMaskCut()
+ {}
+ public void setMaskTexture(Texture mask) { mMask = mask; }
+ public void setMaskSize(Vector2 size) { mMaskSize = size; }
+ public void setMaskPos(Vector2 pos) { mMaskPos = pos; }
+ public override void applyShader(Material mat)
+ {
+ base.applyShader(mat);
+ if (mat != null && mat.shader != null)
+ {
+ string shaderName = mat.shader.name;
+ if (shaderName == "PixelMaskCut")
+ {
+ mat.SetTexture("_MaskTex", mMask);
+ if(isVectorZero(mMaskSize))
+ {
+ mMaskSize = new Vector2(mMask.width, mMask.height);
+ }
+ mat.SetFloat("_SizeX", mMaskSize.x);
+ mat.SetFloat("_SizeY", mMaskSize.y);
+ mat.SetFloat("_PosX", mMaskPos.x);
+ mat.SetFloat("_PosY", mMaskPos.y);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShaderPixelMaskCut.cs.meta b/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShaderPixelMaskCut.cs.meta
new file mode 100644
index 0000000..60856f8
--- /dev/null
+++ b/Assets/Scripts/Frame/LayoutSystem/Window/WindowShader/WindowShaderPixelMaskCut.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8d9e636c5f13d514ebb005856affd19d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Frame/LayoutSystem/WindowPool.cs b/Assets/Scripts/Frame/LayoutSystem/WindowPool.cs
new file mode 100644
index 0000000..d8fc305
--- /dev/null
+++ b/Assets/Scripts/Frame/LayoutSystem/WindowPool.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+public class WindowPool
+{
+ protected Dictionary> mInusedList;
+ protected Dictionary> mUnusedList;
+ protected LayoutScript mScript;
+ protected txUIObject mPoolNode;
+ public WindowPool(LayoutScript script)
+ {
+ mScript = script;
+ mInusedList = new Dictionary>();
+ mUnusedList = new Dictionary>();
+ }
+ public void assignWindow()
+ {
+ mPoolNode = mScript.createObject("WindowPool");
+ }
+ public void destroy()
+ {
+ mScript.destroyObject(mPoolNode, true);
+ mPoolNode = null;
+ }
+ public T createWindow(string name, txUIObject parent) where T : txUIObject, new()
+ {
+ txUIObject window = null;
+ Type type = typeof(T);
+ // 从未使用列表中获取
+ if (mUnusedList.ContainsKey(type) && mUnusedList[type].Count > 0)
+ {
+ window = mUnusedList[type][mUnusedList[type].Count - 1];
+ mUnusedList[type].RemoveAt(mUnusedList[type].Count - 1);
+ }
+ // 未使用列表中没有就创建新窗口
+ if (window == null)
+ {
+ window = mScript.createObject(name);
+ }
+ // 加入到已使用列表中
+ if (!mInusedList.ContainsKey(type))
+ {
+ mInusedList.Add(type, new List());
+ }
+ mInusedList[type].Add(window);
+ window.setActive(true);
+ window.setName(name);
+ window.setParent(parent);
+ return window as T;
+ }
+ public void destroyWindow(T window) where T : txUIObject
+ {
+ if (window == null)
+ {
+ return;
+ }
+ Type type = typeof(T);
+ if (!mUnusedList.ContainsKey(type))
+ {
+ mUnusedList.Add(type, new List());
+ }
+ mUnusedList[type].Add(window);
+ mInusedList[type].Remove(window);
+ window.setActive(false);
+ window.setParent(mPoolNode);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Frame/LayoutSystem/WindowPool.cs.meta b/Assets/Scripts/Frame/LayoutSystem/WindowPool.cs.meta
new file mode 100644
index 0000000..c67e69f
--- /dev/null
+++ b/Assets/Scripts/Frame/LayoutSystem/WindowPool.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0b067e6d33bc4da4299fd3a97db159e3
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Frame/ResourceManager/AndroidAssetLoader.cs b/Assets/Scripts/Frame/ResourceManager/AndroidAssetLoader.cs
index 8131e6d..154a804 100644
--- a/Assets/Scripts/Frame/ResourceManager/AndroidAssetLoader.cs
+++ b/Assets/Scripts/Frame/ResourceManager/AndroidAssetLoader.cs
@@ -22,6 +22,7 @@ public override void destroy()
#endif
base.destroy();
}
+ public static AndroidJavaObject getCurrentActivity() { return mCurrentActivity; }
// 相对于StreamingAssets的路径
public static byte[] loadAsset(string path)
{