零零散散记录自己第一个项目所学习到的知识,本贴只是记录贴,项目完成后,还会重新整理的~~~~
1,1,3,4
1.动态实例化人物和id有关
2 传本地人物信息到服务器
3 接收传输消息
加上结束标志@ 读不到标记 丢弃数据
心跳包,单开线程,发送用户id
人物位置改变才发送
解析json的时候,有异常直接跳过。
LFkeen 2.3 -1.2 6.7
RFkeen -0.78 -0.2 1.6
头的朝向 小球控制脚的位置
重心 0.1 1.3
x 0.5 -0.5
y 1.7 0.9
人物速度 镜头旋转
人物脚点偏差
11.23
今下午任务点:1,实例化线路跟攀岩墙(攀岩墙要换为那套源码里面的墙壁)后 为什么攀爬不了以及BUG
2, 设定攀岩线路的后线路 岩石点会出现顺序数字 在那套源码中也有
3, 开始观战模式的开发,以及加入聊天sdk(环信sdk即可
before 0.27 0.35 需要提高 0.08
2017 11 24
重心按钮时,手部位置跟随
手脚定位到岩石位置过渡
2017.11.27 粘包分包问题
protobuf 的使用
http://blog.csdn.net/caisini_vc/article/details/5599468
https://www.cnblogs.com/jhli/p/6139914.html tool文件转换工具
https://github.com/mgravell/protobuf-net github API源文件
protogen.exe -i:Message.proto -o:Message.cs
protoc.exe –descriptor_set_out=ProtoBinTemp.protobin –include_imports Message.proto
protogen.exe ProtoBinTemp.protobin
del ProtoBinTemp.protobin
pause
定线标号,攀爬人物,房间密码
FixedUpdate的时间间隔可以在项目设置中更改,Edit->ProjectSetting->time 找到Fixedtimestep。就可以修改了。
0.02
2017.12.06 json插件使用 jsonFx ,需要创建实体类进行解析
NewBehaviourScript,PointTriggerHandCtrlSphere,小球会离开手
2017.12.08
NGUI适配方案 UIRoot 选择第二种模式 Constrained 1920 1080
UGUI是适配 Canvas下面的属性 设置为按宽高比 1920 1080 Match 0.5******
在UI排版的时候,需要使用容器*将物体存起来,然后设置容器的 锚点
调节老版GUI的字体大小
GUIStyle bb=new GUIStyle();
bb.normal.background = null; //这是设置背景填充的
bb.normal.textColor=new Color(1,0,0); //设置字体颜色的
bb.fontSize = 40; //当然,这是字体颜色
GUI.Label(new Rect(0, 0, 200, 200), aa,bb);
岩壁1 -0.02 6.66 -0.99
岩壁2 -0.08 8.21 -1.32
岩壁3 0 7.6 1.3
2017.12.17 Bug
难度对战 岩石双点的处理
加入房间已满 重复创建房间面板
人物小球范围限制
点击难度对战之后进入定线菜单不显示
比赛规则测试….
2017.12.19
Highlighted Sprite(高亮图片):选中状态或是鼠标靠近会进入高亮状态。
Pressed Sprite(按下图片):鼠标点击或是按钮处于选中状态时按下enter键。
Disabled Sprite(禁用图片):禁用时图片。
2017.12.21
chillhanlengSHU5.. //腾讯云密码
https://www.cnblogs.com/davidsheh/p/7410464.html 接入博客
http://www.cnblogs.com/msxh/p/7220741.html SDK接入与集成——小白入门篇
http://blog.csdn.net/qinyuanpei/article/details/49000907 在Unity3D中加载外部图片的两种方法
http://blog.csdn.net/alayeshi/article/details/72526725 unity深度查找某个子物体和遍历所有子物体方法
安卓与unity交互 http://blog.csdn.net/sky1466181491/article/details/70651043
//注意:要使用这个方法必须要满足两个条件:第一必须有你要查找的子物体的名字,第二必须要从一个父物体上开始查起
public static Transform GetTransform(Transform check, string name)
{
Transform forreturn = null;
foreach (Transform t in check.GetComponentsInChildren<Transform>())
{
if (t.name == name)
{
Debug.Log("得到最终子物体的名字是:" + t.name);
forreturn = t;
return t;
}
}
return forreturn;
}
https://www.cnblogs.com/guoguoguo/p/7350547.html 读取 网络图片
http://blog.csdn.net/tj134679258/article/details/51345562 Unity社交功能开发——图片上传
//检测手机号码是否合法
private bool CheckPhoneIsAble(string input)
{
if (input.Length < 11||input.Length>11)
{
return false;
}
//电信手机号码正则
string dianxin = @"^1[3578][01379]\d{8}$";
Regex regexDX = new Regex(dianxin);
//联通手机号码正则
string liantong = @"^1[34578][01256]\d{8}";
Regex regexLT = new Regex(liantong);
//移动手机号码正则
string yidong = @"^(1[012345678]\d{8}|1[345678][012356789]\d{8})$";
Regex regexYD = new Regex(yidong);
if (regexDX.IsMatch(input) || regexLT.IsMatch(input) || regexYD.IsMatch(input))
{
return true;
}
else
{
return false;
}
}
void Update () {
//捕获Android的系统返回键
if (Application.platform == RuntimePlatform.Android && (Input.GetKeyDown (KeyCode.Escape))) {
//弹窗,让玩家确认是否退出
dialog.SetActive (true);
}
}
private void Passcheck(string s)
{
if (s.Length > 16 || s.Length < 9) //密码长度不可大于十六位
{
print("请输入10到16位的密码");
return;
}
bool bl_exist = false;
foreach (char c in s)
{
if ((!char.IsLetter(c)) && (!char.IsNumber(c))) //既不是字母又不是数字的就认为是特殊字符
{ bl_exist = true; }
}
if (bl_exist)
print("存在特殊字符");
else
{
print("格式的正确");
}
}
//将账号和密码存储起来,实现记住密码功能
PlayerPrefs.SetString("Username", username);
PlayerPrefs.SetString("Password", password);
PlayerPrefs.SetString("Limit", limit); //存储权限信息
void Start()
{
if (PlayerPrefs.GetString("Account") != null || PlayerPrefs.GetString("Account") != "")
{
{
userName.text = PlayerPrefs.GetString("Username");
}
if (PlayerPrefs.GetString("Password") != null || PlayerPrefs.GetString("Password") != "")
{
passWord.text = PlayerPrefs.GetString("Password");
}
}
}
划重点
在使用Inputfield输入文字时,如果设置为Password格式,不能直接调用其子物体,应该用inputField.text调用,否则获得的字符串为
动态加载图片的两种方法
1 网络加载
Texture2D texture = www.texture;
//创建 Sprite
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
image.sprite = sprite;
2 直接加载(适合本地)
首先你得获得动态的Sprite。
比如你直接
public Sprite[] images ;//直接资源里的图片拖进去就行
public Image img;
img.Sprite = images[0];
ScrollRect的使用与制作 http://www.weixinnu.com/v/00xz2F
Viewport 添加ToggleGrop 组件
Content添加GridLayoutGroup 230*30
拖动Content可以扩大显示范围
判断时间的两种方法
void Update()
{
year = System.DateTime.Now.Year; //当前时间(年)
month = System.DateTime.Now.Month; //当前时间(月)
day = System.DateTime.Now.Day; // 当前时间(日)
h = System.DateTime.Now.Hour; // 当前时间(时)
min = System.DateTime.Now.Minute; // 当前时间(分)
second = System.DateTime.Now.Second; // 当前时间(秒)
if (year == 2017 && month == 12 && day == 28 && h == 20 && min == 17)
{
Debug.LogWarning("开始比赛啦!");
}
DateTime d = new DateTime(2017, 12, 28, 20, 20, 0);
if (DateTime.Now >= d)
{
Debug.LogWarning("开始比赛啦!");
}
//if(DateTime.Now==new DateTime(2017,))
}
https://www.cnblogs.com/caymanlu/p/6361675.html 时间相关
/// <summary>
/// 时间戳Timestamp
/// </summary>
/// <returns></returns>
private int GetCreatetime(DateTime endTime)
{
DateTime DateStart = new DateTime(1970, 1, 1, 8, 0, 0);
return Convert.ToInt32((endTime - DateStart).TotalSeconds);
}
/// 时间戳转为C#格式时间
/// </summary>
/// <param name=”timeStamp”></param>
/// <returns></returns>
private DateTime GetTime(string timeStamp)
{
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
return dtStart.Add(toNow);
}
DateTime date1 = new DateTime(2017, 12, 31, 9, 20, 0);
string str1= date1.ToString("yyyy-MM-dd HH:mm:ss");
DateTime date2 = new DateTime(2017, 12, 31, 11, 0, 0);
string str2=date2.ToString("yyyy-MM-dd HH:mm:ss");
print("更换格式后的时间"+ str1+","+str2);
更换格式后的时间2017-12-31 09:20:00,2017-12-31 11:00:00
Unity3d通用工具类之定时触发器
https://www.cnblogs.com/CaomaoUnity3d/p/4940655.html
Unity使用JsonFX插件进行序列化
http://blog.csdn.net/u010019717/article/details/46636009
User user = new User();
user.club = "123";
user.gender = "false";
string sr = JsonWriter.Serialize(user);
print(sr);
正准备把所有的窗口都由Canvas来管理的时候,看到Canvas下面有一个Sort Order 。
Sort这个词看起来就比较符合口味,排序嘛!
试着把菊花窗口的Sort修改为100,再运行,果然生效!
//把资源加载到内存中
Object cubePreb = Resources.Load("InventItem", typeof(GameObject));
//用加载得到的资源对象,实例化游戏对象,实现游戏物体的动态加载
GameObject cube = Instantiate(cubePreb) as GameObject;
foreach (string s in teachingId)
{
sendStr= sendStr.Insert(sendStr.Length , s+","); //将list集合的数据插入到string中
}
sendStr = sendStr.TrimEnd(','); //截取结尾的“,”
https://www.cnblogs.com/junbird-nest/archive/2012/03/23/2413482.html C#操作字符串方法总结<转>
Unity3D再次点击以退出程序 http://blog.csdn.net/zhaokuo_123456/article/details/53994477
Unity3D手机中Input类touch详解-Unity触屏事件解析到底(Twisted Fate)
https://www.cnblogs.com/kenzi/p/3739517.html
动态更新Scroll View content 的长度 保证所有子项目都可以加载出来
Content Size Fitter http://blog.csdn.net/qq_26999509/article/details/53394854
2018.03.20
控制NGUI摇杆移动范围
//超出范围返回
if (UICamera.lastTouchPosition.x >= 600 || UICamera.lastTouchPosition.y>=600)
{
joystickPos.localPosition = Vector3.zero;
h = 0; v = 0;
return;
}
检测是否点击到UI
bool isClick = UICamera.Raycast(Input.mousePosition);