• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.TextAsset类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.TextAsset的典型用法代码示例。如果您正苦于以下问题:C# TextAsset类的具体用法?C# TextAsset怎么用?C# TextAsset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TextAsset类属于UnityEngine命名空间,在下文中一共展示了TextAsset类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: loadMoleculesFromFile

    public LinkedList<MoleculesSet> loadMoleculesFromFile(TextAsset filePath)
    {
        bool b = true;
        MoleculesSet moleculeSet;
        string setId;
        LinkedList<MoleculesSet> moleculesSets = new LinkedList<MoleculesSet>();

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(filePath.text);
        XmlNodeList moleculesLists = xmlDoc.GetElementsByTagName("molecules");
        foreach (XmlNode moleculesNode in moleculesLists)
          {
        setId = moleculesNode.Attributes["id"].Value;
        if (setId != "" && setId != null)
          {
            ArrayList molecules = new ArrayList();
            b &= loadMolecules(moleculesNode, molecules);
            moleculeSet = new MoleculesSet();
            moleculeSet.id = setId;
            moleculeSet.molecules = molecules;
            moleculesSets.AddLast(moleculeSet);
          }
        else
          {
            Debug.Log("Error : missing attribute id in reactions node");
            b = false;
          }
          }
        return moleculesSets;
    }
开发者ID:CyberCRI,项目名称:DsynBio,代码行数:30,代码来源:FileLoader.cs


示例17: Load

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

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

        int yLength = level.Rows.Length;
        int xLength = yLength > 0 ? level.Rows[0].RowLength : 0;

        level.Grid = new int[xLength, yLength];

        for (int y = 0; y < yLength; ++y)
        {
            char[] row = level.Rows[y].RowData.ToCharArray();

            for (int x = 0; x < xLength; ++x)
            {
                level.Grid[x, y] = row[x] == WALL ? 1 : 0;
            }
        }

        return level;
    }
开发者ID:DrSkipper,项目名称:Watchlist,代码行数:27,代码来源:LevelData.cs


示例18: Load

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

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

        enemyData.EnemyTypes = new Dictionary<int, EnemyType>();
        foreach (EnemyType type in enemyData.EnemyTypeArray)
        {
            /*try
            {*/
            enemyData.EnemyTypes.Add(type.Id, type);
            /*}
            catch (ArgumentException e)
            {
                Debug.Log("ArgumentException: " + e.Message);
            }*/
        }

        return enemyData;
    }
开发者ID:DrSkipper,项目名称:Watchlist,代码行数:25,代码来源:EnemyType.cs


示例19: ParseLevel

 public XmlLevel ParseLevel(TextAsset levelAsset)
 {
     XmlReader sourceReader = XmlReader.Create(new StringReader(levelAsset.text));
     XDocument xDoc = new XDocument(XDocument.Load(sourceReader));
     XElement xLevel = xDoc.Element(XmlLevel.ElementLevel);
     return XmlLevel.FromElement(xLevel);
 }
开发者ID:mANDROID99,项目名称:IaS,代码行数:7,代码来源:XmlLevelParser.cs


示例20: Start

	// Use this for initialization
	void Start () {
		inote = 0;
		keysound = null;
		sounds = 0;


		if (GameObject4.gameFlags == "easy") {
			
			asset = (TextAsset)Resources.Load ("easy-toruko");
			string json = asset.text;
			notes = (IList)Json.Deserialize(json);
			bpm = 240;
			
		}
		if (GameObject4.gameFlags == "normal") {
			
			asset = (TextAsset)Resources.Load ("normal-kakumei");
			string json = asset.text;
			notes = (IList)Json.Deserialize(json);
			bpm = 145;
		}
		if (GameObject4.gameFlags == "hard") {
			
			asset = (TextAsset)Resources.Load ("hard-kusikosu");
			string json = asset.text;
			notes = (IList)Json.Deserialize(json);
			bpm = 150;
		}

	}
开发者ID:molmol178,项目名称:techno2015,代码行数:31,代码来源:Spowner.cs



注:本文中的UnityEngine.TextAsset类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.TextMesh类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.Terrain类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap