當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.TextAsset類代碼示例

本文整理匯總了C#中UnityEngine.TextAsset的典型用法代碼示例。如果您正苦於以下問題:C# TextAsset類的具體用法?C# TextAsset怎麽用?C# TextAsset使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextAsset類屬於UnityEngine命名空間,在下文中一共展示了TextAsset類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: getXML

	IEnumerator getXML()
	{	
		Flow.header.levelText.Text = "Level " + Flow.playerLevel.ToString();
		Flow.header.experienceText.Text = "Exp " + Flow.playerExperience.ToString();
		Flow.header.expBar.width = 7 * Flow.playerExperience/(Flow.playerLevel * Flow.playerLevel * 100);
		Flow.header.expBar.CalcSize();
		
		string caminho = "file:///"+Application.persistentDataPath+"/"+fileName;
		Debug.Log(caminho);
		
		WWW reader = new WWW (caminho);
		yield return reader;
		
		if (reader.error != null)
		{
			Debug.Log ("Erro lendo arquivo xml: "+reader.error);
			
			tilesetXML = Resources.Load("Tileset") as TextAsset;
			rawXML = tilesetXML.text;
			readFromXML();
		}
		else
		{
			Debug.Log("loaded DOCUMENTS xml");
			
			rawXML = reader.text;
			readFromXML();
		}
	}
開發者ID:uptopgames,項目名稱:Minesweeper,代碼行數:29,代碼來源:LogoPanel.cs

示例2: OnGUI

    public void OnGUI()
    {
        string message = "This wizard allows you to import a texture atlas generated" +
            "with the Texture Packer program. You must select both the Texture and the " +
            "Data File in order to proceed. You must select the 'Unity3D' format in the " +
            "'Data Format' dropdown when exporting these files from Texture Packer.";

        EditorGUILayout.HelpBox( message, MessageType.Info );

        if( GUILayout.Button( "Texture Packer Documentation", "minibutton", GUILayout.ExpandWidth( true ) ) )
        {
            Application.OpenURL( "https://www.codeandweb.com/texturepacker/documentation" );
            return;
        }

        dfEditorUtil.DrawSeparator();

        textureFile = EditorGUILayout.ObjectField( "Texture File", textureFile, typeof( Texture2D ), false ) as Texture2D;
        dataFile = EditorGUILayout.ObjectField( "Data File", dataFile, typeof( TextAsset ), false ) as TextAsset;

        if( textureFile != null && dataFile != null )
        {
            if( GUILayout.Button( "Import" ) )
            {
                doImport();
            }
        }
    }
開發者ID:CoryBerg,項目名稱:drexelNeonatal,代碼行數:28,代碼來源:dfTexturePackerImporter.cs

示例3: OnInspectorGUI

    public override void OnInspectorGUI()
    {
        _loader = target as PsaiSoundtrackLoader;
        _textAsset = EditorGUILayout.ObjectField("drop Soundtrack file here:", _textAsset, typeof(TextAsset), true) as TextAsset;

        if (_textAsset)
        {
            string path = AssetDatabase.GetAssetPath(_textAsset);

            string assetsResources = "Assets/Resources/";
            if (!path.StartsWith(assetsResources))
            {
                Debug.LogError("Failed! Your soundtrack file needs to be located within the 'Assets/Resources' folder along with your audio files. (path=" + path);
            }
            else
            {
                string subPath = path.Substring(assetsResources.Length);
                _loader.pathToSoundtrackFileWithinResourcesFolder = subPath;

                /* This is necessary to tell Unity to update the PsaiSoundtrackLoader */
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(_loader);
                }
            }
        }

        EditorGUILayout.LabelField("Path within Resources folder", _loader.pathToSoundtrackFileWithinResourcesFolder);
    }
開發者ID:dirty-casuals,項目名稱:Calamity,代碼行數:29,代碼來源:PsaiSoundtrackLoaderEditor.cs

