The downside to using this project is the server will have Unity overhead, other than that, everything seems to work flawlessly.
Read this if you're interested in contributing.
Learning the new Unity Transport Layer
License: MIT License
The downside to using this project is the server will have Unity overhead, other than that, everything seems to work flawlessly.
Read this if you're interested in contributing.
How do you add or find the params to add for public NetworkDriver(INetworkInterface netIf, params INetworkParameter[] param);
?
When I go to the meta data for INetworkParameter[]
all I get is as follows.
#region Assembly Unity.Networking.Transport, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// Unity.Networking.Transport.dll
#endregion
namespace Unity.Networking.Transport
{
public interface INetworkParameter
{
}
}
I want to send an array of bytes which contains a data type
and the x
, y
, z
position of a player. The data type
tells us that this is of 'position' data, this value could be 1
. For position data, x
, y
, and z
are integers and can be values such as 1500
, 20
, -3000
.
With the BitConverter, we can convert all our integers to byte arrays.
I found that the Unity DataStreamWriter
class has a public bool WriteBytes(NativeArray<byte> value);
method, so we can use that to send the bytes of data over the network.
Below is what I have so far.
https://github.com/valkyrienyanko/Prototype/blob/4762ead183cbb3c2d23dfcd4519318e55127ba59/Assets/Workspace/Scripts/Client.cs#L51-L66
I'm adding the byte arrays to a list to combine them all into one big byte array. Then I am passing that to the new NativeArray<byte>(bytes.ToArray(), Allocator.Persistent);
and finally we write that data to the writer
.
Note that I still have yet to see if this data makes it all in one piece on the server side.
Note that I am using the new Unity Transport Layer minimal client-server example. You can learn more about it here.
I found that the DataStreamReader class has a public void ReadBytes(NativeArray<byte> array);
and it's asking for NativeArray<byte> array
as a param, but my question is how do you know what your going to put in there if you're already receiving the array?
Right now all commands are loaded manually.
https://github.com/valkyrienyanko/Unity-Transport-Layer-Boilerplate/blob/2b0450020b623bd31b0f9852c84d6e652afe7432/Server/Assets/Scripts/Console.cs#L44-L52
If the commands were loaded dynamically somehow, this would save the time of having to manually type out each new command in the future.
https://github.com/valkyrienyanko/Unity-Transport-Layer-Boilerplate/blob/2b0450020b623bd31b0f9852c84d6e652afe7432/Server/Assets/Scripts/Console.cs#L33-L42
Split the scene into 2 areas. Left area is for login, right is for registering.
I just found out that Telepathy exists, is this better than what I'm doing here?
Note that the console can currently only print 1 line that spans across the entire width of the screen. There is no functionality for printing more then one line to console yet. This would require line detection when the characters get off the screen.
Update* I figured out how to detect how many lines there need to be per console message. I also figured out how to size the message box height out according to the number of lines. The only problem is when 2 big messages are sent, they overlap.
https://github.com/valkyrienyanko/Prototype/blob/25fd654754e973394215625cc109a6fa6d29ec6d/Server/Assets/Scripts/Console.cs#L49-L63
The project build takes 2 minutes to build the resource folder on a empty Unity project. 2 minutes might not sound like a long time to you but when you're constantly rebuilding and testing, it is painfully long. I have no lead to why this is happening.
Here are links to other people having similar problems.
https://answers.unity.com/questions/706674/unity-freezes-when-building-a-project-when-buildin.html
Check if account exists before saving to disk.
I'm trying to stop the server properly, just doing Driver.Dispose()
does not seem to be the way. Note that it is not clear exactly when this error occurs, you may have to run start
and stop
several times before the error occurs.
stop
in consolestart
in consoleA Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.
Right now all commands are in a switch statement in https://github.com/valkyrienyanko/Prototype/blob/master/Server/Assets/Scripts/Console.cs
It would be nice if they were spread across several files.
Take the following structure layout as an example.
Scripts/
+-- Server.cs
+-- Commands/
| +-- Kick.cs
| +-- Exit.cs
Each command should have a name, a usage showing the args syntax, and a description of how to use the command. The commands should be stored in a collection so we can type help commandname
to get more info on how to use that command.
Resetting event queue with pending events (Count=1, ConnectionID=0) Listening: 1
UnityEngine.Debug:LogError(Object)
Unity.Networking.Transport.NetworkLogger:DumpToConsole() (at Library/PackageCache/[email protected]/Runtime/NetworkLogger.cs:55)
Unity.Networking.Transport.LogJob:Execute() (at Library/PackageCache/[email protected]/Runtime/NetworkDriver.cs:585)
Unity.Jobs.JobStruct`1:Execute(LogJob&, IntPtr, IntPtr, JobRanges&, Int32)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Server:Update() (at Assets/Workspace/Scripts/Server.cs:90)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.