Skip to content

Instantly share code, notes, and snippets.

View James-Frowen's full-sized avatar

James Frowen James-Frowen

View GitHub Profile
using System;
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
#endif
namespace JamesFrowen.PositionSync
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public class BackingFieldNameAttribute : PropertyAttribute
@James-Frowen
James-Frowen / ExitPlayModeOnCompile.cs
Created February 15, 2021 21:21
Exits play more when scripts are recompiled
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
namespace JamesFrowen.EditorScripts.Compilation
{
/// <summary>
/// Stop the game the scripts are recomplied
/// </summary>
[InitializeOnLoad]
@James-Frowen
James-Frowen / NetworkManagerGUI.cs
Created March 16, 2021 21:01
OnGui for NetworkManager to make iit quick to set up and start a server
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace Mirage
{
/// <summary>
/// An extension for the NetworkManager that displays a default HUD for controlling the network state of the game.
/// <para>This component also shows useful internal state for the networking system in the inspector window of the editor. It allows users to view connections, networked objects, message handlers, and packet statistics. This information can be helpful when debugging networked games.</para>
/// </summary>
[DisallowMultipleComponent]
using System.Collections.Generic;
using UnityEngine;
namespace Mirror
{
/// <summary>
/// Component that controls visibility of networked objects between scenes.
/// <para>Any object with this component on it will only be visible to other objects in the same scene</para>
/// <para>This would be used when the server has multiple additive subscenes loaded to isolate players to their respective subscenes</para>
/// <para>Does not actively check if scene has changed</para>
@James-Frowen
James-Frowen / EchoSocket.cs
Created October 17, 2021 16:08
Behaviour that makes Sockets echo back message. For Mirage networking
using System.Text;
using UnityEngine;
namespace Mirage.SocketLayer
{
/// <summary>
/// Monobehaviour to help debug a cloud server, can help check if ports are open and a socket is sending message correctly
/// <para>Server will echo back the message that was sent to it</para>
/// <para>Client will send 4 byte message every second, incrementing by 1 each time</para>
/// </summary>
@James-Frowen
James-Frowen / NetworkObjectCreater.cs
Last active April 12, 2022 15:14
Helper to create network objects at runtime
/*
MIT License
Copyright (c) 2021 James Frowen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@James-Frowen
James-Frowen / MessageTracker.cs
Created February 11, 2022 17:18
Message tracker for mirror
/*
MIT License
Copyright (c) 2021 James Frowen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
/*
MIT License
Copyright (c) 2022 James Frowen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is

Unity has changes how to create server build in 2021

Building from script

replace:

if (serverBuild)
    buildOptions |= BuildOptions.EnableHeadlessMode;
# Remove the line below if you want to inherit .editorconfig settings from higher directories
###############################
# Core EditorConfig Options #
###############################
root = true
[*.{cs,csx,vb,vbx,md}]
indent_style = space
indent_size = 4
tab_width = 4