This commit is contained in:
2020-07-04 14:41:25 +08:00
parent 70c346d2c1
commit a8f02e4da5
3748 changed files with 587372 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8b73df330179e4c0386b6625be043204
folderAsset: yes
timeCreated: 1484616171
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
#if UNITY_3_5
[CustomEditor(typeof(UIRichText4Chat))]
#else
[CustomEditor(typeof(UIRichText4Chat), true)]
#endif
public class UIRichText4ChatInspector : Editor {
UIRichText4Chat richText4Chat;
public override void OnInspectorGUI ()
{
richText4Chat = target as UIRichText4Chat;
GUILayout.BeginHorizontal();
if (NGUIEditorTools.DrawPrefixButton ("Face Atlas")) {
ComponentSelector.Show<UIAtlas> (OnSelectAtlas);
}
SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "faceAtlas", GUILayout.MinWidth(20f));
if (atlas != null) {
UIAtlas atl = atlas.objectReferenceValue as UIAtlas;
if(atl != richText4Chat.faceAtlas) {
Debug.Log(atl.name);
richText4Chat.faceAtlas = atl;
richText4Chat.atlasName = atl.name;
}
}
if (GUILayout.Button("Edit", GUILayout.Width(40f)))
{
if (atlas != null)
{
UIAtlas atl = atlas.objectReferenceValue as UIAtlas;
NGUISettings.atlas = atl;
NGUIEditorTools.Select(atl.gameObject);
}
}
GUILayout.EndHorizontal();
DrawDefaultInspector ();
}
void OnSelectAtlas (Object obj)
{
Debug.Log (obj.name);
serializedObject.Update();
SerializedProperty sp = serializedObject.FindProperty("faceAtlas");
sp.objectReferenceValue = obj;
serializedObject.ApplyModifiedProperties();
sp = serializedObject.FindProperty("atlasName"); // add by chenbin
sp.stringValue = obj.name; // add by chenbin
serializedObject.ApplyModifiedProperties(); // add by chenbin
NGUITools.SetDirty(serializedObject.targetObject);
NGUISettings.atlas = obj as UIAtlas;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5be76ad9e40b34277ab6eb7c822df9df
timeCreated: 1458617527
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a19c0cffd4e64404ca76350ceb726ae8
folderAsset: yes
timeCreated: 1484616170
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: AtlasFaces
m_Shader: {fileID: 4800000, guid: e75727d9555d9d14ca51d91908c681bc, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: 10fc19a6461fa435eb615a3be5074fee, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: []
m_Colors: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a1df35f6ce796465a89f39f652cc56b1
timeCreated: 1458532376
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: 10fc19a6461fa435eb615a3be5074fee
timeCreated: 1458532417
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: 5
maxTextureSize: 4096
textureSettings:
filterMode: 2
aniso: 4
mipBias: -1
wrapMode: 1
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,108 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &146738
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 472624}
- component: {fileID: 11446434}
m_Layer: 0
m_Name: AtlasFaces
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &472624
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 146738}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &11446434
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 146738}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4d0c51bb0b6e93049af5e88f93826e3b, type: 3}
m_Name:
m_EditorClassIdentifier:
material: {fileID: 2100000, guid: a1df35f6ce796465a89f39f652cc56b1, type: 2}
mSprites:
- name: 1
x: 0
y: 66
width: 63
height: 62
borderLeft: 0
borderRight: 0
borderTop: 0
borderBottom: 0
paddingLeft: 0
paddingRight: 1
paddingTop: 1
paddingBottom: 1
path:
- name: 2
x: 0
y: 2
width: 62
height: 63
borderLeft: 0
borderRight: 0
borderTop: 0
borderBottom: 0
paddingLeft: 1
paddingRight: 1
paddingTop: 0
paddingBottom: 1
path:
- name: 3
x: 64
y: 66
width: 62
height: 62
borderLeft: 0
borderRight: 0
borderTop: 0
borderBottom: 0
paddingLeft: 1
paddingRight: 1
paddingTop: 1
paddingBottom: 1
path:
- name: 4
x: 63
y: 3
width: 62
height: 62
borderLeft: 0
borderRight: 0
borderTop: 0
borderBottom: 0
paddingLeft: 1
paddingRight: 1
paddingTop: 1
paddingBottom: 1
path:
mPixelSize: 1
mReplacement: {fileID: 0}
mCoordinates: 0
sprites: []
_isBorrowSpriteMode: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd0c99e3e6c2a4868aa8da41fd2b7681
timeCreated: 1458532376
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
using UnityEngine;
using System.Collections;
public class PanelChatTest : MonoBehaviour {
public TweenPosition twPosFaceList;
public UIInput input;
public UIRichText4Chat richText;
public UIRichText4Chat labelContent;
public void onClickSend(GameObject go) {
if (string.IsNullOrEmpty (input.value))
return;
labelContent.value += "\n" + input.value;
input.value = "";
}
public void onClick4ShowFaceList(GameObject go) {
twPosFaceList.Play (true);
}
public void onSelectedFace(GameObject go) {
twPosFaceList.Play (false);
UISprite sp = go.GetComponent<UISprite> ();
string[] strs = sp.spriteName.Split ('_');
string faceName = "";
if (strs.Length > 1) {
faceName = "#" + strs[1] + "#";
} else {
faceName = "#" + sp.spriteName + "#";
}
input.Insert (faceName);
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f4e4030308fed4e87937e34b648247ec
timeCreated: 1458623616
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5c7a6e8bf22a44963ac21a93a1a03318
timeCreated: 1458532199
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 862d536b9060a4a609101cfeb9931285
folderAsset: yes
timeCreated: 1484616172
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: b51cb32832d7a4b76bd06ba63853372d
timeCreated: 1458532377
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 1
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: 45050b72c63bb4cd6a3bc03423530001
timeCreated: 1458532377
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 1
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: a0f88887750234316b8549c75ddcb2aa
timeCreated: 1458532377
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 1
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: 07d88cc0a2259422b9355f9041533c2c
timeCreated: 1458532377
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 1
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7aa68d49698064a1bb3237d52e77c034
folderAsset: yes
timeCreated: 1484616169
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,456 @@
/// <summary>
/// User interface rich text4 chat.
/// add by chenbin
/// 2016-03-22
/// </summary>
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// User interface rich text4 chat.
/// </summary>
public class UIRichText4Chat : MonoBehaviour
{
public UILabel _label;
public UILabel label
{
get
{
if (_label == null)
{
_label = GetComponent<UILabel>();
}
return _label;
}
set
{
_label = value;
}
}
[HideInInspector]
public UIAtlas
faceAtlas;
//表情所在的图集
public string atlasName;
public int faceSize = 30;
public float faceScaleOffset = 1;
//表情图片的大小最好是font大小的整数倍当与字体是一样大小时为最宜
// public static List<string> faceList = new List<string> ();
public string faceHead = "";
public bool isFullSpace = true;
//用一个全角空格来占表情的位置,***因次使用的font中需要包含全角空格***
// [HideInInspector]
public float
spaceSize = -1;
public static string
_FaceChar_ = " ";
[HideInInspector]
public int
spaceNumber = -1;
[HideInInspector]
public string
faceStr = "";
public static SpritePool pool = new SpritePool();
public List<UISprite> spList = new List<UISprite>();
[ContextMenu("init")]
public void init()
{
if (isFullSpace)
{
_FaceChar_ = " "; //用一个全角空格来占表情的位置,***因次使用的font中需要包含全角空格***
}
else
{
_FaceChar_ = "."; //用半角空格来占位不知道为何有问题,因此用一个“.“来占位
}
calculateSpaceSize();
}
public void calculateSpaceSize()
{
string oldStr = label.text;
mTempVerts.Clear();
mTempIndices.Clear();
label.text = _FaceChar_;
string text = label.processedText;
label.UpdateNGUIText();
NGUIText.PrintExactCharacterPositions(text, mTempVerts, mTempIndices);
if (mTempVerts.size > 1)
{
spaceSize = mTempVerts[mTempVerts.size - 1].x - mTempVerts[0].x;
spaceNumber = Mathf.CeilToInt(faceSize / spaceSize);
}
mTempVerts.Clear();
mTempIndices.Clear();
label.text = oldStr;
faceStr = "";
for (int i = 0; i < spaceNumber; i++)
{
faceStr += _FaceChar_;
}
}
string mText = "";
public string value
{
get
{
return mText;
}
set
{
if (mText != value)
{
mText = value;
onTextChanged(gameObject);
}
}
}
public string wrapFaceName(string faceName)
{
return string.IsNullOrEmpty(faceHead) ? faceName : faceHead + faceName;
}
public void onInputChanged(GameObject go)
{
if (go == null)
return;
UIInput input = go.GetComponent<UIInput>();
if (input == null)
return;
value = input.value;
}
static BetterList<Vector3> mTempVerts = new BetterList<Vector3>();
static BetterList<int> mTempIndices = new BetterList<int>();
bool isFinishInit = false;
[ContextMenu("Execute Text Changed")]
public void onTextChanged(GameObject go)
{
if (!isFinishInit)
{
isFinishInit = true;
init();
}
clean();
mTempVerts.Clear();
mTempIndices.Clear();
string str = findFace();
label.text = str;
string text = label.processedText;
label.UpdateNGUIText();
NGUIText.PrintExactCharacterPositions(label.text, mTempVerts, mTempIndices);
// for (int i=0; i < mTempVerts.size; i++) {
// Debug.Log (mTempVerts [i]);
// }
ArrayList keyList = new ArrayList();
keyList.AddRange(facesMap.Keys);
int count = keyList.Count;
int index = 0;
string faceName = "";
Vector3 pos = Vector3.zero;
for (int i = 0; i < count; i++)
{
index = (int)(keyList[i]);
if (index * 2 + 1 < mTempVerts.size)
{
faceName = facesMap[index].ToString();
// Debug.Log ("index==" + index);
// Debug.Log("faceName==" + faceName);
pos = calculatePos(mTempVerts[index * 2], mTempVerts[index * 2 + 1]);
showFace(faceName, pos);
}
}
keyList.Clear();
mTempVerts.Clear();
mTempIndices.Clear();
}
/// <summary>
/// Calculates the position. search for #xx#
/// </summary>
/// <returns>The position.</returns>
/// <param name="pos1">Pos1.</param>
/// <param name="pos2">Pos2.</param>
public Vector3 calculatePos(Vector3 pos1, Vector3 pos2)
{
float offsetX = label.printedSize.x;
if (label.overflowMethod == UILabel.Overflow.ResizeHeight)
{
offsetX = label.localSize.x;
}
Vector3 pos = pos1;
Vector3 diff = pos2 - pos;
switch (label.pivot)
{
case UIWidget.Pivot.Center:
pos.x -= offsetX / 2.0f;
pos.y += label.printedSize.y / 2.0f;
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.TopLeft:
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.BottomLeft:
pos.y += label.printedSize.y;
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.Left:
pos.y += label.printedSize.y / 2.0f;
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.Right:
pos.x -= offsetX;
pos.y += label.printedSize.y / 2.0f;
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.TopRight:
pos.x -= offsetX;
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.BottomRight:
pos.x -= offsetX;
pos.y += label.printedSize.y;
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.Top:
pos.x -= offsetX / 2.0f;
pos.y += diff.y / 2.0f;
break;
case UIWidget.Pivot.Bottom:
pos.x -= offsetX / 2.0f;
pos.y += label.printedSize.y;
pos.y += diff.y / 2.0f;
break;
}
return pos;
}
public void showFace(string faceName, Vector3 pos)
{
UISprite sp = pool.getSprite();
spList.Add(sp);
NGUITools.SetLayer(sp.gameObject, gameObject.layer);
sp.pivot = UIWidget.Pivot.Left;
sp.atlas = faceAtlas;
sp.spriteName = wrapFaceName(faceName);
sp.SetDimensions(faceSize, faceSize);
sp.transform.parent = transform;
sp.transform.localScale = Vector3.one * faceScaleOffset;
if (sp.transform.parent == label.transform)
{
sp.transform.localPosition = pos;
}
else
{
sp.transform.localPosition = pos + label.transform.localPosition;
}
sp.depth = label.depth + 1;
NGUITools.SetActive(sp.gameObject, true);
}
Hashtable facesMap = new Hashtable();
public string findFace()
{
facesMap.Clear();
if (string.IsNullOrEmpty(value))
return "";
int len = value.Length;
string str = "";
int offset = 0;
string faceName = "";
for (int i = 0; i < len; i++)
{
// Debug.Log("val==[" + value[i] + "]");
if (value[i] == '\n')
{
offset += 1;
}
else if (value[i] == '\\' && (i + 1 < len) && value[i + 1] == 'n')
{
offset += 2;
}
else if (value[i] == '[' && i + 7 < len && value[i + 7] == ']')
{
offset += 8;
}
else if (value[i] == '[' && i + 2 < len && value[i + 1] == '-' && value[i + 2] == ']')
{
offset += 3;
}
// Debug.Log ("val==[" + value [i] + "]==" + offset);
if (value[i] == '#')
{
faceName = "";
for (int j = i + 1; j < len; j++)
{
if (value[j] == '\n')
{
offset += 1;
}
else if (value[j] == '\\' && (j + 1 < len) && value[j + 1] == 'n')
{
offset += 2;
}
else if (value[i] == '[' && i + 7 < len && value[i + 7] == ']')
{
offset += 8;
}
else if (value[i] == '[' && i + 2 < len && value[i + 1] == '-' && value[i + 2] == ']')
{
offset += 3;
}
// Debug.Log ("val==[" + value [j] + "]==" + offset);
if (value[j] == '#')
{
if (faceAtlas.spriteMap.Contains(wrapFaceName(faceName)))
{
facesMap[str.Length - offset] = faceName;
str += faceStr;
faceName = "";
i = j;
}
else
{
str += ("#" + faceName);
faceName = "";
i = j - 1;
}
break;
}
else
{
faceName += value[j];
if (j == len - 1)
{
i = j;
}
}
}
}
else
{
str += value[i];
}
}
if (!string.IsNullOrEmpty(faceName))
{
str += "#" + faceName;
}
return str;
}
[ContextMenu("Clean")]
public void clean()
{
int count = spList.Count;
for (int i = 0; i < count; i++)
{
pool.retSprite(spList[i]);
// spList [i].transform.parent = null;
// NGUITools.SetActive (spList [i].gameObject, false);
}
spList.Clear();
}
public void OnDestroy()
{
clean();
UISprite[] sps = label.GetComponentsInChildren<UISprite>(true);
int count = sps.Length;
for (int i = 0; i < count; i++)
{
if (sps[i].name == "__Sprite__")
{
sps[i].transform.parent = null;
}
}
}
public void OnDisable()
{
clean();
}
public void OnEnable()
{
onTextChanged(gameObject);
}
//图表对像池
public class SpritePool
{
Queue<UISprite> queue = new Queue<UISprite>();
public void clean()
{
queue.Clear();
}
public UISprite getSprite()
{
if (queue.Count <= 0)
{
return newSprite();
}
else
{
UISprite sp = queue.Dequeue();
try
{
if (sp == null && sp.gameObject == null)
{
return getSprite();
}
else
{
return sp;
}
}
catch (System.Exception e)
{
// Debug.LogError (e);
return getSprite();
}
}
}
public void retSprite(UISprite sp)
{
try
{
queue.Enqueue(sp);
NGUITools.SetActive(sp.gameObject, false);
//sp.gameObject.transform.parent = null;
}
catch (System.Exception e)
{
Debug.LogWarning(e);
}
}
public UISprite newSprite()
{
GameObject go = new GameObject("__Sprite__");
go.transform.parent = null;
UISprite sp = go.AddComponent<UISprite>();
NGUITools.SetActive(go, false);
return sp;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a21715691d40148e6bc0fbb23f7fb1ac
timeCreated: 1458531416
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: