Unity project combat (the first)

I record the knowledge I learned from my first project in bits and pieces. This post is just a record post. After the project is completed, it will be reorganized~~~~~~

1,1,3,4

1. Dynamically instantiate character and id related
2 Pass local character information to server
3 Receive transmission message

Add the end mark @ can not read the mark and discard the data
Heartbeat packet, single open thread, send user id

When the character's position is changed, it is sent. When
parsing json, there is an exception and it is skipped directly.

LFkeen 2.3 -1.2 6.7
RFkeen -0.78 -0.2 1.6

Head towards the ball to control the position of the feet

Center of Gravity 0.1 1.3
x 0.5 -0.5
y 1.7 0.9

Character speed lens rotation
Character foot point deviation

11.23
Task points this afternoon: 1. Why can't climb after instantiating the route and the climbing wall (the climbing wall should be replaced with the wall in the source code) and BUG
2, After setting the climbing route, the rock points of the route will appear in the sequence number at There are also 3 in the source code
, start the development of the spectator mode, and join the chat sdk (the ring letter sdk can be used)

before 0.27 0.35 needs to be improved by 0.08

2017 11 24
When the center of gravity button is pressed, the hand position follows the hand and
foot positioning to the transition from the rock position

2017.11.27 The problem of sticky subcontracting

The use of protobuf
http://blog.csdn.net/caisini_vc/article/details/5599468
https://www.cnblogs.com/jhli/p/6139914.html tool file conversion tool
https://github.com/mgravell /protobuf-net github API source files

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

The time interval of alignment label, climbing character, and room password
FixedUpdate can be changed in the project settings, Edit->ProjectSetting->time to find Fixedtimestep. can be modified.
0.02

2017.12.06 The json plugin uses jsonFx and needs to create an entity class for parsing

NewBehaviourScript, PointTriggerHandCtrlSphere, the ball will leave the hand

2017.12.08
NGUI adaptation scheme UIRoot Select the second mode Constrained 1920 1080
UGUI is adapted to Canvas. The properties below are set to 1920 1080 Match 0.5 according to aspect ratio******
When UI layout, you need to use a container * Save the object, then set the anchor point of the container
Adjust the font size of the old GUI
GUIStyle bb=new GUIStyle();
bb.normal.background = null; //This is the background fill
bb.normal.textColor=new Color (1,0,0); //set font color
bb.fontSize = 40; //of course, this is font color
GUI.Label(new Rect(0, 0, 200, 200), aa,bb);

Wall 1 -0.02 6.66 -0.99 Wall
2 -0.08 8.21 -1.32 Wall
3 0 7.6 1.3

2017.12.17
The handling of the double point of the double-point battle against the rock in the Bug Difficulty. The
added room is full. The room panel is repeatedly created. The range of the character
ball is limited .

2017.12.19
Highlighted Sprite (highlighted picture): The selected state or the mouse closes will enter the highlighted state.
Pressed Sprite: Press enter when the mouse is clicked or the button is selected.
Disabled Sprite: Picture when disabled.

2017.12.21
chillhanlengSHU5.. //Tencent cloud password
https://www.cnblogs.com/davidsheh/p/7410464.html access blog
http://www.cnblogs.com/msxh/p/7220741.html SDK access Entry and Integration - Introduction to Xiaobai
http://blog.csdn.net/qinyuanpei/article/details/49000907Two methods of loading external pictures in Unity3Dhttp
://blog.csdn.net/alayeshi/article/ details/72526725 Unity finds a sub-object in depth and traverses all sub-object methods.
Android interacts with unity http://blog.csdn.net/sky1466181491/article/details/70651043

//Note: To use this method, two conditions must be met: the first must have the name of the child object you are looking for, and the second must start from a parent object.
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.htmlRead network pictureshttp
://blog.csdn.net/tj134679258/article/details/51345562 Unity social function development - picture upload

    //检测手机号码是否合法
    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");
            }
        }
}

The key point
is that when using Inputfield to input text, if it is set to Password format, its sub-object cannot be called directly, it should be called with inputField.text, otherwise the obtained string is

Two methods of dynamically loading pictures
1 Network loading

            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 Direct loading (suitable for local)

首先你得获得动态的Sprite。
比如你直接 
public Sprite[] images ;//直接资源里的图片拖进去就行
public Image img;


img.Sprite = images[0];

The use and production of ScrollRecthttp: //www.weixinnu.com/v/00xz2F

Viewport Add ToggleGrop component
Content Add GridLayoutGroup 230*30
Drag Content to expand the display range

Two ways to judge time

    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.htmlTime related

    /// <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);

The time after changing the format 2017-12-31 09:20:00, 2017-12-31 11:00:00

Timing trigger for Unity3d general tools
https://www.cnblogs.com/CaomaoUnity3d/p/4940655.html

Unity uses JsonFX plugin for serializationhttp
://blog.csdn.net/u010019717/article/details/46636009

        User user = new User();
        user.club = "123";
        user.gender = "false";
        string sr = JsonWriter.Serialize(user);
        print(sr);

When I was about to manage all windows by Canvas, I saw a Sort Order under Canvas.

The word Sort seems to be more in line with taste, sort it!

Try to change the Sort of the chrysanthemum window to 100, and then run it, it really takes effect!

        //把资源加载到内存中  
        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# operation string method summary <transfer>

Unity3D click again to exit the programhttp: //blog.csdn.net/zhaokuo_123456/article/details/53994477
Detailed explanation of Input class touch in Unity3D mobile phone-Unity touch screen event analysis to the end (Twisted Fate)
https://www.cnblogs.com /kenzi/p/3739517.html

Dynamically update the length of Scroll View content to ensure that all sub-items can be loaded
Content Size Fitter http://blog.csdn.net/qq_26999509/article/details/53394854

2018.03.20
Control the movement range of NGUI joystick

            //超出范围返回
            if (UICamera.lastTouchPosition.x >= 600 || UICamera.lastTouchPosition.y>=600)
            {
                joystickPos.localPosition = Vector3.zero;
                h = 0; v = 0;
                return;
            }

Detect if clicked to UI

        bool isClick = UICamera.Raycast(Input.mousePosition);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325849837&siteId=291194637