File.GreateText Unity 5.1.2 to 5.3.4 upgrade lols
Could some one please explain why this method is suddenly broken between the 2 builds?
Additionally some pointers on how to avoid this sort of upgrade nightmare would be nice :D
"Is there a new Way of doing this?"
I am simply creating a text document and storing one line of data into it. But as of now the text file isn't even being "created" :/. Never had this issue before either.
Please don't get hangup on the UMA part. This is in no way an UMA related error, unless I'm blind. It's creating a text file prob, Period
Some more Infos: Upgraded win 7 to win7 sp1. {Was still working fine in Unity 5.1.2f} Using encryption {Yes, this has never been a problem before, never. And it shouldn't, in the first place}.
The Error:
DirectoryNotFoundException: Could not find a part of the path "D:\Unity\Drudgery-Man\Resources\BaseCharacter\noob.txt". System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs:292) System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare) System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/StreamWriter.cs:124) System.IO.StreamWriter..ctor (System.String path, Boolean append) (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool) System.IO.File.CreateText (System.String path) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:159) UMACharacterCreator.Save (System.String characterName) (at Assets/Scripts/GameManagers/UMACharacterCreator.cs:285) UMACharacterCreator.SaveLoad (Boolean salo) (at Assets/Scripts/GameManagers/UMACharacterCreator.cs:271) UnityEngine.Events.InvokableCall`1[System.Boolean].Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:175) UnityEngine.Events.CachedInvokableCall`1[System.Boolean].Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:293) UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:621) UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:756) UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53) UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:35) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:44) UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:52) UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) TeamUtility.IO.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) (at Assets/InputManager/Addons/UIInputModules/StandaloneInputModule.cs:394) TeamUtility.IO.StandaloneInputModule:ProcessMouseEvent() (at Assets/InputManager/Addons/UIInputModules/StandaloneInputModule.cs:285) TeamUtility.IO.StandaloneInputModule:Process() (at Assets/InputManager/Addons/UIInputModules/StandaloneInputModule.cs:192) UnityEngine.EventSystems.EventSystem:Update()
The Code: "characterName" variable/parameter not important. Trimmed down a lot since getting this error.
public void SaveLoad(bool salo){
if(saveTarget.text == ""){
Debug.Log("Please Enter a Character Name, or Family referance"); //see enums.CS for details
return;
}
if (salo){
Load(saveTarget.text as string);
} else if(!salo){
Save(saveTarget.text as string);
}
}
/// Load and Save
public void Save(string characterName) {
//Generate UMA String
UMATextRecipe recipe = ScriptableObject.CreateInstance<UMATextRecipe>();
recipe.Save(umaAvatar.umaData.umaRecipe, umaAvatar.context);
SaveString = recipe.recipeString;
Destroy(recipe);
Debug.Log("Recipy is string");
//Save string to text File
string fileName = "Resources/BaseCharacter/noob.txt";
StreamWriter stream = File.CreateText(fileName);
stream.WriteLine(SaveString);
stream.Close();
}
Many Thanks in advance :D
Answer by Honour-Demon · Apr 29, 2016 at 09:14 PM
string fileName = "D:/Unity/Drudgery-Man/Assets/Resources/BaseCharacter/noob.txt";
To be Honest, I hate answering my own q's. The above snippet of code does the trick.
Even though it seems unity would normally auto complete or know where to find the resources folder on it's own, you would now have to use the entire path to make things happen.
string fileName = "Resources/BaseCharacter/noob.txt";
Old Code For convenience.
Any how, so if your having the same prob in newer versions of unity like this one, then hopefully I did help xD.
Another thought. I do know the technical details behind why this is happening. Could be .net related or what ever. So if any one wants to add on for the technical side. Please Do :)
Your answer
Follow this Question
Related Questions
ComponentChunkIterator is not liking me.. 0 Answers
Missing the class attribute 'ExtensionOfNativeClass' 4 Answers
Error : Failed to build apk -1 Answers
how to fix automatic camera rotation when using joysticks? 0 Answers
InvalidOperationException: Collection was modified; enumeration operation may not execute. 0 Answers