Text file assets.

Inheritance: UnityEngine.Object
Exemplo n.º 1
3
    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));
    }
    void LoadCharactorInfo()
    {
        UnityEngine.TextAsset s = Resources.Load("Charactors/CharactorInfo") as TextAsset;
        string tmp = s.text;

        m_CharactorAll = JsonMapper.ToObject <CharactorAll> (tmp);
    }
Exemplo n.º 3
0
 public void Init()
 {
     jsonDataSheet = new List<Dictionary<string, string>>();
     jsonFile = Resources.Load("TextAsset/SubWorldDefaultData/subworld_default") as TextAsset;
     subWorldJsonObj = new JSONObject(jsonFile.text);
     AccessData(subWorldJsonObj);
 }
Exemplo n.º 4
0
// fields

// properties
    static void TextAsset_text(JSVCall vc)
    {
        UnityEngine.TextAsset _this = (UnityEngine.TextAsset)vc.csObj;
        var result = _this.text;

        JSApi.setStringS((int)JSApi.SetType.Rval, result);
    }
    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);
    }
Exemplo n.º 6
0
	static void Load ()
	{
		mLoaded			= true;
		mPartial		= EditorPrefs.GetString("NGUI Partial");
		mFontName		= EditorPrefs.GetString("NGUI Font Name");
		mAtlasName		= EditorPrefs.GetString("NGUI Atlas Name");
		mFontData		= GetObject("NGUI Font Asset") as TextAsset;
		mFontTexture	= GetObject("NGUI Font Texture") as Texture2D;
		mFont			= GetObject("NGUI Font") as UIFont;
		mAtlas			= GetObject("NGUI Atlas") as UIAtlas;
		mAtlasPadding	= EditorPrefs.GetInt("NGUI Atlas Padding", 1);
		mAtlasTrimming	= EditorPrefs.GetBool("NGUI Atlas Trimming", true);
		mAtlasPMA		= EditorPrefs.GetBool("NGUI Atlas PMA", true);
		mUnityPacking	= EditorPrefs.GetBool("NGUI Unity Packing", true);
		mForceSquare	= EditorPrefs.GetBool("NGUI Force Square Atlas", true);
		mPivot			= (UIWidget.Pivot)EditorPrefs.GetInt("NGUI Pivot", (int)mPivot);
		mLayer			= EditorPrefs.GetInt("NGUI Layer", -1);
		mDynFont		= GetObject("NGUI DynFont") as Font;
		mDynFontSize	= EditorPrefs.GetInt("NGUI DynFontSize", 16);
		mDynFontStyle	= (FontStyle)EditorPrefs.GetInt("NGUI DynFontStyle", (int)FontStyle.Normal);

		if (mLayer < 0 || string.IsNullOrEmpty(LayerMask.LayerToName(mLayer))) mLayer = -1;

		if (mLayer == -1) mLayer = LayerMask.NameToLayer("UI");
		if (mLayer == -1) mLayer = LayerMask.NameToLayer("GUI");
		if (mLayer == -1) mLayer = 5;

		EditorPrefs.SetInt("UI Layer", mLayer);

		LoadColor();
	}
Exemplo n.º 7
0
	public static bool ImportInputManager(RUISInputManager inputManager, string filename, TextAsset xmlSchema)
	{
		XmlDocument xmlDoc = XMLUtil.LoadAndValidateXml(filename, xmlSchema);
		if (xmlDoc == null)
		{
			return false;
		}
		
		XmlNode psMoveNode = xmlDoc.GetElementsByTagName("PSMoveSettings").Item(0);
		inputManager.enablePSMove = bool.Parse(psMoveNode.SelectSingleNode("enabled").Attributes["value"].Value);
		inputManager.PSMoveIP = psMoveNode.SelectSingleNode("ip").Attributes["value"].Value;
		inputManager.PSMovePort = int.Parse(psMoveNode.SelectSingleNode("port").Attributes["value"].Value);
		inputManager.connectToPSMoveOnStartup = bool.Parse(psMoveNode.SelectSingleNode("autoConnect").Attributes["value"].Value);
		inputManager.enableMoveCalibrationDuringPlay = bool.Parse(psMoveNode.SelectSingleNode("enableInGameCalibration").Attributes["value"].Value);
		inputManager.amountOfPSMoveControllers = int.Parse(psMoveNode.SelectSingleNode("maxControllers").Attributes["value"].Value);
		
		XmlNode kinectNode = xmlDoc.GetElementsByTagName("KinectSettings").Item(0);
		inputManager.enableKinect = bool.Parse(kinectNode.SelectSingleNode("enabled").Attributes["value"].Value);
		inputManager.maxNumberOfKinectPlayers = int.Parse(kinectNode.SelectSingleNode("maxPlayers").Attributes["value"].Value);
		inputManager.kinectFloorDetection = bool.Parse(kinectNode.SelectSingleNode("floorDetection").Attributes["value"].Value);
		inputManager.jumpGestureEnabled = bool.Parse(kinectNode.SelectSingleNode("jumpGestureEnabled").Attributes["value"].Value);
		
		XmlNode kinect2Node = xmlDoc.GetElementsByTagName("Kinect2Settings").Item(0);
		inputManager.enableKinect2 = bool.Parse(kinect2Node.SelectSingleNode("enabled").Attributes["value"].Value);
		
		XmlNode razerNode = xmlDoc.GetElementsByTagName("RazerSettings").Item(0);
		inputManager.enableRazerHydra = bool.Parse(razerNode.SelectSingleNode("enabled").Attributes["value"].Value);
		
		XmlNode riftDriftNode = xmlDoc.GetElementsByTagName("OculusDriftSettings").Item(0);
//		string magnetometerMode = riftDriftNode.SelectSingleNode("magnetometerDriftCorrection").Attributes["value"].Value;
		//inputManager.riftMagnetometerMode = (RUISInputManager.RiftMagnetometer)System.Enum.Parse(typeof(RUISInputManager.RiftMagnetometer), magnetometerMode);
		inputManager.kinectDriftCorrectionPreferred = bool.Parse(riftDriftNode.SelectSingleNode("kinectDriftCorrectionIfAvailable").Attributes["value"].Value);
		
		return true;
	}
Exemplo n.º 8
0
    public void TestEncryptionScript()
    {
        LuaTable         scriptEnv         = _luaEnv.NewTable();
        EncryptionHelper _encryptionHelper = new EncryptionHelper();

        //TODO: use EncryptionHelper to load encrypted lua script
        ///use loader to decrypt script

        //Decrypt nonce = 102 //2019 - 09 - 30 update
        #region YourScript
        //TODO: loader here
        UnityEngine.TextAsset file = (UnityEngine.TextAsset)UnityEngine.Resources.Load("Encrypted.lua");
        byte[] decryptedString     = _encryptionHelper.Decrypt(Convert.FromBase64String(file.text), 102);
        string outputString        = Encoding.UTF8.GetString(decryptedString);


        _luaEnv.DoString(outputString);


        #endregion

        GetList unknowFunc = _luaEnv.Global.GetInPath <GetList>("_unknownFunc.unknownFunc");
        if (6 - unknowFunc().Count != 0)
        {
            throw new Exception("Length not valid");
        }

        testList = new List <int>(unknowFunc());

        Debug.Log("Case 3 : pass ");
    }
Exemplo n.º 9
0
    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" );
    }
Exemplo n.º 10
0
	// 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;
		}

	}
Exemplo n.º 11
0
        internal static int LoadFromResource(RealStatePtr L)
        {
            try
            {
                string filename = LuaAPI.lua_tostring(L, 1).Replace('.', '/') + ".lua";

                // Load with Unity3D resources
                UnityEngine.TextAsset file = (UnityEngine.TextAsset)UnityEngine.Resources.Load(filename);
                if (file == null)
                {
                    LuaAPI.lua_pushstring(L, string.Format(
                                              "\n\tno such resource '{0}'", filename));
                }
                else
                {
                    if (LuaAPI.xluaL_loadbuffer(L, file.bytes, file.bytes.Length, "@" + filename) != 0)
                    {
                        return(LuaAPI.luaL_error(L, String.Format("error loading module {0} from resource, {1}",
                                                                  LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1))));
                    }
                }

                return(1);
            }
            catch (System.Exception e)
            {
                return(LuaAPI.luaL_error(L, "c# exception in LoadFromResource:" + e));
            }
        }
Exemplo n.º 12
0
    public void BuildLevel(TextAsset levelData, GFGrid levelGrid)
    {
        //abort if there are no prefabs to instantiate
        if(!red || !green || !blue)
            return;

        //loop though the list of old blocks and destroy all of them, we don't want the new level on top of the old one
        foreach(GameObject go in blocks){
            if(go)
                Destroy(go);
        }
        //destroying the blocks doesn't remove the reference to them in the list, so clear the list
        blocks.Clear();

        //setup the reader, a variable for storing the read line and keep track of the number of the row we just read
        reader = new StringReader(levelData.text);
        string line;
        int row = 0;

        //read the text file line by line as long as there are lines
        while((line = reader.ReadLine()) != null){
            //read each line character by character
            for(int i = 0; i < line.Length; i++){
                //first set the target position based on where in the text file we are, then place a block there
                Vector3 targetPosition = levelGrid.GridToWorld(new Vector3(i + shift, -row - shift, 0)); //offset by 0.5
                CreateBlock(line[i], targetPosition);
            }
            //we read a row, now it's time to read the next one; increment the counter
            row++;
        }
    }
Exemplo n.º 13
0
    void OnGUI()
    {
        GUILayout.Label("Export Options");
        GlTF_Writer.binary = GUILayout.Toggle(GlTF_Writer.binary, "Binary GlTF");
        //buildZip = GUILayout.Toggle(buildZip, "Export Zip");

        // Force animation baking for now
        GlTF_Writer.bakeAnimation = GUILayout.Toggle(true, "Bake animations (forced for now)");
        exportAnimation           = GUILayout.Toggle(exportAnimation, "Export animations");
        convertImages             = GUILayout.Toggle(convertImages, "Convert images");
        presetAsset = EditorGUILayout.ObjectField("Preset file", presetAsset, typeof(UnityEngine.TextAsset), false) as UnityEngine.TextAsset;
        if (!exporterGo)
        {
            exporterGo = new GameObject("exporter");
        }
        if (!exporter)
        {
            exporter = exporterGo.AddComponent <SceneToGlTFWiz>();
        }
        GUI.enabled = (Selection.GetTransforms(SelectionMode.Deep).Length > 0);
        if (GUILayout.Button("Export to glTF"))
        {
            ExportFile();
        }
        GUI.enabled = true;
    }
Exemplo n.º 14
0
        static public T LoadJsonObj <T>(string filePath) where T : class
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return(null);
            }

            UnityEngine.TextAsset textAsset = Services.Get <ResourcesManager>().GetAsset <TextAsset>(filePath);
            if (textAsset == null)
            {
                return(null);
            }

            if (textAsset == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(textAsset.text))
            {
                return(null);
            }

            return(Json.FromJson <T>(textAsset.text));
        }
