General Documentation

if you using “Resource”  to store your config files, all config files and variables already avaliable on application start. To get variable value you should provide config file name and variable name. Or just variable name (will use the default settings).

Example1 getting int variable from GamePlay config:

float car_speed = Properties.getFloat(PropertyFile.GAME_PLAY, "car_speed");

the same for  getString, getInt, getBool functions.

 

Example2 getting string variable from default config:

float greeting_text = Properties.getString("greeting_text");

 

Note: if you using external loaction for property files you should load them before using variables, see Loading external config for more info.

 

HOW TO CREATE PROPERY FILE

You need just create simple text file and fill it with you variables. here is example of file


//--------------------------------------

// BASE SETTINGS

//--------------------------------------


who : Bunny  //main character name

what : carrots   //food for main character

how_many: 2 // how much food does he have

bool_test : true // just testing boolean config


/*

multi line coment

*/



//--------------------------------------

// WELKOM SET UP

//--------------------------------------



reload_button_pos : 120.5 //reload button position

text_pos: 250 // tex position

 

You can use single and multiline comets. Variables name should be without spaces.

Next step, you need to give name to file and put it to “Asset/Resources/Properties” folder, or you can load file via www (see Loading external config) or change default properties folder (see Util Settings).


 

LOADING EXTERNAL CONFIG

For loading externnal config use PropertyLoader class

External Config loading example:

//creating new loader

PropertyLoader loader = PropertyLoader.Create(); 

//adding load event handler

loader.onLoadComplete += onLoad;

//starting load

loader.load(ExampleConfig.EXTARNAL_CONFIG_PATH, PropertyFile.GAME_PLAY);

//ExampleConfig.EXTARNAL_CONFIG_PATH - path to folder with config files

//PropertyFile.GAME_PLAY - config file name


 

Function onLoad will be called after config loaded and ready to use.

You can load config file by your self, and just give it to properties class to parce it.


//fileName name of File

//data file text data

public static void setFile(string fileName, string data)

 

SETTINGS

 

General settings:

You can modifay this setting at runtime or before game start:

PropertySettings.GENERAL_PATH = "Properties/"; // default location of config files, full path (Asset/Resources/Properties)

PropertySettings.DEFAULT_CONFIG = PropertyFile.DEFAULT; // default name of property file.

 

Adding new config file names:

Just modifay PropertyFile.cs file, add or remove new file names.

 

 

  • Manual
    • General Documentation