Unity 3D 開發(fā)《王者榮耀》:Hello World

Unity 安裝


Unity 官方網(wǎng)站:https://unity3d.com

點擊右上角的 獲取Unity

系統(tǒng)要求

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 設置

  • 代碼格式化(自動對齊):(三個鍵同時按下)

Windows

Ctrl+K+D

macOS

^ + I
  • Tab(制表符) 轉 4 個 Space (空格)
Tab.png

在 Camera 上面添加 C# 腳本。

Hello World


https://zh.m.wikipedia.org/zh-sg/Hello_World

Hello, World是指在電腦屏幕顯示“Hello, World!”(你好,世界?。┳址挠嬎銠C程序。相關的程序通常都是每種電腦編程語言最基本、最簡單的程序,也會用作示范一個編程語言如何運作[1]。同時它亦可以用來確認一個編程語言的編譯器、程序開發(fā)環(huán)境及運行環(huán)境是否已經(jīng)安裝妥當。因為寫法簡單可見,這也是很多初學者首次接觸編程語言時會撰寫的程序。

傳統(tǒng)用途

傳統(tǒng)來說,當一位程序員接觸一門新的編程語言的時候,“Hello, World”就會成為首個接觸的內容。

與此同時,相同的字符串亦會用作檢測開發(fā)環(huán)境是否安裝妥當以及相關的操作人員是否理解相關的環(huán)境。

歷史

于1972年,Bear實驗室成員布萊恩·柯林漢撰寫的內部技術文件《A Tutorial Introduction to the Language B》首次提到了Hello World這字符串。當時,他使用B語言撰寫了第一個使用參數(shù)的Hello World相關程序:

main(){
  extrn a,b,c;
  putchar(a); putchar(b); putchar(c); putchar('!*n');
  }

a 'hell';
b 'o, w';
c 'orld';

由 布萊恩·柯林漢 撰寫的“Hello, world”程序 (1978年)
這個程序成為了第一個Hello World的示范程序。之所以會這樣切割,是因為于B語言中,每個參數(shù)只能放置四個ASCII字符[5]。兩年后,布萊恩·柯林漢和丹尼斯·里奇基于B語言寫成C語言后,在他們撰寫的《C程序設計語言》使用更簡單的方式展示Hello World:

#include <stdio.h>

main( )
{
        printf("hello, world\n");
}

自此,Hello World成為了電腦程序員學習新的編程語言的傳統(tǒng)[6]。但是,有些人認為 hello, world 的字符串早于1966年的BCPL語言出現(xiàn)的時候已經(jīng)出現(xiàn)[7]。雖然相關的字詞確實在發(fā)明者記錄的文件出現(xiàn),但是可以肯定的是,Hello World這字符串于當時確實未變得流行。因此,人們公認為布萊恩·柯林漢是令相關字符串走進公眾目光的人。

但是需要注意的是,Hello World的初始寫法為“hello, world”,并沒有任何感嘆號,全部都是小寫,內含逗號,后面亦有空格,而和現(xiàn)在流行的寫法并不一致。

Unity 中的 Hello World

VS.png
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 區(qū)別

.NET Decompiler  .NET反編譯器 ILSpy: https://github.com/icsharpcode/ILSpy

  • vs 中查看 print 定義
print.png
  • 找到 dll 路徑
#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
// 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
// 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 等。

PrintMonoBehaviour 的一個成員。

Debug 則是一個密閉的類。
所以在使用的范圍上,Print 必須要繼承 MonoBehaviour 類,而 Debug 不用。

在 ILSpy 中反編譯 UnityEngine.CoreModule.dll 這個 DLL 會發(fā)現(xiàn) Print 方法的實現(xiàn)其實非常簡單。

結論:Print 就是 Debug.Log 的一個簡單封裝。實現(xiàn)就是通過Debug.Log來完成的。

運行

Run.png

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

GitHub for Unity 是一款將 unity 發(fā)布到 GitHub 的擴展插件。

今天剛剛發(fā)布了 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 創(chuàng)建一個空的倉庫。
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 。

issus: Push 按鈕是灰色的,不能點擊

用命令行工具上傳

$ git push -u origin master

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

明天加載地圖,控制英雄運動。

簡寶玉寫作群日更打卡第 32 天

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • afinalAfinal是一個android的ioc,orm框架 https://github.com/yangf...
    wgl0419閱讀 6,566評論 1 9
  • afinalAfinal是一個android的ioc,orm框架 https://github.com/yangf...
    passiontim閱讀 15,835評論 2 45
  • 小女子不才,未能讓公子傾心 那一年,梅花樹下,只見公子紅衣如火,如畫中神人,小女子不才,將一縷凡心落于卿身...
    顏梟閱讀 633評論 0 8
  • 題目描述 Given two sorted integer arrays nums1 and nums2, mer...
    云胡同學閱讀 230評論 0 0
  • @作者博客 簡單記憶一下知識 : SpringBoot 是什么? 快速開發(fā),簡單入門. IDEA Main快捷鍵 ...
    chcvn閱讀 472評論 0 2

友情鏈接更多精彩內容