Skip to content

Instantly share code, notes, and snippets.

View amrit-choudhary's full-sized avatar

Amrit Choudhary amrit-choudhary

View GitHub Profile
{
"getExtraTurn" : false,
"maxTurns" : 15,
"maxTurnTimer": 5
}
@amrit-choudhary
amrit-choudhary / BugReporter.cs
Created July 14, 2017 14:54
BugReporter Editor Window complete script
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
public class BugReporter : EditorWindow {
string bugReportTitle = "";
GameObject buggyGameObject;
string description = "";
using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
...
// file save location of XML file
public string filePath;
// object to be serialized
<?xml version="1.0" encoding="Windows-1252"?>
<PlayerData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<name>Robert</name>
<age>21</age>
<gender>Male</gender>
</PlayerData>
using UnityEngine;
using System.IO;
using System.Xml.Serializaton;
...
// file save location of XML file
public string filePath;
// object to be serialized
public PlayerData playerDataObject;
{
"name": "Robert",
"age": 21,
"gender": "Male"
}
using UnityEngine;
using System.IO;
...
// file save location of JSON text
public string filePath;
// object to be serialized
public PlayerData playerDataObject;
// Data class who's object will be serialized and deserialized
// Classes must have the System.Serializable attribute
[System.Serializable]
public class PlayerData {
public string name;
public int age;
public string gender;
}
...
// reference to the created asset of scriptable object in the project folder
public SOData soData;
// values for saving and retrieving
float valueToSave;
float valueRetrieved;
// to save a float value
using UnityEngine
// attribute to create shortcut for creating scriptable object asset
[CreateAssetMenu]
public class SOData : ScriptableObject {
// float variable which will hold saved data
public float value;
}