Code: Select all
using UnityEngine;
using System.Collections;
using System; //This allows the IComparable Interface
//Bu kod silahlar için hangi dataları saklayacağını belirliyor.
public class Naau_WeaponData : IComparable<Naau_WeaponData>
{
public string WeaponName;
public bool OwnIt;
public bool Active;
public int power;
public Naau_WeaponData()
{
}
public Naau_WeaponData(string newName, bool newOwnIt,bool NewActive,int NewPower)
{
WeaponName = newName;
OwnIt = newOwnIt;
Active = NewActive;
power = NewPower;
}
public int CompareTo(Naau_WeaponData other)
{
if (other == null)
{
return 1;
}
//Return the difference in power.
return power - other.power;
}
}
I created this type but It still give error.
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ES2UserType_Naau_WeaponData : ES2Type
{
public override void Write(object obj, ES2Writer writer)
{
Naau_WeaponData data = (Naau_WeaponData)obj;
// Add your writer.Write calls here.
writer.Write(data.WeaponName);
writer.Write(data.Active);
writer.Write(data.OwnIt);
writer.Write(data.power);
}
public override object Read(ES2Reader reader)
{
Naau_WeaponData data = new Naau_WeaponData();
Read(reader, data);
return data;
}
public override void Read(ES2Reader reader, object c)
{
Naau_WeaponData data = (Naau_WeaponData)c;
// Add your reader.Read calls here to read the data into the object.
string WeaponName = reader.Read<string>();
bool Active = reader.Read<bool>();
bool OwnIt = reader.Read<bool>();
int power = reader.Read<int>();
}
/* ! Don't modify anything below this line ! */
public ES2UserType_Naau_WeaponData() : base(typeof(Naau_WeaponData)) { }
}
I couldnt find any example I actually find usefull informations but ı couldnt solve it. How Can I save this kind of data. I hope I am clear :.(