LOFTER for ipad —— 让兴趣,更有趣

点击下载 关闭
Unity-变量定义与Debug.LogFormat()格式输出
Zeiod 2022-02-25

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class t1 : MonoBehaviour

{

    // Start is called before the first frame update

    void Start()

    {

        //案例:名字 血量 等级 经验值

        string strName = "怪物A";

        int iHpValue = 1000;

        int iLevel = 100;

        long lExp = 1000000000000;


        Debug.Log("名字:"+strName+",血量:"+iHpValue+",等级:"+iLevel+",经验值:"+lExp);//涉及多字符串合并浪费内存。因为字符串在内存中不可变更。

        Debug.LogFormat("名字:{0},血量:{1},等级:{2},经验值:{3}", strName,iHpValue,iLevel,lExp);

        Debug.LogWarningFormat("名字:{0},血量:{1},等级:{2},经验值:{3}", strName,iHpValue,iLevel,lExp);

        Debug.LogErrorFormat("名字:{0},血量:{1},等级:{2},经验值:{3}", strName,iHpValue,iLevel,lExp);

    }


    // Update is called once per frame

    void Update()

    {

        

    }

}


推荐文章
评论(0)
分享到
转载我的主页