D12
D12
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
no
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
ah it was this error System.TypeLoadException: Could not resolve type with token 010000a1
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
and kept getting errors
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
yeah i did try to use newton soft but this is for a rimworld mod and im not really sure what newtonsoft dll im supposed to be using
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
so im really not sure what im doing wrong
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
(I have also tried the json helper but i get the same result)
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
I have tried a bunch of stuff from this solution but it seems nothing works
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
ServerInfo File
namespace OpenWorldRedux
{
[System.Serializable]
public class ServerInfo
{

public string ServerName;
public string SavedPort;
public string SavedIP;
}

}
namespace OpenWorldRedux
{
[System.Serializable]
public class ServerInfo
{

public string ServerName;
public string SavedPort;
public string SavedIP;
}

}
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
public static class JsonTester {
public static void Test() {
List<ServerInfo> playerInstances = new List<ServerInfo>();

ServerInfo playerInstance1 = new ServerInfo();
playerInstance1.ServerName = "8484239823";
playerInstance1.SavedPort = "Powai";
playerInstance1.SavedIP = "Random Nick";

ServerInfo playerInstance2 = new ServerInfo();
playerInstance2.ServerName = "512343283";
playerInstance2.SavedPort = "User2";
playerInstance2.SavedIP = "Rand Nick 2";
playerInstances.Add(playerInstance2);
playerInstances.Add(playerInstance1);
Log.Message(playerInstances[0].ServerName);
// To Json
string stringListAsJson = JsonUtility.ToJson(new JsonableListWrapper<ServerInfo>(playerInstances));
Log.Message(stringListAsJson);
// From Json
List<ServerInfo> stringListFromJson = JsonUtility.FromJson<JsonableListWrapper<ServerInfo>>(stringListAsJson).list;
Log.Message("Here");
//Convert to JSON
Log.Message(stringListFromJson.Count.ToString());
//Log.Message(stringListFromJson[0].ServerName);



}




}

[System.Serializable]
public class JsonableListWrapper<T>
{
public List<T> list;
public JsonableListWrapper(List<T> list) => this.list = list;
}
public static class JsonTester {
public static void Test() {
List<ServerInfo> playerInstances = new List<ServerInfo>();

ServerInfo playerInstance1 = new ServerInfo();
playerInstance1.ServerName = "8484239823";
playerInstance1.SavedPort = "Powai";
playerInstance1.SavedIP = "Random Nick";

ServerInfo playerInstance2 = new ServerInfo();
playerInstance2.ServerName = "512343283";
playerInstance2.SavedPort = "User2";
playerInstance2.SavedIP = "Rand Nick 2";
playerInstances.Add(playerInstance2);
playerInstances.Add(playerInstance1);
Log.Message(playerInstances[0].ServerName);
// To Json
string stringListAsJson = JsonUtility.ToJson(new JsonableListWrapper<ServerInfo>(playerInstances));
Log.Message(stringListAsJson);
// From Json
List<ServerInfo> stringListFromJson = JsonUtility.FromJson<JsonableListWrapper<ServerInfo>>(stringListAsJson).list;
Log.Message("Here");
//Convert to JSON
Log.Message(stringListFromJson.Count.ToString());
//Log.Message(stringListFromJson[0].ServerName);



}




}

[System.Serializable]
public class JsonableListWrapper<T>
{
public List<T> list;
public JsonableListWrapper(List<T> list) => this.list = list;
}
Log:
Requesting Server Info through packet
512343283
{}
Here
[Openworld] Failed to connect to server browser. Full Stack Error:
System.NullReferenceException: Object reference not set to an instance of an object
Requesting Server Info through packet
512343283
{}
Here
[Openworld] Failed to connect to server browser. Full Stack Error:
System.NullReferenceException: Object reference not set to an instance of an object
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
ok thanks, i'll check it out
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
still nothing
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
trying now
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
@chucklesthebeard
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
ok thanks for the quick answer
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
@chucklesthebeard @sinfluxx
37 replies
CC#
Created by D12 on 8/3/2023 in #help
❔ Basic C# Getting Null Result when trying to index attribute of an object.
37 replies