Exemplo n.º 15
0
        public List <DramaData> getDramaData(string fileName)
        {
            if (dramas.ContainsKey(fileName))
            {
                return(dramas[fileName]);
            }

            List <DramaData> result = new List <DramaData>();

            UnityEngine.TextAsset s = Resources.Load(fileName) as TextAsset;
            string[] lineArray      = s.text.Split(stringSeparators, StringSplitOptions.None);

            int i = 0;

            for (; i < lineArray.Length; i++)
            {
                if (Regex.IsMatch(lineArray[i], "^//"))
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            string[] title = lineArray[i].Split(","[0]);
            i++;

            string[]     unit;
            DramaData    data;
            Type         t = typeof(DramaData);
            PropertyInfo pi;

            for (; i < lineArray.Length; i++)
            {
                if (Regex.IsMatch(lineArray[i].ToLower(), "^end"))
                {
                    break;
                }
                if (Regex.IsMatch(lineArray[i], "^//"))
                {
                    continue;
                }

                unit = lineArray[i].Split(","[0]);
                data = new DramaData();
                for (int j = 0; j < title.Length; j++)
                {
                    pi = t.GetProperty(title[j]);
                    if (pi == null)
                    {
                        continue;
                    }
                    pi.SetValue(data, Convert.ChangeType(unit[j], pi.PropertyType), null);
                }
                result.Add(data);
            }
            return(result);
        }
Exemplo n.º 16
0
    public void ReadJsonData()
    {
        UnityEngine.TextAsset t = Resources.Load("Json/comInf") as TextAsset;
        string   tmp            = t.text;
        JsonData js             = JsonMapper.ToObject(tmp);

        for (int i = 0; i < js.Count; i++)
        {
            //NPC tmpInf = new NPC();
            NPC tmpInf = ScriptableObject.CreateInstance <NPC>();
            tmpInf.firstName = (string)js[i]["firstName"];
            tmpInf.lastName  = (string)js[i]["lastName"];
            tmpInf.job       = js[i]["job"].ToString();
            tmpInf.reason    = (string)js[i]["reason"];
            tmpInf.iniMood   = (int)js[i]["iniMood"];
            tmpInf.nature    = (int)js[i]["nature"];
            tmpInf.dialog1   = (string)js[i]["dialog1"];
            tmpInf.dialog2   = (string)js[i]["dialog2"];
            tmpInf.dialog3   = (string)js[i]["dialog3"];
            tmpInf.dialog4   = (string)js[i]["dialog4"];
            tmpInf.answer1_1 = (string)js[i]["answer1_1"];
            tmpInf.answer1_2 = (string)js[i]["answer1_2"];
            infList.npcList.Add(tmpInf);
        }
    }
Exemplo n.º 17
0
    /// <summary>
    /// Obtener el directorio principal del recurso
    /// </summary>
    /// <param name="assetName">nombre de asset</param>
    /// <param name="r">string vuele</param>
    /// <returns></returns>
    public bool GetParentPathName(string assetName, ref string r)
    {
        if (mAssetPathDic.Count == 0)
        {
            UnityEngine.TextAsset tex = Resources.Load <TextAsset>("res");
            StringReader          sr  = new StringReader(tex.text);
            string fileName           = sr.ReadLine();
            while (fileName != null)
            {
                //Debug.Log("fileName =" + fileName);
                string[] ss = fileName.Split('=');
                mAssetPathDic.Add(ss[0], ss[1]);
                fileName = sr.ReadLine();
            }
        }

        if (mAssetPathDic.ContainsKey(assetName))
        {
            r = mAssetPathDic[assetName];
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 18
0
    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对象
        }
    }
Exemplo n.º 19
0
 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);
 }
Exemplo n.º 20
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.TextAsset o;
     o = new UnityEngine.TextAsset();
     pushObject(l, o);
     return(1);
 }
