Skip to main content

PFile

class PFile

PFile's are used to get an file from the project files on the ItsMagic Object Interface or creating an new instance of PFile

⚠️ Deprecation warning ⚠️

Don't use PFile's constructor, use the ItsMagic interface to add an project file The files will change the directory when the APK is built.

PFile creates a problem when exporting the project in APK, because the file structure changes completely after exporting. Therefore, if you dynamically create a PFile during the script, your game will not work after exporting the game. In order for ITsMagic to convert the PFile to the APK files, it needs to be a PUBLIC variable in the script's global scope. However, due to the large number of users who were creating dynamic PFiles during the script execution, several projects exported with errors. To solve this, it was necessary to create new specific classes for each case (WorldFile, ObjectFile, MaterialFile, VertexFile, FragmentGLSLFile, VertexGLSLFile, SoundFile, [TextureFile]) which are immutable, without a constructor and unalterable. Only the ITsMagic interface (Inspector) can build these classes. This means that the only way to create a WorldFile, for example, is to create a public variable with null value in the script's global scope, so you select the file through itsmagic interface. This way itsmagic will have access to that class and will change the value in the game's export. Not all files in your project are uploaded to the APK, so you can't access them dynamically during the game, as it may simply not even exist in the APK, and when it does, it has a totally different name and directory structure.

⚠️ PFile isn't available anymore ⚠️

The PFile class has been removed from ITsMagic at the version [version].


public class PFile
extends java.io.File

— Constructors —

ConstructorDescription
PFile(String path)Create a new instance of PFile with the provided path, if the path contains slashes, will be treated as relative/absolute path

— Methods —

Method nameDescription
String getFilePath()Returns the file path
String getAbsolutePath()Returns the absolute file path, with slashes & etc
void setFilePath(String path)Set's the file path, if the path contains slashes, will be treated as a relative/absolute path