示例4: SubtitleInitialize

    void SubtitleInitialize(string _path)
    {
        setting.IgnoreComments=true;
        setting.IgnoreProcessingInstructions=true;
        //setting.IgnoreWhitespace=true;
        textFile =(TextAsset)Resources.Load(_path);
        xmlDoc.LoadXml(textFile.text);
        XmlNode root =xmlDoc.DocumentElement;
        XmlNodeList x=root.ChildNodes;

        for(int i=0; i<x.Count;i++){
            SubtitleModel model= new SubtitleModel();
            model.Name=x[i].Attributes["name"].Value;
            string a=x[i].FirstChild.InnerText;
            model.PlayTime=float.Parse(a);
            model.Content=x[i].FirstChild.NextSibling.InnerText;

            model.AutoOff=	Boolean.Parse(x[i].Attributes["AutoOff"].Value);
            model.AutoPlay=	Boolean.Parse(x[i].Attributes["AutoPlay"].Value);
            model.Action=x[i].FirstChild.NextSibling.NextSibling.InnerText;
            if (x[i].FirstChild.NextSibling.NextSibling.Attributes["object"]!=null){
            model.ActionTarget=x[i].FirstChild.NextSibling.NextSibling.Attributes["object"].Value;
            }else {

                model.ActionTarget=null;
            }
            //model.AutoOff=x[i].Attributes["AutoOff"].Value;
            subtitleModel.Add(model);
            //y.Add (x[i]); //將XMLmodelslist 對象轉換為xmlnodes的list對象
        }
    }
開發者ID:tuanzi88,項目名稱:Unity,代碼行數:31,代碼來源:SubtitleCtrl.cs

示例5: Start

    void Start()
    {
        triviaFile = new FileInfo(Application.dataPath + "/trivia.txt");

        if (triviaFile != null && triviaFile.Exists) {
            reader = triviaFile.OpenText();
        } else {
            embedded = (TextAsset) Resources.Load("trivia_embedded", typeof (TextAsset));
            reader = new StringReader(embedded.text);
        }

        string lineOfText = "";
        int lineNumber = 0;

        while ( ( lineOfText = reader.ReadLine() ) != null ) {

            string question = lineOfText;
            int answerCount = Convert.ToInt32(reader.ReadLine());
            List<string> answers = new List<string>();
            for (int i = 0; i < answerCount; i++) {
                answers.Add(reader.ReadLine());
            }

            Trivia temp = new Trivia(question, answerCount, answers);

            triviaQuestions.Add(temp);
            lineNumber++;
        }

        SendMessage( "BeginGame" );
    }
開發者ID:LivingValkyrie,項目名稱:Lab04,代碼行數:31,代碼來源:TriviaLoader.cs

示例6: LoadSpawnPattern

    // パターンデータテキストアセットから、パターンデータを読み出す.
    void LoadSpawnPattern(TextAsset pattern_text, List<SpawnPattern> pList)
    {
        string pText = pattern_text.text;
        string[] lines = pText.Split('\n');

        List<string> pattern_data_str = new List<string>();	// BEGIN=>END間のパターンデータのテキスト
        foreach(var line in lines) {

            string str = line.Trim();	// 前後の空白を消す.

            if(str.StartsWith("#")) 	continue;	// コメント行なら読み飛ばし.

            switch(str.ToUpper()) {
                case "":
                    continue;	// 空行なら読み飛ばし.
                case "BEGIN":
                    // BEGINがきたらパターンデータテキストを一から作り直す.
                    pattern_data_str = new List<string>();
                    break;;	// TODO 1テキストで複數パターン読み込み出來るようにする.
                case "END":
                    // ENDがきたらパターンデータテキストを基にパターンデータを作成し、パターンリストに追加.
                    SpawnPattern pattern = new SpawnPattern();
                    pattern.LoadPattern(pattern_data_str.ToArray());
                    pList.Add(pattern);	// パターンリストに追加.
                    break;
                default:
                    // BEGIN=>END間なのでパターンデータテキストに追加.
                    pattern_data_str.Add(str);
                    break;
            }

        }
    }
開發者ID:gunzee2,項目名稱:RhythmWars,代碼行數:34,代碼來源:SpawnManager.cs

