Skip to content

Instantly share code, notes, and snippets.

View glitchersgames's full-sized avatar
💭
Making Drive Buy - Delivery Battles!

Glitchers glitchersgames

💭
Making Drive Buy - Delivery Battles!
View GitHub Profile
struct PlayerDef
{
string m_Name;
Color m_Color;
public PlayerDef( string name, Color color )
{
m_Name = name;
m_Color = color;
}
[SyncVar(hook="OnHasPlayerDefUpdated")]
public bool m_HasPlayerDef;
void OnHasPlayerDefUpdated( bool hasPlayerDef )
{
if( m_HasPlayerDef == false && hasPlayerDef )
{
// The server now has the data we need!
}
public class LobbyPlayer : NetworkLobbyPlayer
{
[SyncVar(hook="OnHasPlayerDefUpdated")]
public bool m_HasPlayerDef = false;
#endregion
private PlayerDef m_PlayerDef;
public static LobbyPlayer LocalPlayer { get; private set; }
public class PlayerRequestPlayerDataMessage : MessageBase
{
public NetworkInstanceId m_SenderNetId;
public NetworkInstanceId m_SubjectNetId;
public PlayerRequestPlayerDataMessage(){}
public PlayerRequestPlayerDataMessage( NetworkInstanceId senderNetId, NetworkInstanceId subjectNetId )
{
m_SenderNetId = senderNetId;
m_SubjectNetId = subjectNetId;
public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayerObject, GameObject gamePlayerObject)
{
LobbyPlayer lobbyPlayer = lobbyPlayerObject.GetComponent<LobbyPlayer>();
Player gamePlayer = gamePlayerObject.GetComponent<Player>();
// set the SyncVar
gamePlayer.m_PlayerNumber = lobbyPlayer.m_PlayerNumber;
// setup for the server
gamePlayer.SetPlayerDef( lobbyPlayer.playerDef );
using System;
using UnityEngine;
using UnityEngine.Networking;
[DisallowMultipleComponent]
public class NetworkSpawnPosition : SceneDependencyBehaviour
{
public void Awake()
{
NetworkManager.RegisterStartPosition(transform);
private List<Player> m_ClientPlayerObjects = new List<Player>();
private bool m_HasSentGameSceneReady = false;
private bool ShouldSendGameSceneReady
{
get
{
return
AllPlayersReady && // are all the clients created + ready?
Player.LocalPlayer != null && // and we exist as a local player
m_HasSentGameSceneReady == false; // and we haven't already sent the message
using UnityEngine;
using System.Collections;
using UnityEditor;
public static class QuickPlay
{
private static string InitialScenePath
{
get
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public static class AssetBundleUtil
{
public static void FindAllAssetsInBundle( string assetBundleName )
{
List<Object> assets = new List<Object>();
@glitchersgames
glitchersgames / SplineVertexColors.cs
Last active September 3, 2017 11:17
Color a mesh based on progress along a 'spline' (read - series of unconnected transforms). Colors can be adjusted using curves. Do this in edit mode with a VertexColor shader/your custom one to see results live. WARNING: This affects the mesh directly so make sure to save a backup.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SplineVertexColors : MonoBehaviour {
#region Types
public enum Mode
{
ChannelCurves,