前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Unity 3D 开发《王者荣耀》:Hello WorldUnity 安装《王者荣耀》 App Store 英文名称是 《Arena of Valor》GitHub for Unity:https

Unity 3D 开发《王者荣耀》:Hello WorldUnity 安装《王者荣耀》 App Store 英文名称是 《Arena of Valor》GitHub for Unity:https

作者头像
iOSDevLog
发布2018-06-21 17:17:59
1.2K0
发布2018-06-21 17:17:59
举报
文章被收录于专栏:iOSDevLogiOSDevLog

Unity 安装


Unity 官方网站:https://unity3d.com

点击右上角的 获取Unity

系统要求

OS: Windows 7 SP1+, 8, 10, 64-bit versions only; Mac OS X 10.9+. GPU:有DX9(着色器模型2.0)功能的显卡。2004年以来的产品应该都可以。

版本

Unity 2018.1.1f1: https://unity3d.com/cn/unity/whatsnew/unity-2018.1.1

默认安装即可。

登录 Unity 账户,我有一个 Unity 线下活动中的一年 Unity Plus with Unity Teams Advanced

  • ¥2,880.00/year

再不用就浪费了。555

Key.png

《王者荣耀》 App Store 英文名称是 《Arena of Valor》

Arena of Valor

Visual Studio 设置

  • 代码格式化(自动对齐):(三个键同时按下)
代码语言:javascript
复制
Ctrl+K+D
  • Tab(制表符) 转 4 个 Space (空格)

Tab.png

在 Camera 上面添加 C# 脚本。

Hello World

VS.png

代码语言:javascript
复制
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HelloWorld : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {
        print("Hello, World!");
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log("hello, world");
    }
}

print vs Debug.Log 区别

.NET Decompiler  .NET反编译器 ILSpy: https://github.com/icsharpcode/ILSpy

  • vs 中查看 print 定义

print.png

  • 找到 dll 路径
代码语言:javascript
复制
#region 程序集 UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// C:\Program Files\Unity\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
#endregion

VS_print.png

  • ILSpy 打开 dll 搜索 print 方法之后 Ctrl + 点击 Debug.log

ILSpy_print.png

代码语言:javascript
复制
// UnityEngine.MonoBehaviour
/// <summary>
///   <para>Logs message to the Unity Console (identical to Debug.Log).</para>
/// </summary>
/// <param name="message"></param>
public static void print(object message)
{
    Debug.Log(message);
}
  • ILSpy 查看 Debug.log 方法

ILSpy_Debug.log.png

代码语言:javascript
复制
// UnityEngine.Debug
/// <summary>
///   <para>Logs message to the Unity Console.</para>
/// </summary>
/// <param name="message">String or object to be converted to string representation for display.</param>
/// <param name="context">Object to which the message applies.</param>
public static void Log(object message)
{
    unityLogger.Log(LogType.Log, message);
}

在学习或使用 Unity 的时候,就会遇到调试的问题,在 Unity 3d 中调试比较麻烦,不像在vs中可以直接设置断点来调,所以选择打印消息的方式来调试。

但是打印消息也有几种方式,一种的 Print ,一种的 Debug.Log 。

Print 是 MonoBehaviour 的一个成员。

Debug则是一个密闭的类。 所以在使用的范围上,Print必须要继承MonoBehaviour类,而Debug不用。

在 ILSpy 中反编译 UnityEngine.CoreModule.dll 这个 DLL 会发现 Print 方法的实现其实非常简单。

结论:Print 就是 Debug.Log 的一个简单封装。实现就是通过Debug.Log来完成的。所以Print就是Debug.Log的一个简单封装。

运行

Run.png

GitHub for Unity:https://unity.github.com/

GitHub for Unity 是一款将 unity 发布到 GitHub 的扩展插件。

今天刚刚发布了 1.0 版本。

GitHub for Unity

If the current Unity project is not in a Git repository, the GitHub for Unity extension will offer to initialize the repository for you. This will:

  • Initialize a git repository at the Unity project root via git init 初始化 git
  • Initialize git-lfs via git lfs install 安装 git-lfs 和 git lfs
  • Set up a .gitignore file at the Unity project root. 添加 .gitignore 到 Unity 项目根目录
  • Set up a .gitattributes file at the Unity project root with a large list of known binary filetypes (images, audio, etc) that should be tracked by LFS 添加 .gitattributes 文件过滤 大文件
  • Configure the project to serialize meta files as text 设置 meta
  • Create an initial commit with the .gitignore and .gitattributes file. 初始化提交包括 .gitignore and .gitattributes 在内的文件

Publish a new repository

  1. Go to github.com and create a new empty repository - do not add a license, readme or other files during the creation process. 去 github.com 创建一个空的仓库。

github.png

  1. Copy the https URL shown in the creation page 拷贝 https URL。
  2. In Unity, go to Windows -> GitHub -> Settings and paste the url into the Remote textbox. 在 Unity 中添加远程仓库。
  3. Click Save repository. 保存。

remote.png

  1. Go to the History tab and click Push. 推送到 github.com

GitHub for Unity链接: https://pan.baidu.com/s/1atsoakxUFDDbFcSlIme1qw 密码: ytsv

明天加载地图,控制英雄运动。

简宝玉写作群日更打卡第 32 天

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.05.22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Unity 安装
    • 系统要求
      • 版本
  • 《王者荣耀》 App Store 英文名称是 《Arena of Valor》
    • Visual Studio 设置
      • Hello World
        • print vs Debug.Log 区别
      • 运行
        • Publish a new repository
    • GitHub for Unity:https://unity.github.com/
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档