skeyll / SynicSugar

Unity High-level Networking Library for Mobile and Small-party Games with Epic Online Services.

Home Page:https://skeyll.github.io/SynicSugar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SynicSugar

https://github.com/skeyll/SynicSugar/blob/main/LICENSE Unity openupm

SynicSugar is Unity High-Level Network Library with EpicOnlineServices. The concept is the syntax sugar of netcode. The runtime process is sonic by pre-generating and IL weaving codes for your project. SynicSugar will be optimized for small-party (action) game

For more detail is https://skeyll.github.io/SynicSugar/.

Feature

  • Mesh topology with max 64 peers
  • No Use Cost and No CCU Limit
  • High-level APIs for mobile and small-group games (MatchMaking, Host-Migration and Re-connection...)
  • Cross-platform connction (Current: Android, iOS, and PC / Future: Console )
using SynicSugar.P2P;
using UnityEngine;
[NetworkPlayer(true)]
public partial class Player {  
    //Sync every 1000ms(default)
    [SyncVar] public int Hp;
    //Sync every 3000ms
    [SyncVar(3000)] Skill skill;

    [Synic(0)] public string name;
    [Synic(0)] public string item;
    [Synic(1)] public Vector3 pos;
    
    [Rpc] 
    public void Attack(int a){
        Hp -= a;
    }
    [TargetRpc]
    public void GreetTarget(UserId id){
        Debug.log("Hi");
    }
    [Rpc]
    public void Heal(HealInfo info){
        Debug.log($"{OwnerUserId} heal {info.target} {info.amount}");
    }

    public void SyncBasisStatus(){
        //Sync the Variables that have Synic(0) attribute at once.
        ConnectHub.Instance.SyncSynic(p2pInfo.Instance.LastDisconnectedUsersId, 0);
    }
}

Requirement

SynicSugar uses Roslyn SourceGenerator supported after 2021.3. SourceGenerator generates almost all codes for p2p connect on compile automatically.
Large dependencies is for performance. SynicSugar is mesh-topology p2p. All peers connect with each other instead of 1-to-many like dedicated server and client-server model. If we want to sync data with 63 peer in a full-mesh, we need to send data 63 times. Individual connection is fast but the whole is costly. So the core needs faster.

Getting started

1.Install SynicSugar and depended librarys.

The first is to import SynicSugar and dependent libraries. You can get SynicSugar from OpenUPM or SynicSugar/Release's unitypackage.
.unitypackage contains Mono.Cecil and System.Runtime.CompilerServices.Unsafe.dll for MemoryPack and, in addition to SynicSugar. Therefore, you can skip some processes, but it is more convenient to download via OpenUPM for version control.

  1. Rigister some package with OpenUPM

In your unity project, select Edit/ProjectSetting/PackageManager. Then, register some librarys.

Name: OpenUPM

URL: https://package.openupm.com

Scope(s):

  • net.skeyll.synicsugar (Skip if downloading as unitypackage)
  • com.cysharp.unitask
  • com.playeveryware.eos
  • com.cysharp.memorypack

image

  1. Install these packages
    These packages can be imported from Window/PackageManager/MyRegistries. Importing SynicSugar will automatically import the other required librarys. If you are using another version in your project, that one will probably work. However, SynicSugar has been developed using the following:
  • Epic Online Services Plugin for Unity: 2.2.0
  • UniTask: 2.3.1
  • MemoryPack: 1.9.13
  1. Import the rest (Skip if downloading as unitypackage.)
    Import what is not in OpenUPM.
  • Mono.Cecil
    Enter com.unity.nuget.mono-cecil in Edit/ProjectSetting/PackageManager/+/Add package from git URL.

image

  • System.Runtime.CompilerServices.Unsafe
    MemoryPack need System.Runtime.CompilerServices.Unsafe.dll. You can get this dll from Download package in https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/6.0.0 . Since this contains DLLs for multiple environments, only import packages for Unity. Unzip the downloaded file and drag and drop lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll into your project.

2.Get some tokens for EOS.

Please check the eos document or the plugin page. SynicSugar doesn't need EOS store brand. Just register and can develop online games.

About app credential, you can use Peer2Peer as ClientPolicy. The minimum is as follows. image

For Debug

SynicSugar has Debug.Log in some parts for the game development. To use the logs, add SYNICSUGAR_LOG to Scripting Define Symbols in project setting. Logs for errors are displayed by default.

License

License is under the MIT. I will never change it.

Contribute Guideline

SynicSugar's concept is an easy online game development for everyone. Therefore, the development is also based on this policy. The target is online game for up to 64 people supported by EOS, but the main is small-party action game. If you want to create MMO, you can use Mirror. The roadmap is to expand the necessary functions for these games and improve performance. If you need any necessary features, please post it to Github Issue, or pull. Great thanks for all contributions!

About

Unity High-level Networking Library for Mobile and Small-party Games with Epic Online Services.

https://skeyll.github.io/SynicSugar/

License:MIT License


Languages

Language:C# 100.0%