朱峰社區(qū)首頁 朱峰社區(qū)

搜索資源 注冊|登陸

等待

返回 展開菜單
按功能 按軟件

unity3d視頻教程

unity3d視頻教程

包含11節(jié)視頻教程

從零基礎(chǔ)學(xué)習(xí)unity3d游戲引擎,簡單易學(xué)的視頻教程,讓你快速掌握unity3d,并喜歡上游戲開發(fā)的樂趣。

關(guān)閉

Unity組件:Text Asset 文本資源

關(guān)注:1671 留言:0 樓主:ml4621632 發(fā)帖時間:15年11月16日

ml4621632

普通會員

ml4621632

社區(qū)新人:1級

關(guān)注2165人

  • 性別

  • 年齡

    18

  • 積分

    1

  • 登陸

    1

  • 發(fā)帖

    2

  • 作品

    1

間隔線

Text Assets are a format for imported text files. When you drop a text file into your Project Folder, it will be converted to a Text Asset. The supported text formats are:

文本資源是導(dǎo)入的文本文件的一個格式。當(dāng)你拖入一個文本文件到你的項目時,他會被轉(zhuǎn)換為文本資源。支持的文本格式有:

  • .txt
  • .html
  • .htm
  • .xml
  • .bytes


The Text Asset Inspector

Properties 屬性
  • Text 文本
    The full text of the asset as a single string.
    該資產(chǎn)的完整文本作為一個單一的字符串。
Details 細節(jié)

The Text Asset is a very specialized use case. It is extremely useful for getting text from different text files into your game while you are building it. You can write up a simple .txt file and bring the text into your game very easily. It is not intended for text file generation at runtime. For that you will need to use traditional Input/Output programming techniques to read and write external files.

文本資源是一個非常專業(yè)的使用情況。他通常用于從不同的文本文件中得到文本到你的游戲中當(dāng)你編譯他時。你可以寫一個簡單的.txt文件并且很容易的把文本帶入到你的游戲中去。其目的不是在運行時生成文本文件。為此,你需要使用傳統(tǒng)的輸入/輸出的編程技術(shù)來讀取和寫入外部文件。

Consider the following scenario. You are making a traditional text-heavy adventure game. For production simplicity, you want to break up all the text in the game into the different rooms. In this case you would make one text file that contains all the text that will be used in one room. From there it is easy to make a reference to the correct Text Asset for the room you enter. Then with some customized parsing logic, you can manage a large amount of text very easily.

請考慮下面的情形。你正在做一個傳統(tǒng)的文字冒險游戲。為了制作簡單,你想把游戲中的文本分解到不同的房間。在這種情況下,你會制作出一個文本他包含了所有將會在一個房間里使用的文本。從那里你很容易為你輸入的房間引用正確的文本資源。然后使用一些自定義的分析邏輯,這樣你可以很輕松的管理大量的文本。

Binary data 二進制數(shù)據(jù)

A special feature of the text asset is that it can be used to store binary data. By giving a file the extension .bytes it can be loaded as a text asset and the data can be accessed through the bytes property.

文本資源的一個特色是,他可以用來存儲二進制數(shù)據(jù)。文件以.bytes作為擴展名,并且可以被作為一個文本資源進行加載,而且數(shù)據(jù)可以通過bytes屬性進行訪問。

For example put a jpeg file into the Resources folder and change the extension to .bytes, then use the following script code to read the data at runtime:

例如放一個jpeg的文件到Resources文件夾里,并且修改他的屬性為.bytes,然后使用如下的腳本代碼在運行時讀取數(shù)據(jù):

//Load texture from disk
TextAsset bindata= Resources.Load("Texture") as TextAsset;
Texture2D tex = new Texture2D(1,1);
tex.LoadImage(bindata.bytes); 
Hints 提示
  • Text Assets are serialized like all other assets in a build. There is no physical text file included when you publish your game.
    文本資源在編譯時想其他資產(chǎn)一樣被序列化。當(dāng)你發(fā)布你的游戲時沒有物理文本文件被包括其中。
  • Text Assets are not intended to be used for text file generation at runtime.
    文本資源并不是要用于在運行時生成的文本文件。

贊0 踩0

未知用戶

2005-2025 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2025 ZhuFeng Community All Rights Reserved

VIP

朱峰社區(qū)微信公眾號

回頂部

1.復(fù)制文本發(fā)給您的QQ好友或群、微信等;好友點擊鏈接以后,轉(zhuǎn)發(fā)就成功了。 2.如朋友點擊您的鏈接,您需要需刷新一下才行;同一個好友僅能點擊一次。
購買VIP,觀看所有收費教程!