久久精品国产亚洲高清|精品日韩中文乱码在线|亚洲va中文字幕无码久|伊人久久综合狼伊人久久|亚洲不卡av不卡一区二区|精品久久久久久久蜜臀AV|国产精品19久久久久久不卡|国产男女猛烈视频在线观看麻豆

千鋒教育-做有情懷、有良心、有品質(zhì)的職業(yè)教育機構(gòu)

手機站
千鋒教育

千鋒學(xué)習(xí)站 | 隨時隨地免費學(xué)

千鋒教育

掃一掃進入千鋒手機站

領(lǐng)取全套視頻
千鋒教育

關(guān)注千鋒學(xué)習(xí)站小程序
隨時隨地免費學(xué)習(xí)課程

當(dāng)前位置:首頁  >  技術(shù)干貨  > unity學(xué)習(xí)筆記(一)

unity學(xué)習(xí)筆記(一)

來源:千鋒教育
發(fā)布人:qyf
時間: 2022-07-19 17:18:00 1658222280

  當(dāng)對一個父GameObject進行無效設(shè)置后,它的子類gameobject也會無效,但是并沒有改變子類的狀態(tài),也就是說你沒有辦法使用它自身的屬性activeSelf,判斷一個子gameobject是否是激活狀態(tài),要使用activeInHierarchy。如果要改變子類的狀態(tài),使用DeactivateChildren

  使用transform的一些建議

  1,最好把它的父transforn的位置設(shè)置為(0,0,0)這樣對于它來說本地坐標(biāo)和世界坐標(biāo)是一樣的

  2,粒子系統(tǒng)的縮放不受transform的影響,需要去設(shè)置粒子發(fā)射器

  3,Rigidbody的縮放也不受transform影響,需要在Rigidbody組件上面設(shè)置

  4,修改父類的坐標(biāo)會影響子類的本坐標(biāo)

  旋轉(zhuǎn)的正確使用方法

  錯誤一

  // rotation scripting mistake #1

  // the mistake here is that we are modifying the x value of a quaternion

  // this value does not represent an angle, and will not produce desired results

  void Update () {

  var rot = transform.rotation;

  rot.x += Time.deltaTime * 10;

  transform.rotation = rot;

  }

  錯誤二

  // rotation scripting mistake #2

  // the mistake here is that we are reading, modifying then writing the Euler

  // values from a quaternion. Because these values calculated from a Quaternion,

  // each new rotation may return very different Euler angles, which may suffer from gimbal lock.

  void Update () {

  var angles = transform.rotation.eulerAngles;

  angles.x += Time.deltaTime * 10;

  transform.rotation = Quaternion.Euler(angles);

  }

  正確的方法

  // rotation scripting with Euler angles correctly.

  // here we store our Euler angle in a class variable, and only use it to

  // apply it as a Euler angle, but we never rely on reading the Euler back.

  float x;

  void Update () {

  x += Time.deltaTime * 10;

  transform.rotation = Quaternion.Euler(x,0,0);

  }

  unity的dll路徑

  mac:Applications/Unity/Unity.app/Contents/Frameworks/Managed/

  windows:C:\Program Files\Unity\Editor\Data\Managed

  加載AssetBundles的四種方式

  1,AssetBundle.LoadFromMemoryAsync

  IEnumerator LoadFromMemoryAsync(string path)

  {

  AssetBundleCreateRequest createRequest = AssetBundle.LoadFromMemoryAsync(File.ReadAllBytes(path));

  yield return createRequest;

  AssetBundle bundle = createRequest.assetBundle;

  var prefab = bundle.LoadAsset.("MyObject");

  Instantiate(prefab);

  }

  這種方式是異步加載一組包含AssetBundle 數(shù)據(jù)的byte數(shù)組到內(nèi)存中,可以添加CRC校驗,如果使用了LZMA壓縮,會自動解壓

  2,AssetBundle.LoadFromFile

  public class LoadFromFileExample extends MonoBehaviour {

  function Start() {

  var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "myassetBundle"));

  if (myLoadedAssetBundle == null) {

  Debug.Log("Failed to load AssetBundle!");

  return;

  }

  var prefab = myLoadedAssetBundle.LoadAsset.("MyObject");

  Instantiate(prefab);

  }

  }

  Note: On Android devices with Unity 5.3 or older, this API will fail when trying to load AssetBundles from the Streaming Assets path. This is because the contents of that path will reside inside a compressed .jar file. Unity 5.4 and newer can use this API call with Streaming Assets just fine

  3,WWW.LoadFromCacheOrDownload

  using UnityEngine;

  using System.Collections;

  public class LoadFromCacheOrDownloadExample : MonoBehaviour

  {

  IEnumerator Start ()

  {

  while (!Caching.ready)

  yield return null;

  var www = WWW.LoadFromCacheOrDownload("http://myserver.com/myassetBundle", 5);

  yield return www;

  if(!string.IsNullOrEmpty(www.error))

  {

  Debug.Log(www.error);

  yield return;

  }

  var myLoadedAssetBundle = www.assetBundle;

  var asset = myLoadedAssetBundle.mainAsset;

  }

  }

  4,UnityWebRequest

  The UnityWebRequest has a specific API call to deal with AssetBundles. To begin, you’ll need to create your web request using UnityWebRequest.GetAssetBundle. After returning the request, pass the request object into DownloadHandlerAssetBundle.GetContent(UnityWebRequest). This GetContent call will return your AssetBundle object.

  You can also use the assetBundle property on the DownloadHandlerAssetBundle class after downloading the bundle to load the AssetBundle with the efficiency of AssetBundle.LoadFromFile.

  Here’s an example of how to load an AssetBundle that contains two GameObjects and Instantiate them. To begin this process, we’d just need to call StartCoroutine(InstantiateObject());

  IEnumerator InstantiateObject()

  {

  string uri = "file:///" + Application.dataPath + "/AssetBundles/" + assetBundleName; UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(uri, 0);

  yield return request.Send();

  AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);

  GameObject cube = bundle.LoadAsset("Cube");

  GameObject sprite = bundle.LoadAsset("Sprite");

  Instantiate(cube);

  Instantiate(sprite);

  }

  打包之后查看各個資源的大小日志

  This information is available in the Editor Log just after you have performed the build. Go to the Console window (menu: Window < Console), click the small drop-down panel in the top right, and select Open Editor Log.

  在unity中減少圖片的像素

  try to reduce the physical size (in pixels) of the Texture images. To do this without modifying the actual source content, select the Texture in the Project view, and in the Inspector window reduce the Max Size. To see how this looks in-game, zoom in on a GameObject that uses the Texture, then adjust the Max Size until it starts looking worse in the Scene view. Changing the maximum Texture size does not affect your Texture Asset, just its resolution in the game.

  By default, Unity compresses all Textures when importing. For faster workflow in the Editor, go to Unity < Preferences and untick the checkbox for Compress Assets on Import. All Textures are compressed in the build, regardless of this setting.

