RemoveFile

Definition

RemoveFile(string filePath)

Description

This function removes filePath file located in the “Assets/Data/” path.

Parameters

filePath
File path in “Assets/Data/” folder.

Example

function OnTriggerEnter(otherActorName)
   --Create a folder in Assets/Data/ path
   CreateFolder("Lev1")

   --Create and open file to write data
   OpenFileForWriting("Lev1/level1.bin")
   WriteBoolVariableToFile(true)
   CloseFile("Lev1/level1.bin")
end

function OnTriggerStay(otherActorName)

end

function OnTriggerExit(otherActorName)
    RemoveFile("Lev1/level1.bin")
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, using the OpenFileForWriting function, we open the level1.bin file located in the Assets/Data/Lev1/ 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 “level1.bin” file located in the Assets/Data/Lev1/ path.
adminRemoveFile