Definition
RemoveFolder(string folderPath)
Description
This function removes the Assets/Data/folderPath along with all the folders and files inside it.
Parameters
folderPath
Folder path in “Assets/Data/” folder.
Example
function OnTriggerEnter(otherActorName) --Create a folder in Assets/Data/ path CreateFolder("Lev1") --Create a folder in Assets/Data/Lev1 path CreateFolder("Lev1/subLev1") --Create and open file to write data OpenFileForWriting("Lev1/subLev1/level1.bin") WriteBoolVariableToFile(true) CloseFile("Lev1/subLev1/level1.bin") end function OnTriggerStay(otherActorName) end function OnTriggerExit(otherActorName) RemoveFolder("Lev1") end
Assume that the above script is attached to a trigger named “trigger1”.
Whenever the main character or a prefab instance that has dynamic physics enters “trigger1” trigger, we call CreateFolder function to create a folder named “lev1” in the “Assets/Data/” path. Then, we call CreateFolder function again to create a folder named “subLev1” in the “Assets/Data/Lev1” path. Then, using the OpenFileForWriting function, we open the level1.bin file located in the Assets/Data/Lev1/subLev1/ path for writing (If this file doesn’t exist, OpenFileForWriting function will create the file as well). After writing the Boolean value by the WriteBoolVariableToFile function, we close the file by the CloseFile function.
When the main character or a prefab instance that has dynamic physics exits “trigger1” trigger, we remove the “Lev1” folder located in the Assets/Data/ path. This will remove level1.bin file and subLev1 folder located in “Lev1” folder as well.
RemoveFolder