1

  更多關(guān)于“unity培訓(xùn)”的問題,歡迎咨詢千鋒教育在線名師。千鋒教育多年辦學(xué),課程大綱緊跟企業(yè)需求,更科學(xué)更嚴(yán)謹(jǐn),每年培養(yǎng)泛IT人才近2萬人。不論你是零基礎(chǔ)還是想提升,都可以找到適合的班型,千鋒教育隨時歡迎你來試聽。

tags:
聲明:本站稿件版權(quán)均屬千鋒教育所有,未經(jīng)許可不得擅自轉(zhuǎn)載。
10年以上業(yè)內(nèi)強師集結(jié),手把手帶你蛻變精英
請您保持通訊暢通,專屬學(xué)習(xí)老師24小時內(nèi)將與您1V1溝通
免費領(lǐng)取
今日已有369人領(lǐng)取成功
劉同學(xué) 138****2860 剛剛成功領(lǐng)取
王同學(xué) 131****2015 剛剛成功領(lǐng)取
張同學(xué) 133****4652 剛剛成功領(lǐng)取
李同學(xué) 135****8607 剛剛成功領(lǐng)取
楊同學(xué) 132****5667 剛剛成功領(lǐng)取
岳同學(xué) 134****6652 剛剛成功領(lǐng)取
梁同學(xué) 157****2950 剛剛成功領(lǐng)取
劉同學(xué) 189****1015 剛剛成功領(lǐng)取
張同學(xué) 155****4678 剛剛成功領(lǐng)取
鄒同學(xué) 139****2907 剛剛成功領(lǐng)取
董同學(xué) 138****2867 剛剛成功領(lǐng)取
周同學(xué) 136****3602 剛剛成功領(lǐng)取
相關(guān)推薦HOT
什么是PlatformIo?

PlatformIO是什么PlatformIO是一個全面的物聯(lián)網(wǎng)開發(fā)平臺,它為眾多硬件平臺和開發(fā)環(huán)境提供了統(tǒng)一的工作流程,有效簡化了開發(fā)過程,并能兼容各種...詳情>>

2023-10-14 12:55:06
云快照與自動備份有什么區(qū)別?

1、定義和目標(biāo)不同云快照的主要目標(biāo)是提供一種快速恢復(fù)數(shù)據(jù)的方法,它只記錄在快照時間點后的數(shù)據(jù)變化,而不是所有的數(shù)據(jù)。自動備份的主要目標(biāo)...詳情>>

2023-10-14 12:48:59
服務(wù)器為什么要用Linux?

服務(wù)器為什么要用Linux作為服務(wù)器操作系統(tǒng)的優(yōu)選,Linux在眾多選擇中脫穎而出。Linux作為服務(wù)器操作系統(tǒng)的優(yōu)選,有其獨特的優(yōu)勢和特點。包括其...詳情>>

2023-10-14 12:34:11
ORM解決的主要問題是什么?

ORM(對象關(guān)系映射)解決的主要問題是將關(guān)系數(shù)據(jù)庫與面向?qū)ο缶幊讨g的映射困境。在傳統(tǒng)的關(guān)系數(shù)據(jù)庫中,數(shù)據(jù)以表格的形式存儲,而在面向?qū)ο?..詳情>>

2023-10-14 12:26:19
Go為什么不支持三元運算符?

Go為什么不支持三元運算符Go語言是一種以簡潔和有效性為目標(biāo)的編程語言,因此在設(shè)計過程中,Go的設(shè)計者刻意排除了一些他們認(rèn)為可能導(dǎo)致復(fù)雜性或...詳情>>

2023-10-14 12:12:36