Exemplo n.º 21
0
    public void splitTheStrings(TextAsset theJourney)
    {
        string[] splitStrings = theJourney.ToString().Split(new string[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries);

        //INITIALIZE ALL THE LISTS
        int temp = splitStrings.Length;
        Debug.Log(temp);
        notes = new string[temp];
        index = new int[temp];
        killQuests = new string[temp];
        killOptionals = new string[temp];
        fetchQuests = new string[temp];
        lootQuests = new string[temp];
        payQuests = new string[temp];
        readQiests = new string[temp];

        for(int i=1; i< splitStrings.Length; i++) // Skip the title row
        {
            string[] columns = splitStrings[i].Split(new string[]{","}, StringSplitOptions.None);

            //EACH COLUMN GETS PULLED INTO A DIFFERENT LIST
            notes[i] = columns[0];
            index[i] = int.Parse(columns[1]);
            killQuests[i] = columns[2];
            killOptionals[i] = columns[3];
            fetchQuests[i] = columns[4];
            lootQuests[i] = columns[5];
            payQuests[i] = columns[6];
            readQiests[i] = columns[7];
        }
    }
	void Awake () {
    if (textAsset == null)
      return;

    string text = textAsset.text;
    text = text.Replace("\\n", System.Environment.NewLine);

    textAsset = null; // Required otherwise the clone will instantiate other clones
    GameObject clone = Instantiate(gameObject) as GameObject;
    TextMesh clone_text_mesh = clone.GetComponent<TextMesh>();

    string[] parts = text.Split(' ');
    text = "";
    string line = "";
    for (int i = 0; i < parts.Length; ++i)
    {
      clone_text_mesh.text = line + parts[i];
      if (clone_text_mesh.renderer.bounds.extents.x > maxWidth)
      {
        text += line.TrimEnd() + System.Environment.NewLine;
        line = "";
      }
      line += parts[i] + " ";
    }
    text += line.TrimEnd();

    text_mesh_ = GetComponent<TextMesh>();
    text_mesh_.text = text;

    Destroy(clone);
	}
Exemplo n.º 23
0
    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;
    }
Exemplo n.º 24
0
    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;
    }
Exemplo n.º 25
0
    private void ReloadFamilyData()
    {
        UnityEngine.TextAsset s = Resources.Load("family") as TextAsset;
        string tmp = s.text;

        m_FamilyList = JsonMapper.ToObject <FamilyList>(tmp);
    }
    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();
            }
        }
    }
Exemplo n.º 27
0
 public void Reload(TextAsset tileXml)
 {
     this._Clear();
     this._InitProperties();
     this._Reload(tileXml);
     this._ParseData();
 }
Exemplo n.º 28
0
	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();
		}
	}
Exemplo n.º 29
0
    public List<WeaponStats> ReadWeaponStatsFromFile(TextAsset weaponAssets)
    {
        List<WeaponStats> outputList = new List<WeaponStats>();
        if (weaponAssets != null)
        {
            Debug.Log(weaponAssets.text);
            using (StreamReader sr = new StreamReader(new MemoryStream(weaponAssets.bytes)))
            {
                while (!sr.EndOfStream)
                {
                    string t = sr.ReadLine();
                    Debug.Log("Line contents: " + t);
                    if (!t.Contains("#"))
                    {
                        WeaponStats tws = new WeaponStats();
                        Debug.Log(t);
                        string[] tt = t.Split(',');
                        tws.setName(tt[0]);
                        tws.setClipSize(int.Parse(tt[1]));
                        tws.setMaxAmmo(int.Parse(tt[2]));
                        tws.setSpreadFactor(float.Parse(tt[3]));

                        Debug.Log("Added " + tws.getName() + " to weapon list");

                        outputList.Add(tws);
                    }
                }
            }
        }
        return outputList;
    }
Exemplo n.º 30
0
    static bool LoadTextAsset(TextAsset textAsset, Dictionary<string, string> dic)
    {
        if (textAsset == null || dic == null)
            return false;

        char[] separator1 = new char[] { '\n' };
        char[] separator2 = new char[] { '=' };
        string[] sArr1 = textAsset.text.Split(separator1);

        dic.Clear();

        for (int i=0; i<sArr1.Length; i++) {

            string line = sArr1[i];

            string[] sArr2 = line.Split(separator2);
            if (sArr2.Length < 2)
                continue;

            string akey = sArr2[0].Trim();
            string avalue = sArr2[1].Trim();

            if (!dic.ContainsKey(akey))
                dic.Add(akey, avalue);
            else
                Debug.LogError(string.Format("{0}存在相同的key={1}", textAsset.name, akey) );

        }

        return true;
    }