示例7: loadLevel

    protected List<Dictionary<string, int>> loadLevel(int level)
    {
        if(reader == null){
            text = (TextAsset)Resources.Load("LevelDesign/fases/fase" + level,typeof(TextAsset));
            reader = new StringReader(text.text);
        }

        while((line = reader.ReadLine()) != null){
            if(line.Contains(",")){
                string[] note = line.Split(new char[]{','});
                phaseNotes.Add(new Dictionary<string,int>(){
                    {"time",int.Parse(note[0])},
                    {"show",int.Parse(note[1])},
                    {"note",int.Parse(note[2])}
                });
                linecount++;
            }else if(line.Contains("tick"))
            {
                string[] tick = line.Split(new char[]{':'});
                musicTick = float.Parse(tick[tick.Length - 1]);

                linecount ++;
            }
        }
        linecount = 0;

        return getNotesDuration(excludeDoubleNotes(phaseNotes));
    }
開發者ID:renanclaudino,項目名稱:SoundWalker,代碼行數:28,代碼來源:LevelDesign.cs

示例8: ParseMessagesFromTextAsset

	// ---------------------
	// Helpers
	// ---------------------

	List<Message> ParseMessagesFromTextAsset (TextAsset asset)
	{
		List<Message> messages = new List<Message> { };

		string text = asset.text;
		string[] lines = text.Split ('\n');

		foreach (string line in lines) {
			string[] parts = line.Split (',');
			if (parts.Length < 2) {
				print ("Line contains error");
				continue;
			}
			short result;
			bool success = short.TryParse (parts [0], out result);
			if (success) {
				// remove target from array
				parts = parts.Where ((val, idx) => idx != 0).ToArray ();
			} else {
				print ("Failed parsing target");
			}

			Target target = (Target)result;
			string message = string.Join (",", parts);

			Message msg = new Message ();
			msg.target = target;
			msg.message = message;

			messages.Add (msg);
		}

		return messages;
	}
開發者ID:nickskull,項目名稱:HofmannTriptych,代碼行數:38,代碼來源:MessagesManager.cs

示例9: Load

    // 바이너리 로드
    public void Load(TextAsset kTa_)
    {
        //FileStream fs = new FileStream("Assets\\Resources\\StageDB.bytes", FileMode.Open);
        //BinaryReader br = new BinaryReader(fs);
        Stream kStream = new MemoryStream (kTa_.bytes);
        BinaryReader br = new BinaryReader(kStream);

        // *주의
        // 바이너리 세이브 순서와 로드 순서가 같아야된다. [5/13/2012 JK]
        // 바이너리 리드
        int iCount = br.ReadInt32();        // 갯수 읽기
        for (int i = 0; i < iCount; ++i)
        {
            StStateInfo kInfo = new StStateInfo();

            kInfo.m_nStageIndex = br.ReadInt32();          // 캐릭터 코드
            // 스테이지 별로 나오는 캐릭터
            kInfo.m_anCharCode = new int[(int)EStageDetail.Count];
            for (int k = 0; k < (int)EStageDetail.Count; ++k)
            {
                kInfo.m_anCharCode[k] = br.ReadInt32();
            }
            kInfo.m_fTermTime = br.ReadSingle();

            m_tmStage.Add(kInfo.m_nStageIndex, kInfo);
        }

        //fs.Close();
        br.Close();
        kStream.Close();
    }
開發者ID:ditto21c,項目名稱:ExampleSource,代碼行數:32,代碼來源:StageDB.cs

示例10: Read

 public TileType[,] Read(TextAsset file)
 {
     //option to call Read without size information.
     Vector2 size = GetMapSize(file);
     //convert Vector2 from GetMapSize into integers
     return Read(file, (int) size.x, (int) size.y);
 }
開發者ID:seanarooni,項目名稱:Unity-common-scripts,代碼行數:7,代碼來源:LoadMapFromTextFile.cs

示例11: GetMapSize

    public Vector2 GetMapSize(TextAsset file)
    {
        //returns the size of the map as a Vector 2, needs to be converted (shown below).
        StringReader reader = new StringReader(file.text);

        int xSize = 0;
        int ySize = 0;

        if (reader == null)
        {
            print ("read failed");
        }
        else
        {
            for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
            {
                if (xSize == 0)
                {
                    foreach (char c in line)
                    {
                        xSize++;
                    }
                }
                ySize++;
            }
        }
        return new Vector2(xSize, ySize);
    }
