Skip to content

Commit

Permalink
同步代码
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHOURUIH committed Nov 13, 2018
1 parent 6f9a161 commit 15e41a4
Show file tree
Hide file tree
Showing 30 changed files with 537 additions and 66 deletions.
7 changes: 7 additions & 0 deletions Assets/NGUI/Scripts/UI/UIInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ [DoNotObfuscateNGUI] public enum OnReturnKey
}

public delegate char OnValidate (string text, int charIndex, char addedChar);
public delegate void OnKeyDelegate();

/// <summary>
/// Currently active input field. Only valid during callbacks.
Expand Down Expand Up @@ -185,6 +186,7 @@ [DoNotObfuscateNGUI] public enum OnReturnKey
/// </summary>

public OnValidate onValidate;
public OnKeyDelegate onTabCallback;

/// <summary>
/// Input field's value.
Expand Down Expand Up @@ -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();
}
}
}

Expand Down
84 changes: 84 additions & 0 deletions Assets/Resources/Material/PixelMaskCut.mat
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 8 additions & 0 deletions Assets/Resources/Material/PixelMaskCut.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions Assets/Resources/Shader/Frame/PixelMaskCut.shader
Original file line number Diff line number Diff line change
@@ -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"
}
9 changes: 9 additions & 0 deletions Assets/Resources/Shader/Frame/PixelMaskCut.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions Assets/Scripts/Frame/Character/CharacterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Character> characterMap = new Dictionary<string, Character>();
characterMap.Add(character.getName(), character);
mCharacterTypeList.Add(character.getType(), characterMap);
mCharacterTypeList.Add(character.getType(), new Dictionary<string, Character>());
}
mCharacterTypeList[character.getType()].Add(character.getName(), character);
// 加入ID索引表
int characterID = character.getCharacterData().mGUID;
if (!mCharacterGUIDList.ContainsKey(characterID))
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Frame/Common/CommonDefine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public enum SOUND_OWNER
public enum CHARACTER_TYPE
{
CT_NORMAL,
CT_NPC,
CT_AI,
CT_OTHER,
CT_MYSELF,
Expand Down Expand Up @@ -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 + "/";
Expand Down
11 changes: 10 additions & 1 deletion Assets/Scripts/Frame/Common/DoubleBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ public class DoubleBuffer<T> : GameBase
protected int mWriteIndex;
protected int mReadIndex;
protected ThreadLock mBufferLock;
protected int mWriteListLimit;
public DoubleBuffer()
{
mBufferList = new List<T>[2];
mBufferList[0] = new List<T>();
mBufferList[1] = new List<T>();
mWriteIndex = 0;
mReadIndex = 1;
mWriteListLimit = 0;
mBufferLock = new ThreadLock();
}
// 切换缓冲区,获得可读列表,在遍历可读列表期间,不能再次调用getReadList,否则会出现不可预知的错误,并且该函数只能在一个线程中调用
Expand All @@ -31,7 +33,14 @@ public List<T> 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;
}
}
42 changes: 22 additions & 20 deletions Assets/Scripts/Frame/Common/FrameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,26 +39,27 @@ public virtual void notifyConstructDone()
if (mGameFramework == null)
{
mGameFramework = GameFramework.instance;
mCommandSystem = mGameFramework.getSystem<CommandSystem>();
mAudioManager = mGameFramework.getSystem<AudioManager>();
mGameSceneManager = mGameFramework.getSystem<GameSceneManager>();
mCharacterManager = mGameFramework.getSystem<CharacterManager>();
mLayoutManager = mGameFramework.getSystem<GameLayoutManager>();
mKeyFrameManager = mGameFramework.getSystem<KeyFrameManager>();
mGlobalTouchSystem = mGameFramework.getSystem<GlobalTouchSystem>();
mShaderManager = mGameFramework.getSystem<ShaderManager>();
mSQLite = mGameFramework.getSystem<SQLite>();
mDataBase = mGameFramework.getSystem<DataBase>();
mCameraManager = mGameFramework.getSystem<CameraManager>();
mResourceManager = mGameFramework.getSystem<ResourceManager>();
mLayoutSubPrefabManager = mGameFramework.getSystem<LayoutSubPrefabManager>();
mApplicationConfig = mGameFramework.getSystem<ApplicationConfig>();
mFrameConfig = mGameFramework.getSystem<FrameConfig>();
mObjectManager = mGameFramework.getSystem<ObjectManager>();
mInputManager = mGameFramework.getSystem<InputManager>();
mSceneSystem = mGameFramework.getSystem<SceneSystem>();
mClassObjectPool = mGameFramework.getSystem<ClassObjectPool>();
mSQLiteSound = mSQLite.getTable<SQLiteSound>();
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);
}
}
// 方便书写代码添加的命令相关函数
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/Frame/Common/Serialize/SerializedData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ protected void zeroParams()
}
protected void pushParam(OBJECT param)
{
if(param == null)
{
logError("param is null!");
}
mParameterInfoList.Add(param);
}
};
Loading

0 comments on commit 15e41a4

Please sign in to comment.