Auros
Auros
CC#
Created by Galelao on 1/21/2023 in #help
❔ Learning C# Need help fixing a problem.
If you go into your .csproj file, you can change
<TargetFramework>netX.0</TargetFramework>
<TargetFramework>netX.0</TargetFramework>
to
<TargetFramework>netX.0-windows</TargetFramework>
<TargetFramework>netX.0-windows</TargetFramework>
to suppress the warning
16 replies
CC#
Created by Galelao on 1/21/2023 in #help
❔ Learning C# Need help fixing a problem.
That's not an error, it's just a warning which explains that the setter for Console.WindowHeight only works on Windows
16 replies
CC#
Created by Galelao on 1/21/2023 in #help
❔ Learning C# Need help fixing a problem.
I can only presume that \ should be \n
16 replies
CC#
Created by Galelao on 1/21/2023 in #help
❔ Learning C# Need help fixing a problem.
On line 22, you're using \ which escapes something in a string without escaping anything
16 replies
CC#
Created by Galelao on 1/21/2023 in #help
❔ Learning C# Need help fixing a problem.
OH! My bad, I didn't see the error
16 replies
CC#
Created by Galelao on 1/21/2023 in #help
❔ Learning C# Need help fixing a problem.
Is there anything in particular you do not understand about this? Or do you not understand it in general? Does the tutorial not cover the explanation of it?
16 replies
CC#
Created by Anton on 1/20/2023 in #help
❔ Resolve a service before the container is built
Not that I know of. If you need to set the shared object, do it after you call WebApplication.CreateBuilder. Technically a lambda provided to ctx.Host.ConfigureServices is called while the container is building, but that's not really an ideal event.
51 replies
CC#
Created by Anton on 1/20/2023 in #help
❔ Resolve a service before the container is built
I might be wrong with what you're trying to do, but if the shared object doesn't require a dependency from the built container, you can use the builder.Host.Properties dictionary to store shared objects during the host building process.
51 replies
CC#
Created by Anton on 1/20/2023 in #help
❔ Resolve a service before the container is built
If I'm reading this correctly, you want to resolve a service, and then use that service to further configure your services? Can you prove a code example of what you would like to do? (It doesn't have to work)
51 replies
CC#
Created by Stroniax on 1/20/2023 in #help
✅ HTTP/3 Server Without AspNetCore
12 replies
CC#
Created by lyxerexyl on 1/20/2023 in #help
Help, how to make this unity save and load system work?
Oh I never realized there was an official Unity discord server
6 replies
CC#
Created by lyxerexyl on 1/20/2023 in #help
Help, how to make this unity save and load system work?
I do Unity, but I've never touched the JsonUtility class. I used to use Newtonsoft but now I use System.Text.Json
6 replies
CC#
Created by lyxerexyl on 1/20/2023 in #help
Help, how to make this unity save and load system work?
According to the Unity documentation https://docs.unity3d.com/ScriptReference/JsonUtility.ToJson.html, it appears you are not allowed to serialize an array and presumably List<T> directly, as it tries to serialize the public fields on the List object itself, not the contents within. You need to wrap the list in a separate serializable class or struct, which you seem to already have with ListObjectToSave but aren't using. Try replacing this line in your Save method from
string json = JsonUtility.ToJson(objectsToSave);
string json = JsonUtility.ToJson(objectsToSave);
to
string json = JsonUtility.ToJson(listObjectToSave);
string json = JsonUtility.ToJson(listObjectToSave);
and change the type and assignment of the JsonUtility.FromJson call in your Load method. You might also need to add a [System.Serializable] attribute to the ListObjectToSave class.
6 replies