UNITY 2D 筆記

2020/09/06 更新
官方學習網站 https://learn.unity.com
2020版本 有黑色介面可以免費使用
ASSETSTORE 素材改至線上開啟

跨平台的遊戲引擎,可用於開發 Windows、MacOS、Linux 單機遊戲

以UNITY開發之遊戲:

簡易版中文教學影片:
阿空(他還有c2教學)
https://youtu.be/1JlnnJBaOjM

英文教學影片:

https://www.youtube.com/user/Brackeys

基本環境

(忘記附圖片)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Scene是場景,開發時用來查看場景的視窗。

Game則是實體遊戲視窗。

Hierarchy顯示場景中存在的物件
其中的Main Camera叫做主要攝影機

右方的Project視窗是專案資源視窗,
顯示圖片、音效、場景檔案等等的素材。

Inspector是資訊視窗,會顯示物件或素材的相關資訊。

Asset Store 已移除

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

上方的選單

  • File – 檔案
  • Edit – 編輯
  • Assets – 資產
  • GameObject – 遊戲物件
  • Component – 組件
  • Window – 視窗
  • Help – 幫助

點擊GameObject會出現以下選單 分別是

  • Create Empty – 創造空物件
  • Create Empty Child – 創造空的子物件
  • 3D Object – 3D物件
  • 2D Object – 2D物件
  • Light – 燈光
  • Audio – 聲音
  • UI – 介面
  • Particle System – 粒子系統
  • Camera – 攝影機

1.建立人物及say hello word

GAMEOBJECT >> 2D Object >> Sprite

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

注意

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Texture type default 要改為 sprite

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

PROJECT 匯入的圖檔拖曳至Hierarchy視窗中直接建立一個Sprite物件。

更改Scene camera視窗大小

camera

選擇Main Camera >> projection >>

可選擇數值或滑桿調整

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

scene

按住『ALT』(win)、『OPTION』(mac)
左鍵即可拖移

快捷鍵:

  • Q鍵 拖移畫面
  • W鍵 移動主角XY軸
  • E鍵 旋轉主角XY軸
  • R鍵 縮放主角
  • T鍵 變形主角
  • F鍵可以聚焦
  • CTRL (COMMAND FOR MAC ) + P 播放

按著Shift鍵時,物件的旋轉會以15度為單位,縮放則會是等比例控制

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

四個按鈕,由左至右依序是2D視角切換、光線預覽、音效預覽、天空盒預覽

撰寫程式碼

Create(創建) -> C# Script(C#腳本)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

*c"#" 升記號 = c sharp *

滑鼠點兩下 Project >> c#腳本

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Start is called before the first frame update
物件創造時會執行

Update is called once per frame

刷新即會執行

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

未完待續