Exemplo n.º 31
0
    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;
    }
Exemplo n.º 32
0
    //载入地图编辑器数据
    private void LoadData()
    {
        UnityEngine.TextAsset s = null;
#if UNITY_EDITOR
        s             = UnityEditor.AssetDatabase.LoadAssetAtPath <TextAsset>("Assets/PublishRes/DesignTools/MapEditorData" + ".json");
        allEditorData = JsonMapper.ToObject <MapEditorData>(s.text);
#endif
    }
Exemplo n.º 33
0
        public static string ReadTextFile(string assetName)
        {
            TextAsset textasset = UResources.Load(assetName, typeof(TextAsset)) as TextAsset;

            if (textasset == null)
            {
                throw new ContentLoadException("Failed to load " + assetName + " as " + typeof(TextAsset));
            }
            return(textasset.text);
        }
Exemplo n.º 34
0
        public static Stream ReadBytesFileToStream(string fileName)
        {
            fileName = fileName.ToLower().Replace("\\", "/");
            TextAsset binData = UResources.Load(fileName, typeof(TextAsset)) as TextAsset;

            if (binData == null)
            {
                throw new ContentLoadException("Failed to load " + fileName + " as " + typeof(TextAsset));
            }
            return(new MemoryStream(binData.bytes));
        }
 static public int get_bytes(IntPtr l)
 {
     try {
         UnityEngine.TextAsset self = (UnityEngine.TextAsset)checkSelf(l);
         pushValue(l, self.bytes);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 36
0
    void Start()
    {
        string filepath = "rofbuff_bytes";

        UnityEngine.TextAsset assetObj = (UnityEngine.TextAsset)_AssetManager.GetAsset <UnityEngine.Object>(AppConst.mDaoBiao_Path + filepath);
        if (assetObj != null)
        {
            RofBuffTable = new RofTable <RofBuffRow>(assetObj.bytes);
        }
        //StartCoroutine(StartLoadDaoBiao(filepath));
    }
Exemplo n.º 37
0
        public JsonData getData(string fileName)
        {
//            if (!jsons.ContainsKey(fileName))
//            {
//                UnityEngine.TextAsset s = Resources.Load(fileName) as TextAsset;
//                jsons.Add(fileName, JsonMapper.ToObject(s.text));
//            }
//            return jsons[fileName];
            UnityEngine.TextAsset s = Resources.Load(fileName) as TextAsset;
            return(JsonMapper.ToObject(s.text));
        }
Exemplo n.º 38
0
 static public int get_text(IntPtr l)
 {
     try {
         UnityEngine.TextAsset self = (UnityEngine.TextAsset)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.text);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.TextAsset o;
         o = new UnityEngine.TextAsset();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 40
0
    IEnumerator StartLoadDaoBiao(string filepath)
    {
        AssetBundle mDaoBiaoBundle = AssetBundle.LoadFromFile(AppConst.LoadRes_Root_Path + AppConst.mDaoBiao_Path + filepath);
        string      obj_name_suff  = filepath.Remove(0, filepath.LastIndexOf('_') + 1);
        string      obj_name       = filepath.Remove(filepath.LastIndexOf('_'), filepath.Length - filepath.LastIndexOf('_')) + "." + obj_name_suff;

        Debug.Log("===>" + obj_name);
        UnityEngine.TextAsset assetObj = (UnityEngine.TextAsset)mDaoBiaoBundle.LoadAsset(obj_name);
        RofBuffTable = new RofTable <RofBuffRow>(assetObj.bytes);
        Debug.Log("===>" + RofBuffTable.GetDataByID(10001).Num);
        yield return(null);
    }
Exemplo n.º 41
0
 static public int get_bytes(IntPtr l)
 {
     try {
         UnityEngine.TextAsset self = (UnityEngine.TextAsset)checkSelf(l);
         pushValue(l, self.bytes);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 42
0
 public static string LoadTextAsset(string path)
 {
     try {
         UnityEngine.TextAsset asset = Resources.Load(path) as UnityEngine.TextAsset;
         string text = asset.text;
         Resources.UnloadAsset(asset);
         return(text);
     } catch (Exception e) {
         LOG.Debug("**** {0} ", e.ToString());
         return("");
     }
 }
Exemplo n.º 43
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.TextAsset o;
         o = new UnityEngine.TextAsset();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 44
0
    static void TextAsset_bytes(JSVCall vc)
    {
        UnityEngine.TextAsset _this = (UnityEngine.TextAsset)vc.csObj;
        var result = _this.bytes;
        var arrRet = result;

        for (int i = 0; arrRet != null && i < arrRet.Length; i++)
        {
            JSApi.setByte((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
            JSApi.moveSaveID2Arr(i);
        }
        JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
    }
Exemplo n.º 45
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.TextAsset o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.TextAsset();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Exemplo n.º 46
0
    /// <summary>
    /// 加载自定义的Lua文件
    /// </summary>
    /// <param name="luaFileName"></param>
    /// <returns></returns>
    public byte[] LoadCustomLuaFile(string filename)
    {
        // 从缓存中加载
        byte[] result = LoadFormAssetBundle(filename);
        if (result != null)
        {
            return(result);
        }

        string loadFileName = string.Empty;

        if (filename.EndsWith(".lua"))
        {
            loadFileName = filename;
        }
        else
        {
            loadFileName = filename + ".lua";
        }

#if UNITY_EDITOR
        // 从Lua原始目录加载
        string fileFullName = (LuaConst.LuaDir + "/" + loadFileName).Replace("//", "/");
        if (File.Exists(fileFullName))
        {
            return(File.ReadAllBytes(fileFullName));
        }
        else
        {
            Debug.LogErrorFormat("Don't exsit lua file:[{0}]", fileFullName);
            return(null);
        }
#else
        // 从Resource 目录加载
        string fileFullName = (LuaConst.LuaDirInResources + "/" + loadFileName).Replace("//", "/").TrimStart('/');
        // Load with Unity3D resources
        UnityEngine.TextAsset file = (UnityEngine.TextAsset)UnityEngine.Resources.Load(fileFullName);
        if (file != null)
        {
            return(file.bytes);
        }
        else
        {
            Debug.LogErrorFormat("Custom lua resource path can't find lua file[{0}]", filename);
            return(null);
        }
#endif
    }
Exemplo n.º 47
0
    private void OnGUI()
    {
        GUILayout.Label("Export Options");
        GlTF_Writer.binary = GUILayout.Toggle(GlTF_Writer.binary, "Binary GlTF");
        if (GlTF_Writer.binary)
        {
            GlTF_Writer.b3dm = GUILayout.Toggle(GlTF_Writer.b3dm, "B3dm");
        }
        else
        {
            GlTF_Writer.b3dm = false;
        }

        copyShaders = GUILayout.Toggle(copyShaders, "Copy shaders");

        presetAsset = EditorGUILayout.ObjectField("Preset file", presetAsset, typeof(UnityEngine.TextAsset), false) as UnityEngine.TextAsset;
        rtcScript   = EditorGUILayout.ObjectField("Cesium RTC Callback", rtcScript, typeof(MonoScript), false) as MonoScript;
        rotScript   = EditorGUILayout.ObjectField("Rotation Callback", rotScript, typeof(MonoScript), false) as MonoScript;

        if (rtcScript != null)
        {
            var name = typeof(RTCCallback).FullName;
            var ci   = rtcScript.GetClass().GetInterface(name);
            if (ci == null)
            {
                rtcScript = null;
            }
        }

        if (rotScript != null)
        {
            var name = typeof(RotationCallback).FullName;
            var ci   = rotScript.GetClass().GetInterface(name);
            if (ci == null)
            {
                rotScript = null;
            }
        }

        if (GUILayout.Button("Export"))
        {
            OnWizardCreate();
        }
    }
Exemplo n.º 48
0
    public string GetFileFullName(string assetName)
    {
        if (mAssetPathDic.Count == 0)
        {
            UnityEngine.TextAsset tex = Resources.Load <TextAsset>("res");
            StringReader          sr  = new StringReader(tex.text);
            string fileName           = sr.ReadLine();
            while (fileName != null)
            {
                //Debug.Log("fileName =" + fileName);
                string [] ss = fileName.Split('=');
                mAssetPathDic.Add(ss[0], ss[1]);
                fileName = sr.ReadLine();
            }
        }
        string parent = mAssetPathDic.ContainsKey(assetName) ? mAssetPathDic[assetName] : "";

        return(parent == "" ? assetName : parent + "/" + assetName);
    }
Exemplo n.º 49
0
    void test()
    {
        m_Localization = Singlton.getInstance("NvLocalizationManager") as NvLocalizationManager;
        if (m_Localization == null)
        {
            Debug.LogError("Can Not Find Localization File!!");
        }
        Debug.LogError("ssss" + m_Localization.GetValue("seaside_song_2_name"));

        //

        UnityEngine.TextAsset s = (UnityEngine.TextAsset)Resources.Load("TXT/KKKKK/TestJson", typeof(UnityEngine.TextAsset));
        m_ScenariogListLocal = JsonMapper.ToObject <List <KKKKK> >(s.text);

        Debug.Log("************" + m_ScenariogListLocal.Count);
        for (int i = 0; i < m_ScenariogListLocal.Count; i++)
        {
            Debug.Log(i + "=>" + m_ScenariogListLocal[i].strS1 + "++" + m_ScenariogListLocal[i].nN + "++" + m_ScenariogListLocal[i].strS2);
        }
    }
 static int QPYX__CreateUnityEngine_TextAsset_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 0)
         {
             UnityEngine.TextAsset QPYX_obj_YXQP = new UnityEngine.TextAsset();
             ToLua.Push(L_YXQP, QPYX_obj_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to ctor method: UnityEngine.TextAsset.New"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Exemplo n.º 51
-1
    // パターンデータテキストアセットから、パターンデータを読み出す.
    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;
            }

        }
    }
Exemplo n.º 52
-1
    // 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;
    }
Exemplo n.º 53
-2
    //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);
        }
    }
Exemplo n.º 54
-2
 private void OnEnable()
 {
     if (templateFile == null)
     {
         templateFile = AssetDatabase.LoadMainAssetAtPath(TemplateFilePath) as TextAsset;
     }
 }
    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);
    }
Exemplo n.º 56
-2
    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;
    }
Exemplo n.º 57
-2
	// ---------------------
	// 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;
	}
    public TileType[,] Read(TextAsset file, int xSize, int ySize)
    {
        StringReader reader = new StringReader(file.text);

        TileType[,] ttmap = new TileType[xSize, ySize];

        if (reader == null)
        {
            print ("read failed");
            return null;
        }
        else
        {
            int x = 0;
            int y = ySize - 1;
            for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
            {
                //PrintMapLine(line, row);
                x = 0;
                foreach(char c in line)
                {
                    //print ("" + x + " " + y);
                    ttmap[x,y] = ConvertToTileTypeFromChar(c, x, y);
                    x++;
                }

                y--;
            }
            return ttmap;
        }
    }
 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);
 }
Exemplo n.º 60
-5
    // 바이너리 로드
    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();
    }