開發者ID:seanarooni,項目名稱:Unity-common-scripts,代碼行數:28,代碼來源:LoadMapFromTextFile.cs

示例12: OnEnable

 private void OnEnable()
 {
     if (templateFile == null)
     {
         templateFile = AssetDatabase.LoadMainAssetAtPath(TemplateFilePath) as TextAsset;
     }
 }
開發者ID:wuxin0602,項目名稱:Nothing,代碼行數:7,代碼來源:GameEventGenerator.cs

示例13: ColorDictionary

    //Constructor
    public ColorDictionary(TextAsset colorList)
    {
        colorDictionary = new Dictionary<string, Dictionary<string, Color>>();
        //Parse color rows
        string[] fileRows = colorList.text.Split('\n');

        for (int i = 0; i < fileRows.Length - 1; i++)
        {
            //Create temporary color type dictionary
            Dictionary<string, Color> tempDictionary = new Dictionary<string, Color>();

            //create variable to hold parsed color values
            string[] values = fileRows[i].Split(',');

            //Create temp color
            string temp_Color = values[0];

            int numberOfColors = (values.Length - 1) / 4;
            //For each _ColorType, add Color to tempDictionary
            for(int j = 0; j < numberOfColors; j++)
            {
                //Create temp_ColorType
                string temp_ColorType = values[1 + 4 * j];
                //Create tempColor
                Color tempColor = Color.HSVToRGB(float.Parse(values[2+4*j]), float.Parse(values[3+4*j]), float.Parse(values[4+4*j]));
                //Add tempColor to the tempDictionary
                tempDictionary.Add(temp_ColorType, tempColor);
            }
            //Add to colorDictionary
            colorDictionary.Add(temp_Color, tempDictionary);
        }
    }
開發者ID:ScopatGames,項目名稱:Spectrum,代碼行數:33,代碼來源:ColorDictionary.cs

示例14: Load

    public static BossData Load(TextAsset asset)
    {
        BossData bossData = null;
        var serializer = new XmlSerializer(typeof(BossData));

        using (var stream = new StringReader(asset.text))
        {
            bossData = serializer.Deserialize(stream) as BossData;
        }

        bossData.BossTypes = new Dictionary<int, BossType>();
        foreach (BossType type in bossData.BossTypeArray)
        {
            /*try
            {*/
            bossData.BossTypes.Add(type.Id, type);
            /*}
            catch (ArgumentException e)
            {
                Debug.Log("ArgumentException: " + e.Message);
            }*/
        }

        return bossData;
    }
開發者ID:DrSkipper,項目名稱:Watchlist,代碼行數:25,代碼來源:BossType.cs

示例15: Generate_Localized_Dictionary

    // Generates a dictionary for our localized languages
    public static Dictionary<string, Dictionary<string, string>> Generate_Localized_Dictionary(TextAsset text_asset)
    {
        Dictionary<string, Dictionary<string, string>> language_dictionaries = new Dictionary<string, Dictionary<string, string>>();

        // Read in the Localized UI so we change the labels of our UI to the correct language
        string[,] split_csv = CSVReader.SplitCsvGrid(text_asset.text);

        // Put these values into multiple dictionaries based on their language
        // Each language gets its own dictionary
        // Then the specific dictionary is searched
        for (int x = 1; x < split_csv.GetUpperBound(0); x++)
        {
            // Create a dictionary for this language
            Dictionary<string, string> new_dictionary = new Dictionary<string, string>();

            if (string.IsNullOrEmpty(split_csv[x, 0]))
                break;

            // Populate the entries
            for (int y = 1; y < split_csv.GetUpperBound(1); y++)
            {
                string key = split_csv[0, y];
                string value = split_csv[x, y];
                if (!string.IsNullOrEmpty(key) || !string.IsNullOrEmpty(value))
                {
                    new_dictionary.Add(key, value);
                }
            }

            language_dictionaries.Add(split_csv[x, 0], new_dictionary);
        }

        return language_dictionaries;
    }
開發者ID:DeeCeptor,項目名稱:VN,代碼行數:35,代碼來源:CSVReader.cs


注:本文中的UnityEngine.TextAsset類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。