脚本相关
文章平均质量分 58
颠沛流离。。
这个作者很懒,什么都没留下…
展开
-
屏蔽字
using UnityEngine;using System.Collections;using System.Collections.Generic;using NTFrame;using System.IO;using System.Text.RegularExpressions;public class WordFiltterManager : Singleton { st原创 2016-10-12 11:03:47 · 1482 阅读 · 0 评论 -
Unity3d读取Josn,xml等非手动拼写,换行符不识别的问题
表格配置程序读取数据之后直接 赋值给 UILable。但是运行之后却并没有换行。*** 重点我直接赋值表格里的话,直接贴到uilable上,就瞬间换行了!!!!!一直怀疑是ngui的问题。。。看脚本和导出的json数据,结果发现 导出来的数据,原来的 " \n " 变成了 " \\n " 。解决方法m_MainNoticeText原创 2016-07-28 20:14:36 · 918 阅读 · 0 评论 -
C# 【String】 用法
// String.Format 用法string text1 = "1";string text2 = "2";string endString = "";endString = string.Format("{0}/{1}", text1,text2);Debug.Log(endString); // 1/2endString = string.Format("{0}/h",原创 2016-03-05 11:10:27 · 684 阅读 · 0 评论 -
判断距离自己最近的点
// 当前的位置 Vector2 newPos = WorldMapRayPosition.CurrentXY; List list = new List (); // 排序顺序:距离远的在前 距离近的在后 list.Sort((lpos, rpos)=> { if(Vector2.Distance(newPos,lpos) > Vector2.Distanc原创 2016-07-18 18:01:21 · 961 阅读 · 0 评论 -
UITool 2
using UnityEngine;using System.Collections;using System.Collections.Generic;using CommonDelegate;public class UITools { public static void PlayAnimtionWithCallBack(Animator animator,string acti原创 2016-06-21 17:43:02 · 1253 阅读 · 0 评论 -
3D模型--UITexture
using UnityEngine;using System.Collections;using System.Collections.Generic;using NTFrame;public class RenderAvatar : SingletonMono { public delegate void DoSomething(RenderAvatarItem item);原创 2016-07-06 14:42:13 · 430 阅读 · 0 评论 -
AI
using UnityEngine;using System.Collections;using System.Collections.Generic;using System;using CommonEnum;public enum FeastUIChangedType{ FeastUIChangedType_Congratulated = 1, FeastUICh原创 2016-07-06 14:38:15 · 281 阅读 · 0 评论 -
相机抖动
Camera.main.transform.DOShakePosition(0.3f);原创 2016-07-13 20:35:02 · 980 阅读 · 0 评论 -
数组中最接近N的数
int FindNearest (float f, float[] array) { float distance = Mathf.Infinity; int output = 0; for (int index = 0; index < array.Length; index++) { if (Mathf.Abs (array [index] - f) < distance)原创 2015-11-24 14:36:11 · 1007 阅读 · 0 评论 -
MusicManager
using UnityEngine;using System.Collections;using System.Collections.Generic; using NTFrame;public class MusicCallBackInfo{ public float mTime; public CommonDelegate.VoidDelegate mFunc = null;原创 2016-07-08 11:01:57 · 315 阅读 · 0 评论 -
UILabel 数字动画
using System;using UnityEngine;public class UILabelNumberAnima : MonoBehaviour{ public CommonDelegate.VoidDelegate OnAnimaEnd = null; UIRichLabel _RichLabel; UILabel _Label; bool _BeginAnima原创 2016-07-20 18:27:01 · 649 阅读 · 0 评论 -
【时间戳】
1. 通过时间戳 - 获取 2016-8-12 10:07:25 时间格式/// /// 返回 2016-8-12 10:07:25 /// /// 时间戳 public static string GetDataTime(long time) { System.DateTime dtDateTime = new System.DateTime(1970, 1, 1);原创 2016-08-12 10:46:54 · 903 阅读 · 0 评论 -
Unity Text 插入图片
http://blog.csdn.net/akof1314/article/details/49028279转载 2016-08-23 17:40:15 · 1859 阅读 · 0 评论 -
NGUI 富文本
文本[ff0000]带[-][00ff00]颜[-][0000ff]色[-]. [b]粗体[/b][i]斜体[/i][u]下划线[/u][s]删除线[/s][b][u]大[i][s]杂[/u][/b]烩[/i][/s]正常文本[sup]上标[/sup]正常文本[sub]下标[/sub][ffff00]不支持[sup]上标[sub]下原创 2016-08-23 15:39:57 · 2485 阅读 · 1 评论 -
NGUI 超链接
using UnityEngine;using System.Collections;using System.Collections.Generic;using System.Text.RegularExpressions;using System;using System.Text;using CommonEnum;// 我是超人!public class ParseStri原创 2016-08-15 16:41:51 · 1354 阅读 · 0 评论 -
【游戏】随机名字
using UnityEngine;using System.Collections;using System.Collections.Generic;using System.IO;using LitJson;using NTFrame;using ProtoBuf;[ProtoContract]public class CharNamesData{ [ProtoMembe原创 2016-08-10 14:04:20 · 10243 阅读 · 0 评论 -
HarvestAnimation
收拾粮食 从收拾粮食的位置 动画 到 top资源条 using UnityEngine;using System.Collections;using NTFrame;using CommonEnum;using System.Collections.Generic;public class HarvestAnimation : SingletonMono{ GameO原创 2016-08-30 20:28:23 · 356 阅读 · 0 评论 -
NGUI坑 之 首行缩进
有人问了一个问题,UILabel怎么进行首行缩进,第一感觉是加两格空格,回答不行。自己建了个Label测试,不行,多打几个字直接换行了。囧百度无结果。NGUI官网搜索,无结果,好像有说英文下是可以的,还有说右对齐的,还有说字体里面没有空格符的.......都不是我要的结果。Google,返了几页后,发现一片文章 NGU原创 2016-08-08 15:09:40 · 797 阅读 · 0 评论 -
游戏里的文本tips
大概实现效果如图! 下面是实现的脚本!!!!using UnityEngine;using System.Collections;using System.Collections.Generic;/// /// 提示条/// public class UIInfoTips : MonoBehaviour{ public static int BgHeight =原创 2016-08-08 14:18:13 · 510 阅读 · 0 评论 -
tips 设
private void SetPos() { if (_SelectItem == null) return; gameObject.transform.position = _SelectItem.transform.position; Vector3 local_pos = gameObject.transform.localPosition; local_po原创 2016-06-14 15:59:58 · 327 阅读 · 0 评论 -
字典排序
void Sort(){ SortedDictionary dic = new SortedDictionary(); dic.Add(1,"1"); dic.Add(12,"12"); dic.Add(5,"15"); //输出:"1","15","12"}暂时我只知道这样做原创 2016-03-03 21:06:02 · 318 阅读 · 0 评论 -
C# 【Math】 用法
1. 【 Mathf.Ceil】用法int allCount = 1;float result = (float)allCount/3f; // 0.33333float height = Mathf.Ceil(result);// 1原创 2016-03-05 11:15:05 · 2076 阅读 · 0 评论 -
UITabEx
using UnityEngine;using System.Collections;using CommonDelegate;[RequireComponent(typeof(BoxCollider))][RequireComponent(typeof(UIWidget))]public class UITabEx : MonoBehaviour{ [SerializeFiel原创 2016-03-30 21:01:00 · 338 阅读 · 0 评论 -
Itween
public void SetButtonRotate(GameObject obj, bool isSelect) { if (isSelect) { //open Hashtable tabel = new Hashtable(); tabel.Add("rotation", new Vector3(0, 0, -90)); tabel.Add("time",原创 2016-04-08 14:09:48 · 344 阅读 · 0 评论 -
DoTweenPositionEx
如图动画using UnityEngine;using System.Collections;using DG.Tweening;public class DoTweenPositionEx : MonoBehaviour { [SerializeField] Vector3 from = Vector3.zero; [SerializeField] Vector3 to =原创 2016-04-18 16:47:36 · 336 阅读 · 0 评论 -
c# 字典
Dictionary _Heros = new Dictionary(); // 定义字段 List aaa = new List(_Heros.Values) ;// 获取value列表原创 2016-05-07 11:45:04 · 965 阅读 · 0 评论 -
数字 转换成 .千百万
Debug.Log(string.Format("90000:{0}",ClientTools.ConvertNumToKM(90000)));public static string ConvertNumToKM(int num) { float value = 0; string result = num.ToString(); if (num >= 1000000) {原创 2016-05-09 21:00:01 · 1266 阅读 · 0 评论 -
不规则items排序
1. obj的身上的脚本继承与下面这个类 (以便排序的时候获取方便,直接获取这个脚本的height 和 width就好了)using UnityEngine;using System.Collections;public class UIItemSize : MonoBehaviour { /// /// 高 /// public int _height = 0; ///原创 2016-05-13 10:44:55 · 379 阅读 · 0 评论 -
按照“规则”拆分字符串
public void SetData(string text) { Init(); UITools.SetCachedItemHide(mItems); string[] strs = ParseSymbol(text); if(strs == null) return; if (mGrid == null || mItem == null) return;原创 2016-06-12 15:09:21 · 867 阅读 · 0 评论 -
声音
紧接上面博客,设置游戏里的各种声音吧!!!1. 各种UIbutton的点击 music......(1) 声音控制的脚本using UnityEngine;using System.Collections;public class UIButtonMusic : MonoBehaviour { public string mMusicName = "ui_click"原创 2016-07-08 21:16:46 · 565 阅读 · 0 评论 -
读取XML方法
using UnityEngine;using System.Collections;using System.Collections.Generic;using NTFrame;using System.Security;public class WorldMusicCtrl : SingletonMono { public Dictionary mDatasLists原创 2016-07-11 11:07:45 · 332 阅读 · 0 评论 -
UIRichLabel
using UnityEngine;using System.Collections;using System.Collections.Generic;using System.Text.RegularExpressions;using System;/* * sprite标签格式: * framesprite标签格式: * button标签格式: */public cl原创 2016-03-30 20:20:12 · 851 阅读 · 1 评论 -
Edtior
using UnityEngine;using UnityEditor;using System.Collections;public class NTEditorMenu : MonoBehaviour { [MenuItem("Game/NTTool/坐标取整", false, 3)] static void ResetPositionToInt() { GameObjec原创 2016-03-30 18:27:24 · 470 阅读 · 0 评论 -
C# 传方法function / 传带参数的方法function
定义类似枚举---using UnityEngine;using System.Collections;namespace DelegateTools{ public delegate void VoidDelegate();// 传方法 public delegate void IdDelegate(long id);// 传带参数的方法(long id) public del原创 2016-03-05 14:49:42 · 5413 阅读 · 0 评论 -
数字 1 转换成 “一” (10-> “十”,25-> “二十五”,.....)
public static string getNumStr(int num) { string strnum = string.Empty; int temp_num = num; bool has_0 = false; //千 int temp_qian = temp_num / 1000; if(temp_qian > 0) { strnum原创 2016-03-15 14:08:59 · 563 阅读 · 0 评论 -
拖拽
using UnityEngine;using System.Collections;using System.Collections.Generic;using System;public class DragManager{ DragItem _DragItem = null;}public class Item : MonoBehaviour { public UI原创 2016-03-18 15:55:40 · 449 阅读 · 0 评论 -
items排序
/// /// x 位置 通用 /// y 第一个obj的y /// padding 行距 /// items obj数组 /// public static void SortItems(List items,int padding = 100,float x = 0.0f,float y =0.0f) { for (int k = 0; k < items.Cou原创 2016-03-24 11:36:02 · 326 阅读 · 0 评论 -
items 排序 0
第一种 - x横向排序 y纵向排序 (每行只有一个) /// -------------------------------y /// x 位置 通用 /// y 第一个obj的y /// padding 行距 /// items obj数组 /// public static void SortItems(L原创 2016-03-24 13:08:13 · 244 阅读 · 0 评论 -
[ClientTool] 项目里用到的工具func
定义一个数据类吧 - 正常根据项目而定public class ItemDataStruct{ public int _Id; public int _Num; public ItemDataStruct() { } public ItemDataStruct(int id, int num) { Init(id,num); } public ItemDataSt原创 2016-03-24 14:53:50 · 1104 阅读 · 0 评论 -
置灰 Manager
using UnityEngine;using System.Collections;using System.Collections.Generic;using NTFrame;public class GrayUIManager : SingletonMono{ public Hashtable shaderTable = new Hashtable(); publ原创 2016-03-25 11:16:50 · 300 阅读 · 0 评论