1631 lines
162 KiB
HTML
1631 lines
162 KiB
HTML
|
|
|
||
|
|
<!doctype html>
|
||
|
|
<html lang="en">
|
||
|
|
|
||
|
|
<head>
|
||
|
|
<meta charset="utf-8">
|
||
|
|
<title></title>
|
||
|
|
</head>
|
||
|
|
|
||
|
|
<body>
|
||
|
|
|
||
|
|
<div id="product">
|
||
|
|
<div id="product_author">TIGERFORGE</div>
|
||
|
|
<div id="product_name">Easy File Save</div>
|
||
|
|
<div id="product_version">1.1</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="manual_title"></div>
|
||
|
|
|
||
|
|
<div id="manual_content">
|
||
|
|
[[[Introduction]]]
|
||
|
|
Easy File Save is a lightweight, easy and practical way to save and load your data in a file. It has
|
||
|
|
been designed to be very easy and fast to use, but complete and powerful as well.
|
||
|
|
|
||
|
|
{{{HOW IT WORKS}}}
|
||
|
|
Basically, everything starts with the declaration of an instance of EasyFileSave class. This instance
|
||
|
|
represents a file that can be written and read. The instance contains all the methods and functionalities
|
||
|
|
for working with data and that file. With the instantiation, you can specify a file name. The file name is
|
||
|
|
optional: if your project just needs one file only, you can omit the file name and Easy File Save will use a
|
||
|
|
default predefined name. Instead, if you plan to use more files, you must specify a file name.
|
||
|
|
|
||
|
|
{{{SYSTEM INTERNAL STORAGE}}}
|
||
|
|
When you create an EasyFileSave instance, the <b>internal storage</b> is initialized. Practically, this storage
|
||
|
|
represents the file content. This means that if you want to write a file, you have to fill that storage with
|
||
|
|
data. Then, through the Save() method, the storage is transferred into a file. Similarly, when you read a
|
||
|
|
file, the whole file content is transferred into the storage, in a well-organized structure easily
|
||
|
|
accessible.
|
||
|
|
|
||
|
|
{{{WRITING}}}
|
||
|
|
The writing process consists of transferring the internal storage into a file. This means that firstly you
|
||
|
|
have to fill the storage with the data you want to save. Filling the storage is very easy: you have just to
|
||
|
|
use the Add() method specifying the data to save and a unique id to find it later after you loaded the
|
||
|
|
file. After that, simply calling the Save() method, the file is filled with the storage content.
|
||
|
|
|
||
|
|
<code title="File writing example">
|
||
|
|
void Save()
|
||
|
|
{
|
||
|
|
-// Instance declaration.
|
||
|
|
-EasyFileSave myFile = new EasyFileSave();
|
||
|
|
|
||
|
|
-// Internal storage filling with some data.
|
||
|
|
-myFile.Add("name", "Conan");
|
||
|
|
-myFile.Add("age", 30);
|
||
|
|
-myFile.Add("has_sword", true);
|
||
|
|
|
||
|
|
-// Saving.
|
||
|
|
-myFile.Save();
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{{{READING}}}
|
||
|
|
The reading process consists of calling the Load() method, which will fill the storage with the file
|
||
|
|
content. The storage is a simple dictionary where every single value is located by the unique id used during
|
||
|
|
the writing process. Because the values are saved as object data-type, you must convert (cast) them in a
|
||
|
|
proper way to have them in their original data-type. The instance comes with various Get methods
|
||
|
|
that read and convert the values.
|
||
|
|
|
||
|
|
<code title="File reading example">
|
||
|
|
void Load()
|
||
|
|
{
|
||
|
|
-EasyFileSave myFile = new EasyFileSave();
|
||
|
|
|
||
|
|
-// Load() method returns true if everything is ok.
|
||
|
|
-if (myFile.Load())
|
||
|
|
-{
|
||
|
|
|
||
|
|
--// Read the "name" value and return it as String.
|
||
|
|
--string character = myFile.GetString("name");
|
||
|
|
|
||
|
|
--// Read the "age" value and return it as Integer.
|
||
|
|
--int age = myFile.GetInt("age");
|
||
|
|
|
||
|
|
--// Read the "has_sword" value and return it as Boolean.
|
||
|
|
--bool has_sword = myFile.GetBool("has_sword");
|
||
|
|
|
||
|
|
--// Dispose() method clears the storage in order to free the memory occupied by it.
|
||
|
|
--myFile.Dispose();
|
||
|
|
|
||
|
|
-}
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{-{{NOTE}}}
|
||
|
|
Data is always saved in binary format as to have a better writing/reading speed, smaller file size and a
|
||
|
|
higher level of data protection.
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[CREATING AN INSTANCE]]]
|
||
|
|
The first thing to do is creating an instance of EasyFileSave class. Usually, you do it once in your Script,
|
||
|
|
for example in the variables declaration section or in a Start() function.
|
||
|
|
|
||
|
|
{-{{DECLARATION}}}
|
||
|
|
|-||[1]<bold>EasyFileSave</bold> variable_name = new <bold>EasyFileSave</bold>()|||
|
||
|
|
|-||[2]<bold>EasyFileSave</bold> variable_name = new <bold>EasyFileSave</bold>(<par>file_name</par>)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameter{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{file_name!string (<i>optional</i>)!The name of the file. If omitted, Easy File Save will use 'gamedata'
|
||
|
|
as name.}
|
||
|
|
</tbl>
|
||
|
|
|
||
|
|
<code title="Example 1 - Instance without file name">
|
||
|
|
// Import TigerForge namespace for accessing to Easy File Save class.
|
||
|
|
using TigerForge;
|
||
|
|
|
||
|
|
public class Demo : MonoBehaviour
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Declare the variable globally.
|
||
|
|
-EasyFileSave myFile;
|
||
|
|
|
||
|
|
-void Start()
|
||
|
|
-{
|
||
|
|
--// Initialize the EasyFileSave instance.
|
||
|
|
--myFile = new EasyFileSave();
|
||
|
|
-}
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
<code title="Example 2 - Instance with a file name">
|
||
|
|
// Import TigerForge namespace for accessing to Easy File Save class.xx
|
||
|
|
using TigerForge;
|
||
|
|
|
||
|
|
public class Demo : MonoBehaviour
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Declare the variable globally.
|
||
|
|
-EasyFileSave myFile;
|
||
|
|
|
||
|
|
-void Start()
|
||
|
|
-{
|
||
|
|
--// Initialize the EasyFileSave instance and name the file 'my_game_data'.
|
||
|
|
--myFile = new EasyFileSave("my_game_data");
|
||
|
|
-}
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[writing]]]
|
||
|
|
When you declare an instance of EasyFileSave class, the system initializes also the internal storage. This
|
||
|
|
storage represents the file content. It's a dictionary you have to fill with data. When the filling
|
||
|
|
operation is completed, you have to just call the Save() method to transfer the storage data into the file.
|
||
|
|
To fill the storage you have to use the Add() method.
|
||
|
|
|
||
|
|
{{{.ADD}}}
|
||
|
|
The Add() method adds a new, single value, to the internal storage.<br><br>
|
||
|
|
|||variable_name.Add(key, value, ignoreExistingKey = false*)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value. This key must be unique and it used, during the reading
|
||
|
|
operation, to get this value.}
|
||
|
|
{value!object!The value to save.}
|
||
|
|
{ignoreExistingKey!bool (optional)!By default, if the given key already exists into the 'internal
|
||
|
|
storage', the existing key value is overwritten by the new value.<br />Set the optional
|
||
|
|
'ignoreExistingKey' parameter to true so as to prevent the reuse of an existing key. In this case, the
|
||
|
|
original value won't be overwritten and a non-blocking warning will be thrown.}
|
||
|
|
</tbl>
|
||
|
|
|
||
|
|
The Add() method can recognize different type of values and serialize them in the proper
|
||
|
|
way:
|
||
|
|
|
||
|
|
- in general, everything that is based on <b>object</b> type and can be serialized by
|
||
|
|
<i>BinaryFormatter</i>;<br>
|
||
|
|
- common data types: string, boolean, integer, float, bytes, etc.;<br>
|
||
|
|
- common collections: list, dictionary, ecc.;<br>
|
||
|
|
- common Unity data types: Vector2, Vector3, Vector4, Quaternion, Transform, Color, Color32, Rect;<br>
|
||
|
|
- custom Class instances and collections of this Class (through a built-in dedicated serializer - see
|
||
|
|
Writing Custom Classes paragraph for details);<br>
|
||
|
|
- BoxCollider (through a custom Extension - see Extension paragraph for details).
|
||
|
|
|
||
|
|
{{{.SAVE}}}
|
||
|
|
The Save() method transfers the data collected into the internal storage into the file. This operation
|
||
|
|
concludes the writing process and clears the storage to free the memory occupied by it. This method
|
||
|
|
should be called at the end of the storage filling operation.
|
||
|
|
|
||
|
|
|||variable_name.Save()|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
</tbl>
|
||
|
|
<tbl2>
|
||
|
|
{{Returned Value{}Type{}Description}}
|
||
|
|
{true or false!boolean!The method returns true if the writing is completed without errors. Otherwise, it
|
||
|
|
returns false.}
|
||
|
|
</tbl2>
|
||
|
|
|
||
|
|
<code title="Example - Collecting data and saving">
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void SaveMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Write some common data type value.
|
||
|
|
|
||
|
|
-myFile.Add("name", "Conan");
|
||
|
|
-myFile.Add("age", 32);
|
||
|
|
-myFile.Add("strenght", 122.5f);
|
||
|
|
-myFile.Add("has_sword", true);
|
||
|
|
|
||
|
|
-// Write a List of strings.
|
||
|
|
|
||
|
|
-var equipment = new List<string>();
|
||
|
|
-equipment.Add("Hammer");
|
||
|
|
-equipment.Add("Knife");
|
||
|
|
-equipment.Add("Rope");
|
||
|
|
|
||
|
|
-myFile.Add("hero_equip", equipment);
|
||
|
|
|
||
|
|
-// Write some Unity common type value.
|
||
|
|
|
||
|
|
-myFile.Add("initialLocation", new Vector3(101.5f,-30.4f,22f));
|
||
|
|
-myFile.Add("player", gameObject.transform);
|
||
|
|
|
||
|
|
-// Save the collected data into the file and clear the storage.
|
||
|
|
-// Note that Save() method returns true (writing ok) or false (writing error). So you can use it inside an 'if' statement.
|
||
|
|
|
||
|
|
-myFile.Save();
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{{{.APPEND}}}
|
||
|
|
The Append() method is similar to Save(), but it adds the internal storage content at the end of the file's
|
||
|
|
existing content. If the file doesn't exist, Append() method simply works as Save() the first time. If the
|
||
|
|
file exists, this method reads the file content and then add the storage at the end of this content. By
|
||
|
|
default, if the file and the storage contain one same keys, the value of the file is overwritten with the
|
||
|
|
storage's value. You can bypass this behavior setting the method's overwrite parameter to false. In this
|
||
|
|
case, the storage's key is ignored and the file's value is preserved.
|
||
|
|
|
||
|
|
|||[1]variable_name.Append()|||
|
||
|
|
|||[2]variable_name.Append(overwrite)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{overwrite!boolean (<i>optional</i>)!true (default): file values are updated with storage values if they
|
||
|
|
share the same key.<br />false: file values are preserved even if the storage contains same keys. }
|
||
|
|
</tbl>
|
||
|
|
<tbl2>
|
||
|
|
{{Returned Value{}Type{}Description}}
|
||
|
|
{true or false!boolean!The method returns true if the writing is completed without errors. Otherwise, it
|
||
|
|
returns false.}
|
||
|
|
</tbl2>
|
||
|
|
|
||
|
|
<code title="Example">
|
||
|
|
myFile.Append();
|
||
|
|
</code>
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[Writing custom classes]]]
|
||
|
|
Easy File Save can save instances of custom classes and collections that use custom classes. Since the use
|
||
|
|
of custom classes often results in the creation of complex data structures, EasyFileSave uses various
|
||
|
|
methods to convert these data structures into simpler formats more suitable to be saved and loaded.|
|
||
|
|
Two techinques are implemented at the moment: <b>XML serialization</b> and <b>Binary conversion</b>. Keep in
|
||
|
|
mind that both
|
||
|
|
have pros and cons. You should check if your custom class can be converted without issues or if it's too
|
||
|
|
complex for a correct conversion. See a C# development manual to better undestand the limitations of those
|
||
|
|
methods and do some test with your data.
|
||
|
|
|
||
|
|
{{{.ADDSERIALIZED}}}
|
||
|
|
The AddSerialized() method works exactly as the Add() method, but it convert the data through XML serialization,
|
||
|
|
so as to turn the data structure into text format.
|
||
|
|
|
||
|
|
|||variable_name.AddSerialized(key, data)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value. This key must be unique and it used, during the reading
|
||
|
|
operation, to get this value.}
|
||
|
|
{data!object!The data to save.}
|
||
|
|
</tbl>
|
||
|
|
<br>
|
||
|
|
<code>
|
||
|
|
[System.Serializable]
|
||
|
|
public class XXItemXX
|
||
|
|
{
|
||
|
|
-public string name;
|
||
|
|
-public int quantity;
|
||
|
|
}
|
||
|
|
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void SaveMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Create a List of Item (custom class).
|
||
|
|
|
||
|
|
-var items = new List<XXItemXX>();
|
||
|
|
-items.Add(new XXItemXX { name = "Gold", quantity = 15000 });
|
||
|
|
-items.Add(new XXItemXX { name = "Darts", quantity = 24 });
|
||
|
|
-items.Add(new XXItemXX { name = "Potions", quantity = 10 });
|
||
|
|
|
||
|
|
-// Add this custom List to the internal storage.
|
||
|
|
|
||
|
|
-myFile.AddSerialized("items", items);
|
||
|
|
|
||
|
|
-// Save the collected data into the file and clear the storage.
|
||
|
|
|
||
|
|
-myFile.Save();
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{{{.ADDBINARY}}}
|
||
|
|
The AddBinary() method works exactly as the Add() method, but it convert the data through BinaryFormat,
|
||
|
|
so as to turn the data structure into an array of bytes.
|
||
|
|
|
||
|
|
|||variable_name.AddBinary(key, data)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value. This key must be unique and it used, during the reading
|
||
|
|
operation, to get this value.}
|
||
|
|
{data!object!The data to save.}
|
||
|
|
</tbl>
|
||
|
|
<br>
|
||
|
|
<code>
|
||
|
|
[System.Serializable]
|
||
|
|
public class XXItemXX
|
||
|
|
{
|
||
|
|
-public string name;
|
||
|
|
-public int quantity;
|
||
|
|
}
|
||
|
|
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void SaveMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Create a List of Item (custom class).
|
||
|
|
|
||
|
|
-var items = new List<XXItemXX>();
|
||
|
|
-items.Add(new XXItemXX { name = "Gold", quantity = 15000 });
|
||
|
|
-items.Add(new XXItemXX { name = "Darts", quantity = 24 });
|
||
|
|
-items.Add(new XXItemXX { name = "Potions", quantity = 10 });
|
||
|
|
|
||
|
|
-// Add this custom List to the internal storage.
|
||
|
|
|
||
|
|
-myFile.AddBinary("items", items);
|
||
|
|
|
||
|
|
-// Save the collected data into the file and clear the storage.
|
||
|
|
|
||
|
|
-myFile.Save();
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[Reading]]]
|
||
|
|
When you declare an instance of EasyFileSave class, the system initializes also the internal storage. This
|
||
|
|
storage represents the file content. This means that the reading operation will fill this storage with its
|
||
|
|
content. As a result, you will have the internal storage with all the file values identified by their unique
|
||
|
|
ids (the keys you used in the Add() method for writing data). Because the Add() method adds data as a
|
||
|
|
generic
|
||
|
|
type, when you read a value it's just an <b>object</b> and you have to convert (cast) it in the proper data
|
||
|
|
type.
|
||
|
|
You can get the object value and then manually convert it or you can use one of the built-in Get methods
|
||
|
|
that convert the values in the most common types.
|
||
|
|
|
||
|
|
{{{.LOAD}}}
|
||
|
|
The Load() method fills the internal storage with the file content. <b>It must be called before to start
|
||
|
|
reading the values.</b> It returns true when loading and storage filling is completed, so it must be used in
|
||
|
|
an
|
||
|
|
'if' statement in order to avoid get value issues.
|
||
|
|
|
||
|
|
|||variable_name.Load()|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
</tbl>
|
||
|
|
<tbl2>
|
||
|
|
{{Value{}Type{}Description}}
|
||
|
|
{true or false!boolean!The method returns true when the reading process is completed without errors and
|
||
|
|
the internal storage is filled with all the file data. Otherwise, it returns false.}
|
||
|
|
</tbl2>
|
||
|
|
|
||
|
|
{{{.GET* METHODS}}}
|
||
|
|
The methods that can read the storage values have the name starting with Get. Basically, the name of the
|
||
|
|
method specifies which type of data it will get.
|
||
|
|
|
||
|
|
|||variable_name.GetData(key)|||
|
||
|
|
|||variable_name.GetString(key)|||
|
||
|
|
|||variable_name.GetBool(key)|||
|
||
|
|
|||variable_name.GetInt(key)|||
|
||
|
|
|||variable_name.GetFloat(key)|||
|
||
|
|
|||variable_name.GetByte(key)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value.}
|
||
|
|
</tbl>
|
||
|
|
<tbl2>
|
||
|
|
{{Method{}Type{}Description}}
|
||
|
|
{GetData!object!The value as object.}
|
||
|
|
{GetString!string!The value as string.}
|
||
|
|
{GetBool!bool!The value as boolean.}
|
||
|
|
{GetInt!int!The value as integer.}
|
||
|
|
{GetFloat!float!The value as float.}
|
||
|
|
{GetByte!byte!The value as byte.}
|
||
|
|
</tbl2>
|
||
|
|
|
||
|
|
{{{.GETUNITY* METHODS}}}
|
||
|
|
These methods get values that are Unity data types.
|
||
|
|
|
||
|
|
|||variable_name.GetUnityVector2(key)|||
|
||
|
|
|||variable_name.GetUnityVector3(key)|||
|
||
|
|
|||variable_name.GetUnityVector4(key)|||
|
||
|
|
|||variable_name.GetUnityQuaternion(key)|||
|
||
|
|
|||variable_name.GetUnityColor(key)|||
|
||
|
|
|||variable_name.GetUnityColor32(key)|||
|
||
|
|
|||variable_name.GetUnityRect(key)|||
|
||
|
|
|||variable_name.GetUnityTransform(key)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value.}
|
||
|
|
</tbl>
|
||
|
|
<tbl2>
|
||
|
|
{{Method{}Type{}Description}}
|
||
|
|
{GetUnityVector2!Vector2!The value as Vector2.}
|
||
|
|
{GetUnityVector3!Vector3!The value as Vector3.}
|
||
|
|
{GetUnityVector4!Vector4!The value as Vector4.}
|
||
|
|
{GetUnityQuaternion!Quaternion!The value as Quaternion.}
|
||
|
|
{GetUnityColor!Color!The value as Color.}
|
||
|
|
{GetUnityColor32!Color32!The value as Color32.}
|
||
|
|
{GetUnityRect!Rect!The value as Rect.}
|
||
|
|
{GetUnityTransform!<i>Custom object</i>!The Unity transform type contains various Vector3 and Quaternion
|
||
|
|
values. For this reason, this method gets a custom structure where all these parameters are well
|
||
|
|
organized. This structure contains the following parameters:<br>
|
||
|
|
- (Vector3) position;<br>
|
||
|
|
- (Quaternion) rotation;<br>
|
||
|
|
- (Vector3) localScale;<br>
|
||
|
|
- (Vector3) localPosition;<br>
|
||
|
|
- (Quaternion) localRotation;<br>
|
||
|
|
- (Vector3) lossyScale;<br>
|
||
|
|
- (Vector3) eulerAngles;<br>
|
||
|
|
- (Vector3) localEulerAngles;}
|
||
|
|
</tbl2>
|
||
|
|
|
||
|
|
{{{.DISPOSE}}}
|
||
|
|
The Dispose() method manually clears the internal storage, in order to free the memory occupied by it. Even
|
||
|
|
if it's not mandatory, it's recommended to call Dispose() at the end of the reading operations. Note that
|
||
|
|
this method is automatically called by the Save() method.
|
||
|
|
|
||
|
|
|||variable_name.Dispose()|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
</tbl>
|
||
|
|
|
||
|
|
<code title="Example - Loading, reading data and disposing memory">
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void LoadMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// The Load() method returns true when the storage is filled and ready.
|
||
|
|
-if (myFile.Load())
|
||
|
|
-{
|
||
|
|
|
||
|
|
--// Use the various Get methods to read each value properly converted.
|
||
|
|
|
||
|
|
--var character = myFile.GetString("name");
|
||
|
|
--var age = myFile.GetInt("age");
|
||
|
|
--var strenght = myFile.GetFloat("strenght");
|
||
|
|
--var has_sword = myFile.GetBool("has_sword");
|
||
|
|
|
||
|
|
--// Use the various GetUnity methods to read values that are Unity types.
|
||
|
|
|
||
|
|
--var initialLocation = myFile.GetUnityVectorTRE("initialLocation");
|
||
|
|
|
||
|
|
--// GetUnityTransform() returns a custom object, so it requires a variable.
|
||
|
|
|
||
|
|
--var tr = myFile.GetUnityTransform("player");
|
||
|
|
--gameObject.transform.position = tr.position;
|
||
|
|
--gameObject.transform.rotation = tr.rotation;
|
||
|
|
--gameObject.transform.localScale = tr.localScale;
|
||
|
|
|
||
|
|
--// Now that all the data has been read, you can call Dispose() to free the memory.
|
||
|
|
|
||
|
|
--myFile.Dispose();
|
||
|
|
|
||
|
|
-{
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[Reading custom classes]]]
|
||
|
|
Easy File Save can load instances of custom classes and collections that use custom classes.
|
||
|
|
The methods to be used to read data depend on the system chosen when writing.
|
||
|
|
|
||
|
|
{{{.GETDESERIALISED}}}
|
||
|
|
The GetDeserialized() method convert the XML data structure into the custom data structure.
|
||
|
|
|
||
|
|
|||variable_name.GetDeserialized(key, type)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value.}
|
||
|
|
{type!System.Type!The type that must be used for deserialization.}
|
||
|
|
</tbl>
|
||
|
|
<tbl2>
|
||
|
|
{{Value{}Type{}Description}}
|
||
|
|
{read data!object!The data as object. It must be manually converted in the proper way (cast).}
|
||
|
|
</tbl2>
|
||
|
|
|
||
|
|
<code>
|
||
|
|
[System.Serializable]
|
||
|
|
public class XXItemXX
|
||
|
|
{
|
||
|
|
-public string name;
|
||
|
|
-public int quantity;
|
||
|
|
}
|
||
|
|
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void LoadMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// The Load() method returns true when the storage is filled and ready.
|
||
|
|
-if (myFile.Load())
|
||
|
|
-{
|
||
|
|
|
||
|
|
--// Because the saved data was a List of Item,
|
||
|
|
--// GetDeserialized() method requires this type as parameter (using typeof to obtain the System.Type).
|
||
|
|
--// The method returns an object, so it must be manually converted.
|
||
|
|
|
||
|
|
--var items = (List<XXItemXX>)myFile.GetDeserialized("items", typeof(List<XXItemXX>));
|
||
|
|
|
||
|
|
--// Now that all the data has been read, you can call Dispose() to free the memory.
|
||
|
|
|
||
|
|
--myFile.Dispose();
|
||
|
|
|
||
|
|
-{
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{{{.GETBINARY}}}
|
||
|
|
The GetBinary() method convert the bytes array data structure into the custom data structure.
|
||
|
|
|
||
|
|
|||variable_name.GetDeserialized(key)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value.}
|
||
|
|
</tbl>
|
||
|
|
<tbl2>
|
||
|
|
{{Value{}Type{}Description}}
|
||
|
|
{read data!object!The data as object. It must be manually converted in the proper way (cast).}
|
||
|
|
</tbl2>
|
||
|
|
|
||
|
|
<code>
|
||
|
|
[System.Serializable]
|
||
|
|
public class XXItemXX
|
||
|
|
{
|
||
|
|
-public string name;
|
||
|
|
-public int quantity;
|
||
|
|
}
|
||
|
|
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void LoadMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// The Load() method returns true when the storage is filled and ready.
|
||
|
|
-if (myFile.Load())
|
||
|
|
-{
|
||
|
|
|
||
|
|
--// Because the saved data was a List of Item,
|
||
|
|
--// GetDeserialized() method requires this type as parameter (using typeof to obtain the System.Type).
|
||
|
|
--// The method returns an object, so it must be manually converted.
|
||
|
|
|
||
|
|
--var items = (List<XXItemXX>)myFile.GetBinary("items");
|
||
|
|
|
||
|
|
--// Now that all the data has been read, you can call Dispose() to free the memory.
|
||
|
|
|
||
|
|
--myFile.Dispose();
|
||
|
|
|
||
|
|
-{
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[MANAGEMENT METHODS]]]
|
||
|
|
Easy File Save comes with some methods to manage the file and the system.
|
||
|
|
|
||
|
|
{{{FILE EXISTS}}}
|
||
|
|
Return true if the file exists (if the file is physically existing in the device storage).
|
||
|
|
|
||
|
|
|||variable_name.FileExists()|||
|
||
|
|
|
||
|
|
{{{DELETE}}}
|
||
|
|
Delete the file from the device storage (if it exists) and dispose the Easy File Save internal storage.
|
||
|
|
|
||
|
|
|||variable_name.Delete()|||
|
||
|
|
|
||
|
|
{{{KEY EXISTS}}}
|
||
|
|
Check if the internal storage contains the given key. This control can be useful to check if a certain key
|
||
|
|
exists before trying to read its value.
|
||
|
|
|
||
|
|
|||variable_name.KeyExists(key)|||
|
||
|
|
|
||
|
|
<code>
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void LoadMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// The Load() method returns true when the storage is filled and ready.
|
||
|
|
-if (myFile.Load())
|
||
|
|
-{
|
||
|
|
|
||
|
|
--// Check if 'name' key exists before using the Get method.
|
||
|
|
|
||
|
|
--string name = "";
|
||
|
|
--if (myFile.KeyExists("name")) name = myFile.GetString("name");
|
||
|
|
|
||
|
|
-{
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{{{GET FILE NAME}}}
|
||
|
|
Return the current file name assigned to the instance, with the full path.
|
||
|
|
|
||
|
|
|||variable_name.GetFileName()|||
|
||
|
|
|
||
|
|
{{{DELETE ALL FILES}}}
|
||
|
|
The EasyFileSave class has a static function to delete all the files currently instantiated. Use it with
|
||
|
|
caution.
|
||
|
|
|
||
|
|
|||variable_name.DeleteAll()|||
|
||
|
|
|
||
|
|
{{{CLASS SERIALIZATION}}}
|
||
|
|
The EasyFileSave class has a static function to serialize a custom class instance. It returns the XML
|
||
|
|
representation of the given data (object).
|
||
|
|
|
||
|
|
|||EasyFileSave.Serialize(data)|||
|
||
|
|
|
||
|
|
{{{CLASS DESERIALIZATION}}}
|
||
|
|
The EasyFileSave class has a static function to deserialize an XML in the user custom class instance. It
|
||
|
|
returns an object.
|
||
|
|
|
||
|
|
|||EasyFileSave.Deserialize(data, type)|||
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[Extensions]]]
|
||
|
|
An <b>Extension</b> allows you to extend what Easy File Save can save and load. With this feature, you can save
|
||
|
|
and
|
||
|
|
load data types that aren't built-in in the system, for example, Unity components or complex custom data
|
||
|
|
types. When you implement an Extension, it becomes part of the Easy File Save system and it's accessible by
|
||
|
|
all the EasyFileSave instances.
|
||
|
|
|
||
|
|
{-{{EasyFileSaveExtension Class}}}
|
||
|
|
New Extensions must be developed inside the EasyFileSaveExtension C# script, that's placed inside the
|
||
|
|
EasyFileSave folder. This script already contains an Extension that allows to save and load
|
||
|
|
BoxColliders.
|
||
|
|
|
||
|
|
{{{HOW TO CREATE AN EXTENSION}}}
|
||
|
|
Developing an Extension is pretty easy and it basically requires just some steps. The following instructions
|
||
|
|
will show how to implement an Extension adding the support for RigidBody Unity component as
|
||
|
|
example:
|
||
|
|
|
||
|
|
{.{{1.}}}
|
||
|
|
Inside the Start() function, use the AddExtension() method to declare a new Extension. This
|
||
|
|
method requires a name for the Extension (a string) and the name of the callBack function (the function to
|
||
|
|
call in order to make this Extension working).
|
||
|
|
|
||
|
|
<code>
|
||
|
|
public void Start()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Name of this extension and the callBack function which contains the extension configuration.
|
||
|
|
-AddExtension("BoxCollider", BoxCollider);
|
||
|
|
|
||
|
|
-// My new Extension: support for saving and loading RigidBody.
|
||
|
|
-AddExtension("RBody", RBodyExtension);
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{.{{2.}}}
|
||
|
|
In the Script file (ideally after the Start() function) create the callBack function (for this
|
||
|
|
example <i>RigidBodyExtension</i>).
|
||
|
|
|
||
|
|
<code>
|
||
|
|
public void Start()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Name of this extension and the callBack function which contains the extension configuration.
|
||
|
|
-AddExtension("BoxCollider", BoxCollider);
|
||
|
|
|
||
|
|
-// My new Extension: support for saving and loading RigidBody.
|
||
|
|
-AddExtension("RBody", RBodyExtension);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// My RigidBodyExtension callback function, as declared in AddExtension() method.
|
||
|
|
void RBodyExtension()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{.{{3.}}}
|
||
|
|
The callBack function is called every time you perform a writing operation. So, it must contain
|
||
|
|
the logic to collect the RigidBody data you want to save. The Extension system recognizes basic data type
|
||
|
|
only (string, bool, int, float, byte, etc.), so you must collect only RigidBody values that are of
|
||
|
|
these types and that are important for your needs. Inside this function you have just to perform 3
|
||
|
|
operations:
|
||
|
|
|
||
|
|
<b>3.1 </b><br>You have to use the GetData() method to obtain the value you are going to save. GetData() method
|
||
|
|
requires the Extension name as parameter:
|
||
|
|
|
||
|
|
<code>
|
||
|
|
// My RigidBodyExtension callback function, as declared in AddExtension() method.
|
||
|
|
void RBodyExtension()
|
||
|
|
{
|
||
|
|
-// Use GetData, with Extension name as parameter, to get the value you are going to save.
|
||
|
|
-var data = GetData("RBody");
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
<b>3.2 </b><br>Because GetData() method returns an object, you have to convert it in the original type (in this
|
||
|
|
example, RigidBody Unity data type):
|
||
|
|
|
||
|
|
<code>
|
||
|
|
// My RigidBodyExtension callback function, as declared in AddExtension() method.
|
||
|
|
void RBodyExtension()
|
||
|
|
{
|
||
|
|
-// Use GetData, with Extension name as parameter, to get the value you are going to save.
|
||
|
|
-var data = GetData("RBody");
|
||
|
|
|
||
|
|
-// I convert the object from GetData() into a RigidBody data type.
|
||
|
|
-RigidBody rb = (RigidBody)data;
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
<b>3.3 </b><br>Now that you have the RigidBody that you're going to save, you have to use the SetParameters()
|
||
|
|
method to collect the RigidBody values you want to save. This method requires the Extension name followed by
|
||
|
|
a list of parameters. Each parameter, described by the Par() object, must contain one of the RigidBody
|
||
|
|
values and a unique name that identifies it:
|
||
|
|
|
||
|
|
<code>
|
||
|
|
// My RigidBodyExtension callback function, as declared in AddExtension() method.
|
||
|
|
void RBodyExtension()
|
||
|
|
{
|
||
|
|
-// Use GetData, with Extension name as parameter, to get the value you are going to save.
|
||
|
|
-var data = GetData("RBody");
|
||
|
|
|
||
|
|
-// I convert the object from GetData() into a RigidBody data type.
|
||
|
|
-RigidBody rb = (RigidBody)data;
|
||
|
|
|
||
|
|
-// With SerParameters() method you can choose which RigidBody values to save and load.
|
||
|
|
-// Every single value requires a name. A good practice is to use the same RigidBody property name.
|
||
|
|
-SetParameters(
|
||
|
|
--"RBody",
|
||
|
|
--new Par { name = "angularDrag", value = rb.angularDrag },
|
||
|
|
--new Par { name = "angularVelocity", value = rb.angularVelocity },
|
||
|
|
--new Par { name = "detectCollisions", value = rb.detectCollisions },
|
||
|
|
--new Par { name = "freezeRotation", value = rb.freezeRotation },
|
||
|
|
--new Par { name = "useGravity", value = rb.useGravity },
|
||
|
|
--new Par { name = "velocity", value = rb.velocity }
|
||
|
|
-);
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
That's all and the new Extension for RigidBody is ready to be used.
|
||
|
|
|
||
|
|
{{{HOW TO SAVE EXTENSION DATA}}}
|
||
|
|
Because Extension data is a custom functionality, you can't use the standard Add() method, but you must use
|
||
|
|
AddCustom() method.
|
||
|
|
|
||
|
|
|||variable_name.AddCustom(key, data, extension_name)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value.}
|
||
|
|
{data!object!The custom data to save.}
|
||
|
|
{extension_name!string!The name of the Extension that will properly save the data.}
|
||
|
|
</tbl>
|
||
|
|
|
||
|
|
<code>
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void SaveMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// Add my GameObject RigidBody to the internal storage through a dedicated Extension.
|
||
|
|
|
||
|
|
-myFile.AddCustom("player_rigid_body", gameObject.GetComponent<RigidBody>(), "RBody");
|
||
|
|
|
||
|
|
-// Save the collected data into the file and clear the storage.
|
||
|
|
|
||
|
|
-myFile.Save();
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
|
||
|
|
{{{HOW TO LOAD EXTENSION DATA}}}
|
||
|
|
To get data that has been saved by an Extension you must use GetCustom() method. This method returns a
|
||
|
|
special dictionary that contains all the saved values, identified by a specific name, and methods to convert
|
||
|
|
each value in a common data type.
|
||
|
|
|
||
|
|
|||variable_name.GetCustom(key, extension_name)|||
|
||
|
|
<tbl>
|
||
|
|
{{Parameters{}Type{}Description}}
|
||
|
|
{variable_name!!The name of the EasyFileSave instance.}
|
||
|
|
{key!string!A unique id to identify the value.}
|
||
|
|
{extension_name!string!The name of the Extension that will generate the dictionary.}
|
||
|
|
</tbl>
|
||
|
|
|
||
|
|
Returned value:<br>
|
||
|
|
a special dictionary with the values indentified by unique keys and the following methods to convert (cast)
|
||
|
|
each value:
|
||
|
|
|
||
|
|
- <i>variable</i>[<i>key</i>]<b>.ToString()</b>;<br>
|
||
|
|
- <i>variable</i>[<i>key</i>]<b>.ToBool()</b>;<br>
|
||
|
|
- <i>variable</i>[<i>key</i>]<b>.ToInt()</b>;<br>
|
||
|
|
- <i>variable</i>[<i>key</i>]<b>.ToFloat()</b>;<br>
|
||
|
|
- <i>variable</i>[<i>key</i>]<b>.ToByte()</b>;<br><br>
|
||
|
|
- <i>variable</i>[<i>key</i>]<b>.data</b> (<i>property that contains the value as object</i>);
|
||
|
|
|
||
|
|
<code>
|
||
|
|
// It's supposed you have previously created a myFile instance.
|
||
|
|
void LoadMyData()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// The Load() method returns true when the storage is filled and ready.
|
||
|
|
-if (myFile.Load())
|
||
|
|
-{
|
||
|
|
|
||
|
|
--// Use GetCustom to obtain the dictionary with all the saved values.
|
||
|
|
|
||
|
|
--var rb = myFile.GetCustom("player_rigid_body", "RBody");
|
||
|
|
|
||
|
|
--// Use rb dictionary as needed.
|
||
|
|
|
||
|
|
--var playerRB = gameObject.GetComponent<RigidBody>();
|
||
|
|
|
||
|
|
--playerRB.angularDrag = rb["angularDrag"].toFloat();
|
||
|
|
--playerRB.angularVelocity = rb["angularVelocity"].toFloat();
|
||
|
|
--playerRB.detectCollisions = rb["detectCollisions"].toBool();
|
||
|
|
--playerRB.freezeRotation = rb["freezeRotation"].toBool();
|
||
|
|
--playerRB.useGravity = rb["useGravity"].toBool();
|
||
|
|
--playerRB.velocity = rb["velocity"].toFloat();
|
||
|
|
|
||
|
|
-{
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
[[[WRITE / READ TEST]]]
|
||
|
|
The TestDataSaveLoad() method is a practical way to test the writing and reading operation. This method is
|
||
|
|
pretty useful to test own data structure, expecially in case you're going to manage complex data structures.|
|
||
|
|
To use this method just fill the "internal storage" with your data e call TestDataSaveLoad(). In the Unity
|
||
|
|
Console you will see the test results.
|
||
|
|
|
||
|
|
<code>
|
||
|
|
void MyTest()
|
||
|
|
{
|
||
|
|
|
||
|
|
-// The data structure to test.
|
||
|
|
|
||
|
|
-myFile.Add("name", "Conan");
|
||
|
|
-myFile.Add("age", 32);
|
||
|
|
-myFile.Add("strenght", 122.5f);
|
||
|
|
-myFile.Add("has_sword", true);
|
||
|
|
|
||
|
|
-var equipment = new List<string>();
|
||
|
|
-equipment.Add("Hammer");
|
||
|
|
-equipment.Add("Knife");
|
||
|
|
-equipment.Add("Rope");
|
||
|
|
|
||
|
|
-myFile.Add("hero_equip", equipment);
|
||
|
|
|
||
|
|
-myFile.Add("initialLocation", new Vector3(101.5f,-30.4f,22f));
|
||
|
|
-myFile.Add("player", gameObject.transform);
|
||
|
|
|
||
|
|
-// Test
|
||
|
|
|
||
|
|
-myFile.TestDataSaveLoad();
|
||
|
|
|
||
|
|
}
|
||
|
|
</code>
|
||
|
|
[[[]]]
|
||
|
|
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div style="height:80px;"></div>
|
||
|
|
</body>
|
||
|
|
|
||
|
|
</html>
|
||
|
|
|
||
|
|
|
||
|
|
<script>
|
||
|
|
/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */
|
||
|
|
!function (e, t) { "use strict"; "object" == typeof module && "object" == typeof module.exports ? module.exports = e.document ? t(e, !0) : function (e) { if (!e.document) throw new Error("jQuery requires a window with a document"); return t(e) } : t(e) }("undefined" != typeof window ? window : this, function (C, e) { "use strict"; var t = [], E = C.document, r = Object.getPrototypeOf, s = t.slice, g = t.concat, u = t.push, i = t.indexOf, n = {}, o = n.toString, v = n.hasOwnProperty, a = v.toString, l = a.call(Object), y = {}, m = function (e) { return "function" == typeof e && "number" != typeof e.nodeType }, x = function (e) { return null != e && e === e.window }, c = { type: !0, src: !0, nonce: !0, noModule: !0 }; function b(e, t, n) { var r, i, o = (n = n || E).createElement("script"); if (o.text = e, t) for (r in c) (i = t[r] || t.getAttribute && t.getAttribute(r)) && o.setAttribute(r, i); n.head.appendChild(o).parentNode.removeChild(o) } function w(e) { return null == e ? e + "" : "object" == typeof e || "function" == typeof e ? n[o.call(e)] || "object" : typeof e } var f = "3.4.1", k = function (e, t) { return new k.fn.init(e, t) }, p = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; function d(e) { var t = !!e && "length" in e && e.length, n = w(e); return !m(e) && !x(e) && ("array" === n || 0 === t || "number" == typeof t && 0 < t && t - 1 in e) } k.fn = k.prototype = { jquery: f, constructor: k, length: 0, toArray: function () { return s.call(this) }, get: function (e) { return null == e ? s.call(this) : e < 0 ? this[e + this.length] : this[e] }, pushStack: function (e) { var t = k.merge(this.constructor(), e); return t.prevObject = this, t }, each: function (e) { return k.each(this, e) }, map: function (n) { return this.pushStack(k.map(this, function (e, t) { return n.call(e, t, e) })) }, slice: function () { return this.pushStack(s.apply(this, arguments)) }, first: function () { return this.eq(0) }, last: function () { return this.eq(-1) }, eq: function (e) { var t = this.length, n = +e + (e < 0 ? t : 0); return this.pushStack(0 <= n && n < t ? [this[n]] : []) }, end: function () { return this.prevObject || this.constructor() }, push: u, sort: t.sort, splice: t.splice }, k.extend = k.fn.extend = function () { var e, t, n, r, i, o, a = arguments[0] || {}, s = 1, u = arguments.length, l = !1; for ("boolean" == typeof a && (l = a, a = arguments[s] || {}, s++), "object" == typeof a || m(a) || (a = {}), s === u && (a = this, s--); s < u; s++)if (null != (e = arguments[s])) for (t in e) r = e[t], "__proto__" !== t && a !== r && (l && r && (k.isPlainObject(r) || (i = Array.isArray(r))) ? (n = a[t], o = i && !Array.isArray(n) ? [] : i || k.isPlainObject(n) ? n : {}, i = !1, a[t] = k.extend(l, o, r)) : void 0 !== r && (a[t] = r)); return a }, k.extend({ expando: "jQuery" + (f + Math.random()).replace(/\D/g, ""), isReady: !0, error: function (e) { throw new Error(e) }, noop: function () { }, isPlainObject: function (e) { var t, n; return !(!e || "[object Object]" !== o.call(e)) && (!(t = r(e)) || "function" == typeof (n = v.call(t, "constructor") && t.constructor) && a.call(n) === l) }, isEmptyObject: function (e) { var t; for (t in e) return !1; return !0 }, globalEval: function (e, t) { b(e, { nonce: t && t.nonce }) }, each: function (e, t) { var n, r = 0; if (d(e)) { for (n = e.length; r < n; r++)if (!1 === t.call(e[r], r, e[r])) break } else for (r in e) if (!1 === t.call(e[r], r, e[r])) break; return e }, trim: function (e) { return null == e ? "" : (e + "").replace(p, "") }, makeArray: function (e, t) { var n = t || []; return null != e && (d(Object(e)) ? k.merge(n, "string" == typeof e ? [e] : e) : u.call(n, e)), n }, inArray: function (e, t, n) { return null == t ? -1 : i.call(t, e, n) }, merge: function (e, t) { for (var n = +t.length, r = 0, i = e.length; r < n; r++)e[i++] = t[r]; return e.length = i, e }, grep: function (e, t, n) { for (var r = [], i = 0, o = e.length, a = !n; i < o; i++)!t(e[i], i) !== a && r.push(e[i]); return r }, map: function (e, t, n) { var r, i, o = 0, a = []; if (d(e)) for (r = e.length; o
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style>
|
||
|
|
.bg-color-grey {
|
||
|
|
background-color: #4e5d64;
|
||
|
|
}
|
||
|
|
|
||
|
|
.bg-color-grey-dark {
|
||
|
|
background-color: #434e54;
|
||
|
|
}
|
||
|
|
|
||
|
|
.bg-color-blue {
|
||
|
|
background-color: #6181b2;
|
||
|
|
}
|
||
|
|
|
||
|
|
.bg-color-blue-dark {
|
||
|
|
background-color: #495d75;
|
||
|
|
}
|
||
|
|
|
||
|
|
body {
|
||
|
|
background-color: #CCC;
|
||
|
|
margin: 0px;
|
||
|
|
padding: 0px;
|
||
|
|
width: 100%;
|
||
|
|
height: 100%;
|
||
|
|
font-family: Arial, Helvetica, sans-serif;
|
||
|
|
font-size: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title {
|
||
|
|
width: 100%;
|
||
|
|
overflow: hidden;
|
||
|
|
position: relative;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title .deco2 {
|
||
|
|
width: 80px;
|
||
|
|
height: 200px;
|
||
|
|
transform: rotate(20deg);
|
||
|
|
position: absolute;
|
||
|
|
top: -20px;
|
||
|
|
left: 50px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title .deco1 {
|
||
|
|
width: 80px;
|
||
|
|
height: 200px;
|
||
|
|
transform: rotate(-20deg);
|
||
|
|
position: absolute;
|
||
|
|
top: -10px;
|
||
|
|
left: -40px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title .name {
|
||
|
|
margin-left: 170px;
|
||
|
|
padding: 10px 0px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title .company {
|
||
|
|
color: #6181b2;
|
||
|
|
font-weight: bold;
|
||
|
|
font-size: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title .software {
|
||
|
|
color: #FFF;
|
||
|
|
font-size: 24px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title .software span {
|
||
|
|
color: #CCC;
|
||
|
|
font-size: 18px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.box {
|
||
|
|
background-color: #FFF;
|
||
|
|
border: 1px solid #AAA;
|
||
|
|
-webkit-box-shadow: 6px 6px 5px 0px rgba(0, 0, 0, 0.3);
|
||
|
|
-moz-box-shadow: 6px 6px 5px 0px rgba(0, 0, 0, 0.3);
|
||
|
|
box-shadow: 6px 6px 5px 0px rgba(0, 0, 0, 0.3);
|
||
|
|
min-height: 20px;
|
||
|
|
margin: 20px 20px 0px 20px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.box .title {
|
||
|
|
width: 100%;
|
||
|
|
padding: 6px 4px 4px 7px;
|
||
|
|
color: #434e54;
|
||
|
|
font-weight: bold;
|
||
|
|
font-size: 16px;
|
||
|
|
text-transform: uppercase;
|
||
|
|
border-bottom: 1px solid #CCC;
|
||
|
|
margin-bottom: 10px;
|
||
|
|
background-color: aliceblue;
|
||
|
|
box-sizing: border-box;
|
||
|
|
}
|
||
|
|
|
||
|
|
.box .title2 {
|
||
|
|
width: 100%;
|
||
|
|
padding: 6px 4px 4px 7px;
|
||
|
|
color: #495d75;
|
||
|
|
font-weight: bold;
|
||
|
|
font-size: 16px;
|
||
|
|
border-bottom: 1px solid #CCC;
|
||
|
|
margin-bottom: 10px;
|
||
|
|
background-color: aliceblue;
|
||
|
|
box-sizing: border-box;
|
||
|
|
}
|
||
|
|
|
||
|
|
.box .type {
|
||
|
|
font-weight: normal;
|
||
|
|
}
|
||
|
|
|
||
|
|
.box .content {
|
||
|
|
width: 100%;
|
||
|
|
padding: 0px 4px 10px 7px;
|
||
|
|
font-size: 12px;
|
||
|
|
color: rgb(19, 19, 19);
|
||
|
|
box-sizing: border-box;
|
||
|
|
}
|
||
|
|
|
||
|
|
.box .content .intro {
|
||
|
|
border-bottom: 1px solid #CCC;
|
||
|
|
padding-bottom: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.box .content .spec {
|
||
|
|
padding-top: 6px;
|
||
|
|
padding-bottom: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.csharp-types {
|
||
|
|
font-weight: bold;
|
||
|
|
color: rgb(18, 0, 255);
|
||
|
|
}
|
||
|
|
|
||
|
|
.csharp-types2 {
|
||
|
|
font-style: italic;
|
||
|
|
color: rgb(18, 0, 255);
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows {
|
||
|
|
border: 1px solid #FFFFFF;
|
||
|
|
text-align: left;
|
||
|
|
border-collapse: collapse;
|
||
|
|
margin-top: 10px;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows td,
|
||
|
|
table.paleBlueRows th {
|
||
|
|
border: 1px solid #FFFFFF;
|
||
|
|
padding: 3px 2px;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows tbody td {
|
||
|
|
font-size: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows tr:nth-child(even) {
|
||
|
|
background: aliceblue;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows thead {
|
||
|
|
background: #da8300;
|
||
|
|
border-bottom: 5px solid #FFFFFF;
|
||
|
|
}
|
||
|
|
|
||
|
|
.table-head2 thead {
|
||
|
|
background: #6a9955 !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows thead th {
|
||
|
|
font-size: 12px;
|
||
|
|
font-weight: bold;
|
||
|
|
color: #FFFFFF;
|
||
|
|
text-align: center;
|
||
|
|
border-left: 2px solid #FFFFFF;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows thead th:first-child {
|
||
|
|
border-left: none;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows tfoot {
|
||
|
|
font-size: 12px;
|
||
|
|
font-weight: bold;
|
||
|
|
color: #333333;
|
||
|
|
background: #D0E4F5;
|
||
|
|
border-top: 3px solid #444444;
|
||
|
|
}
|
||
|
|
|
||
|
|
table.paleBlueRows tfoot td {
|
||
|
|
font-size: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.method {
|
||
|
|
position: relative;
|
||
|
|
background-color: #fdffde;
|
||
|
|
padding: 10px;
|
||
|
|
border: 1px solid #efce80;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code {
|
||
|
|
background-color: #1e1e1e;
|
||
|
|
color: #FFF;
|
||
|
|
border-radius: 0px 6px 6px 0px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .row {
|
||
|
|
float: none;
|
||
|
|
clear: both;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .row .num {
|
||
|
|
padding: 1px 1px 1px 6px;
|
||
|
|
float: left;
|
||
|
|
width: 18px;
|
||
|
|
background-color: #3f3f3f;
|
||
|
|
color: #a7a7a7;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .row .text {
|
||
|
|
padding: 1px 1px 1px 36px;
|
||
|
|
box-sizing: border-box;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .green {
|
||
|
|
color: #4ec9b0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .blue {
|
||
|
|
color: #569cd6;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .yellow {
|
||
|
|
color: #d0dcaa;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .pink {
|
||
|
|
color: #bb86c0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .red {
|
||
|
|
color: rgb(238, 131, 131);
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .black {
|
||
|
|
color: #1e1e1e;
|
||
|
|
}
|
||
|
|
|
||
|
|
.code .comment {
|
||
|
|
color: #6a9955 !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
.example {
|
||
|
|
background-color: #3f3f3f;
|
||
|
|
border-radius: 4px 4px 0px 0px;
|
||
|
|
padding: 6px 10px 5px 10px;
|
||
|
|
color: #FFF;
|
||
|
|
width: max-content;
|
||
|
|
}
|
||
|
|
|
||
|
|
.picture {
|
||
|
|
border: 6px solid #434e54;
|
||
|
|
border-radius: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.tag-t {
|
||
|
|
background-color: #6181b2;
|
||
|
|
color: #FFF;
|
||
|
|
font-weight: bold;
|
||
|
|
width: max-content;
|
||
|
|
padding: 4px 10px 4px 10px;
|
||
|
|
border-radius: 0px 4px 4px 0px;
|
||
|
|
margin-left: -10px;
|
||
|
|
margin-bottom: 4px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.tag-p {
|
||
|
|
background-color: #5f5f5f;
|
||
|
|
color: #FFF;
|
||
|
|
font-weight: bold;
|
||
|
|
width: max-content;
|
||
|
|
padding: 4px 10px 4px 10px;
|
||
|
|
border-radius: 0px 4px 4px 0px;
|
||
|
|
margin-bottom: 4px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.tag-product {
|
||
|
|
font-weight: bold;
|
||
|
|
color: #434e54;
|
||
|
|
}
|
||
|
|
|
||
|
|
.properties {
|
||
|
|
margin-top: 4px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.properties td {
|
||
|
|
text-align: left;
|
||
|
|
vertical-align: top;
|
||
|
|
border-bottom: 1px solid #CCC;
|
||
|
|
padding-bottom: 6px;
|
||
|
|
padding-top: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.properties td:nth-of-type(1) {
|
||
|
|
font-weight: bold;
|
||
|
|
background-color: #d0e4f5;
|
||
|
|
padding: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.properties td:nth-of-type(2) {
|
||
|
|
padding-left: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.properties tr:nth-of-type(1) td {
|
||
|
|
border-top: 1px solid #CCC;
|
||
|
|
}
|
||
|
|
|
||
|
|
bold {
|
||
|
|
color: #6181b2;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
|
||
|
|
par {
|
||
|
|
color: #da8300;
|
||
|
|
}
|
||
|
|
|
||
|
|
.override {
|
||
|
|
position: absolute;
|
||
|
|
width: 20px;
|
||
|
|
top: 0px;
|
||
|
|
bottom: 0px;
|
||
|
|
left: 0px;
|
||
|
|
background-color: #da8300;
|
||
|
|
color: #FFF;
|
||
|
|
display: flex;
|
||
|
|
justify-content: center;
|
||
|
|
align-items: center;
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
|
||
|
|
function customs(html) {
|
||
|
|
html = html.replaceAll("EasyFileSaveExtension", "<span class='green'>EasyFileSaveExtension</span>");
|
||
|
|
html = html.replaceAll("EasyFileSave", "<span class='green'>EasyFileSave</span>");
|
||
|
|
html = html.replaceAll("MonoBehaviour", "<span class='green'>MonoBehaviour</span>");
|
||
|
|
html = html.replaceAll("Vector3", "<span class='green'>Vector3</span>");
|
||
|
|
html = html.replaceAll("Par {", "<span class='green'>Par</span> {");
|
||
|
|
html = html.replaceAll("RigidBody", "<span class='green'>RigidBody</span>");
|
||
|
|
html = html.replaceAll("RBody", "RigidBody");
|
||
|
|
html = html.replaceAll("XXItemXX", "<span class='green'>Item</span>");
|
||
|
|
html = html.replaceAll("GameObject ", "<span class='green'>GameObject </span>");
|
||
|
|
html = html.replaceAll("Debug", "<span class='green'>Debug</span>");
|
||
|
|
html = html.replaceAll("GetInt", "<span class='yellow'>GetInt</span>");
|
||
|
|
html = html.replaceAll("GetString", "<span class='yellow'>GetString</span>");
|
||
|
|
html = html.replaceAll("GetBool", "<span class='yellow'>GetBool</span>");
|
||
|
|
html = html.replaceAll("gameObject", "<span class='pink'>gameObject</span>");
|
||
|
|
html = html.replaceAll("myFile.AddBinary", "myFile<span class='yellow'>.AddBinary</span>");
|
||
|
|
html = html.replaceAll("myFile.AddSerialized", "myFile<span class='yellow'>.AddSerialized</span>");
|
||
|
|
html = html.replaceAll("myFile.Add", "myFile<span class='yellow'>.Add</span>");
|
||
|
|
html = html.replaceAll("myFile.Save", "myFile<span class='yellow'>.Save</span>");
|
||
|
|
html = html.replaceAll("myFile.Append", "myFile<span class='yellow'>.Append</span>");
|
||
|
|
html = html.replaceAll("myFile.GetFloat", "myFile<span class='yellow'>.GetFloat</span>");
|
||
|
|
html = html.replaceAll("myFile.GetUnityVectorTRE", "myFile<span class='yellow'>.GetUnityVector3</span>");
|
||
|
|
html = html.replaceAll("myFile.GetUnityTransform", "myFile<span class='yellow'>.GetUnityTransform</span>");
|
||
|
|
html = html.replaceAll("myFile.Dispose", "myFile<span class='yellow'>.Dispose</span>");
|
||
|
|
html = html.replaceAll("myFile.GetBinary", "myFile<span class='yellow'>.GetBinary</span>");
|
||
|
|
html = html.replaceAll("myFile.GetDeserialized", "myFile<span class='yellow'>.GetDeserialized</span>");
|
||
|
|
html = html.replaceAll("myFile.Load", "myFile<span class='yellow'>.Load</span>");
|
||
|
|
html = html.replaceAll("myFile.KeyExists", "myFile<span class='yellow'>.KeyExists</span>");
|
||
|
|
html = html.replaceAll("myFile.TestDataSaveLoad", "myFile<span class='yellow'>.TestDataSaveLoad</span>");
|
||
|
|
html = html.replaceAll("AddExtension", "<span class='yellow'>AddExtension</span>");
|
||
|
|
html = html.replaceAll("GetData", "<span class='yellow'>GetData</span>");
|
||
|
|
html = html.replaceAll("SetParameters", "<span class='yellow'>SetParameters</span>");
|
||
|
|
return html;
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==== CORE ENGINE ===========================================================================
|
||
|
|
|
||
|
|
$(document).ready(function () {
|
||
|
|
|
||
|
|
initialize();
|
||
|
|
|
||
|
|
manualRendering();
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
function manualRendering() {
|
||
|
|
|
||
|
|
var html = $("#manual_content").html();
|
||
|
|
|
||
|
|
var rows = html.split("\n");
|
||
|
|
var n = rows.length;
|
||
|
|
html = "";
|
||
|
|
var isCodeBlock = false;
|
||
|
|
var codeBlock = "";
|
||
|
|
|
||
|
|
for (var i = 0; i < n; i++) {
|
||
|
|
|
||
|
|
var row = rows[i].trim();
|
||
|
|
if (row == "") {
|
||
|
|
row = "<br><br>";
|
||
|
|
if (i == n - 1) {
|
||
|
|
row = "";
|
||
|
|
} else {
|
||
|
|
if (isEngineCode(rows[i + 1])) row = "";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (row.indexOf("<code") >= 0) {
|
||
|
|
isCodeBlock = true;
|
||
|
|
codeBlock = "";
|
||
|
|
}
|
||
|
|
|
||
|
|
if (isCodeBlock) {
|
||
|
|
codeBlock += row + "\n";
|
||
|
|
} else {
|
||
|
|
|
||
|
|
row = row.replace('[[[]]]', '</div></div>');
|
||
|
|
row = row.replace('[[[', '<div class="box"><div class="title">');
|
||
|
|
row = row.replace(']]]', '</div><div class="content">');
|
||
|
|
row = row.replace('{{{', '<div class="tag-t">');
|
||
|
|
row = row.replace('{-{{', '<div class="tag-p">');
|
||
|
|
row = row.replace('{.{{', '<div class="tag-p" style="background-color:#6181b2">');
|
||
|
|
row = row.replace('}}}', '</div>');
|
||
|
|
row = row.replace('.|', '.<br>');
|
||
|
|
|
||
|
|
if (row.indexOf("|||") == 0) {
|
||
|
|
row = row.replace("|||", "").replace("|||", "");
|
||
|
|
row = row.replace("variable_name", "<i>variable_name</i>");
|
||
|
|
|
||
|
|
var tmp = row.replace(".", "|").replace("(", "|").replace(")", "|").split("|");
|
||
|
|
var tmp2 = tmp[2].split(",");
|
||
|
|
var pars = "";
|
||
|
|
for (t = 0; t < tmp2.length; t++) {
|
||
|
|
var p = tmp2[t].trim();
|
||
|
|
if (p.indexOf("*") > 0) p = "<span style='color:#9a9a9a;'>" + p.replace("*", "") + "</span>"; else p = "<span style='color:#da8300;'>" + p.replace("*", "") + "</span>";
|
||
|
|
pars += ", " + p;
|
||
|
|
}
|
||
|
|
pars = pars.substr(2);
|
||
|
|
row = tmp[0] + ".<b style='color:#6181b2'>" + tmp[1] + "</b>(" + pars + ");";
|
||
|
|
|
||
|
|
row = overrideRender(row);
|
||
|
|
|
||
|
|
row = '<div class="method">' + row + '</div>';
|
||
|
|
}
|
||
|
|
|
||
|
|
if (row.indexOf("|-||") == 0) {
|
||
|
|
row = row.replace("|-||", "").replace("|||", "");
|
||
|
|
row = row.replace("variable_name", "<i>variable_name</i>");
|
||
|
|
row = overrideRender(row);
|
||
|
|
row = '<div class="method">' + row + '</div>';
|
||
|
|
}
|
||
|
|
|
||
|
|
row = row.replaceAll(product.name, '<span class="tag-product">' + product.name + '</span>');
|
||
|
|
|
||
|
|
html += row + " ";
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
if (row.indexOf("</code>") >= 0) {
|
||
|
|
isCodeBlock = false;
|
||
|
|
html += codeBlock;
|
||
|
|
}
|
||
|
|
|
||
|
|
//console.log(row);
|
||
|
|
}
|
||
|
|
|
||
|
|
//console.log(html);
|
||
|
|
|
||
|
|
$("#manual_content").html(html);
|
||
|
|
|
||
|
|
codeRender();
|
||
|
|
|
||
|
|
imageRender();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
function overrideRender(row) {
|
||
|
|
if (row.indexOf("[") == 0) {
|
||
|
|
for (var i = 0; i < 5; i++) {
|
||
|
|
var tag = "[" + i + "]";
|
||
|
|
row = row.replace(tag, '<div class="override">' + i + '</div> ');
|
||
|
|
}
|
||
|
|
return row;
|
||
|
|
} else {
|
||
|
|
return row;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function codeRender() {
|
||
|
|
|
||
|
|
$("code").each(function () {
|
||
|
|
|
||
|
|
var code = $(this).text();
|
||
|
|
code = code.split("\n");
|
||
|
|
var title = $(this).attr("title");
|
||
|
|
if (title == "" || typeof title === "undefined") title = "Example";
|
||
|
|
|
||
|
|
var html = "";
|
||
|
|
|
||
|
|
for (var i = 0; i < code.length; i++) {
|
||
|
|
|
||
|
|
var riga = indent(code[i].trim());
|
||
|
|
if (riga.indexOf("//") >= 0) {
|
||
|
|
riga = comments(riga);
|
||
|
|
} else {
|
||
|
|
riga = quotes(riga);
|
||
|
|
riga = standards(riga);
|
||
|
|
riga = customs(riga);
|
||
|
|
}
|
||
|
|
|
||
|
|
html += "<div class='row'><div class='num'>" + (i + 1) + "</div><div class='text'>" + riga + "</div></div>";
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
html = "<div class='example'>" + title + "</div><div class='code'>" + html + "</div>";
|
||
|
|
$(this).html(html);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
$("tbl").each(function () {
|
||
|
|
|
||
|
|
var html = $(this).html();
|
||
|
|
|
||
|
|
html = html.replaceAll("{{", "<thead><tr><th>");
|
||
|
|
html = html.replaceAll("{}", "</th><th>");
|
||
|
|
html = html.replaceAll("}}", "</th></tr></thead>");
|
||
|
|
html = html.replaceAll("{", "<tr><td>");
|
||
|
|
html = html.replaceAll("}", "</td></tr>");
|
||
|
|
html = html.replaceAll("!", "</td><td>");
|
||
|
|
|
||
|
|
var final = "<tr style='background: #da8300;'><td></td><td></td><td></td></tr>";
|
||
|
|
|
||
|
|
html = "<table class='paleBlueRows'>" + html + final + "</table>";
|
||
|
|
|
||
|
|
$(this).html(html);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
$("tbl2").each(function () {
|
||
|
|
|
||
|
|
var html = $(this).html();
|
||
|
|
|
||
|
|
html = html.replaceAll("{{", "<thead><tr><th>");
|
||
|
|
html = html.replaceAll("{}", "</th><th>");
|
||
|
|
html = html.replaceAll("}}", "</th></tr></thead>");
|
||
|
|
html = html.replaceAll("{", "<tr><td>");
|
||
|
|
html = html.replaceAll("}", "</td></tr>");
|
||
|
|
html = html.replaceAll("!", "</td><td>");
|
||
|
|
|
||
|
|
var final = "<tr style='background: #6a9955;'><td></td><td></td><td></td></tr>";
|
||
|
|
|
||
|
|
html = "<table class='paleBlueRows table-head2'>" + html + final + "</table>";
|
||
|
|
|
||
|
|
$(this).html(html);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
function standards(html) {
|
||
|
|
html = html.replaceAll("void", "<span class='blue'>void</span>");
|
||
|
|
html = html.replaceAll("var", "<span class='blue'>var</span>");
|
||
|
|
html = html.replaceAll("null", "<span class='blue'>null</span>");
|
||
|
|
html = html.replaceAll("int", "<span class='blue'>int</span>");
|
||
|
|
html = html.replaceAll("using", "<span class='blue'>using</span>");
|
||
|
|
html = html.replaceAll("new", "<span class='blue'>new</span>");
|
||
|
|
html = html.replaceAll("public class", "<span class='blue'>public class</span>");
|
||
|
|
html = html.replaceAll("public", "<span class='blue'>public</span>");
|
||
|
|
html = html.replaceAll("true", "<span class='blue'>true</span>");
|
||
|
|
html = html.replaceAll("false", "<span class='blue'>false</span>");
|
||
|
|
html = html.replaceAll("bool", "<span class='blue'>bool</span>");
|
||
|
|
html = html.replaceAll("float", "<span class='blue'>float</span>");
|
||
|
|
html = html.replaceAll("string", "<span class='blue'>string</span>");
|
||
|
|
html = html.replaceAll("byte", "<span class='blue'>byte</span>");
|
||
|
|
html = html.replaceAll("typeof", "<span class='blue'>typeof</span>");
|
||
|
|
html = html.replaceAll("List", "<span class='green'>List</span>");
|
||
|
|
html = html.replaceAll("Dictionary", "<span class='green'>Dictionary</span>");
|
||
|
|
html = html.replaceAll("Serializable", "<span class='green'>Serializable</span>");
|
||
|
|
html = html.replaceAll("MonoBehaviour", "<span class='green'>MonoBehaviour</span>");
|
||
|
|
html = html.replaceAll("Vector3", "<span class='green'>Vector3</span>");
|
||
|
|
html = html.replaceAll("RigidBody", "<span class='green'>RigidBody</span>");
|
||
|
|
html = html.replaceAll("RBody", "RigidBody");
|
||
|
|
html = html.replaceAll("GameObject ", "<span class='green'>GameObject </span>");
|
||
|
|
html = html.replaceAll("AudioSource ", "<span class='green'>AudioSource </span>");
|
||
|
|
html = html.replaceAll("Input", "<span class='green'>Input</span>");
|
||
|
|
html = html.replaceAll("Debug", "<span class='green'>Debug</span>");
|
||
|
|
html = html.replaceAll("gameObject", "<span class='pink'>gameObject</span>");
|
||
|
|
html = html.replaceAll("Start", "<span class='blue'>Start</span>");
|
||
|
|
html = html.replaceAll("Update", "<span class='blue'>Update</span>");
|
||
|
|
html = html.replaceAll("GetKeyUp", "<span class='yellow'>GetKeyUp</span>");
|
||
|
|
html = html.replaceAll("KeyCode", "<span class='yellow'>KeyCode</span>");
|
||
|
|
|
||
|
|
if (html == "") html = "<span class='black'>.</span>";
|
||
|
|
return html;
|
||
|
|
}
|
||
|
|
|
||
|
|
function quotes(riga) {
|
||
|
|
var counter = 0;
|
||
|
|
var newriga = "";
|
||
|
|
for (var i = 0; i < riga.length; i++) {
|
||
|
|
var c = riga.substr(i, 1);
|
||
|
|
|
||
|
|
if (c == '"') {
|
||
|
|
counter++;
|
||
|
|
if (counter % 2) {
|
||
|
|
newriga += "<span class='red'>\"";
|
||
|
|
} else {
|
||
|
|
newriga += "\"</span>";
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
newriga += c;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return newriga;
|
||
|
|
}
|
||
|
|
|
||
|
|
function comments(riga) {
|
||
|
|
return "<span class='comment'>" + riga + "</span>";
|
||
|
|
}
|
||
|
|
|
||
|
|
function indent(riga) {
|
||
|
|
var counter = 0;
|
||
|
|
for (var i = 0; i < riga.length; i++) {
|
||
|
|
var c = riga.substr(i, 1);
|
||
|
|
if (c == "-") counter++; else break;
|
||
|
|
}
|
||
|
|
if (counter == 0) return riga;
|
||
|
|
|
||
|
|
var spazi = riga.substr(0, counter);
|
||
|
|
spazi = spazi.replaceAll("-", " ");
|
||
|
|
|
||
|
|
riga = spazi + riga.substr(counter);
|
||
|
|
|
||
|
|
return riga;
|
||
|
|
}
|
||
|
|
|
||
|
|
function imageRender() {
|
||
|
|
|
||
|
|
$("picture").each(function () {
|
||
|
|
var i = $(this).attr("n");
|
||
|
|
$(this).html('<img loading="lazy" class="picture" src="' + images[i] + '">');
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
function contentRender() {
|
||
|
|
|
||
|
|
$(".content").each(function () {
|
||
|
|
var html = $(this).html();
|
||
|
|
|
||
|
|
for (var i = 0; i < 100; i++) {
|
||
|
|
html = html.replace("[t[", "<div class='tag-t'>");
|
||
|
|
html = html.replace("[p[", "<div class='tag-p'>");
|
||
|
|
|
||
|
|
html = html.replace("]]", "</div>");
|
||
|
|
|
||
|
|
html = html.replace("[SP]", "<span class='tag-product'>");
|
||
|
|
html = html.replace("[S]", "</span>");
|
||
|
|
}
|
||
|
|
|
||
|
|
$(this).html(html);
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
function OLD_RENDER() {
|
||
|
|
$(".attribute_structure").each(function () {
|
||
|
|
var testo = $(this).text();
|
||
|
|
testo = "[<span style='font-weight:bold;color:#6181b2'>" + testo + "]";
|
||
|
|
testo = testo.replace("(", "</span>( ").replace(")", " )");
|
||
|
|
testo = testo.replaceAll("string", "<span class='csharp-types'>string</span>");
|
||
|
|
testo = testo.replaceAll("int", "<span class='csharp-types'>int</span>");
|
||
|
|
testo = testo.replaceAll("float", "<span class='csharp-types'>float</span>");
|
||
|
|
testo = testo.replaceAll("bool", "<span class='csharp-types'>bool</span>");
|
||
|
|
testo = testo.replaceAll("true", "<span class='csharp-types2'>true</span>");
|
||
|
|
testo = testo.replaceAll("false", "<span class='csharp-types2'>false</span>");
|
||
|
|
$(this).html(testo);
|
||
|
|
});
|
||
|
|
|
||
|
|
contentRender();
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==== HELPERS ===============================================================================
|
||
|
|
|
||
|
|
var product = {};
|
||
|
|
|
||
|
|
function initialize() {
|
||
|
|
|
||
|
|
$("#product").hide();
|
||
|
|
product.author = $("#product_author").text();
|
||
|
|
product.name = $("#product_name").text();
|
||
|
|
product.version = $("#product_version").text();
|
||
|
|
|
||
|
|
$("title").text(product.author + " » " + product.name + " (v." + product.version + ")");
|
||
|
|
|
||
|
|
var title = '<div class="title bg-color-grey"><div class="deco1 bg-color-grey-dark"></div><div class="deco2 bg-color-blue"></div><div class="name"><div class="company">' + product.author + '</div><div class="software"><b>' + product.name + '</b> <span>v. ' + product.version + '</span></div></div></div>';
|
||
|
|
|
||
|
|
$("#manual_title").html(title);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
function isEngineCode(string) {
|
||
|
|
if (string.indexOf("[[[") >= 0) return true;
|
||
|
|
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
String.prototype.replaceAll = function (search, replacement) {
|
||
|
|
var target = this;
|
||
|
|
|
||
|
|
//return target.replace(new RegExp(search, 'g'), replacement);
|
||
|
|
return target.split(search).join(replacement);
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
var images = [];
|
||
|
|
|
||
|
|
</script>
|