Skip to content

Instantly share code, notes, and snippets.

@SradnickDev
SradnickDev / AutoVersion.cs
Created May 4, 2019 14:52
Auto Increment Version (Unity 3D 2019)
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
public class AutoVersion : IPreprocessBuildWithReport
{
public int callbackOrder
{
@SradnickDev
SradnickDev / Timer.cs
Created June 14, 2019 11:23
Timer using Photon Unity Network / Pun 2
using System;
using ExitGames.Client.Photon;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
/// <summary>
/// PhotonNetwork Timer, using Photon Events(RaiseEvents).
/// Call Initialize() as soon as the Timer should react to Photon Callbacks(RaiseEvents), Deinitialize if not needed.
/// Every Client should Update the Timer : timer.Update(Time.deltaTime)
@SradnickDev
SradnickDev / SyncPlayerPropertyAgent.cs
Created September 4, 2019 09:31
Abstract way to deal with Player Propertiy changes. Simply connect a method that is interest in changes for a specific property. https://ibb.co/Qc6VKNK
using System.Collections;
using System.Collections.Generic;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.Events;
using Hashtable = ExitGames.Client.Photon.Hashtable;
public struct PropertyData
{
@SradnickDev
SradnickDev / DarkTheme.cs
Created September 9, 2019 17:18 — forked from instance-id/DarkTheme.cs
Legit/Legal Unity 2019.3.0bx beta dark theme one click converter
// --- instance.id ------------------------------------------------------------
// Thanks to TheZombieKiller and Peter77 for creating this
// https://forum.unity.com/threads/editor-skinning-thread.711059/#post-4785434
// Tested on Unity 2019.3.0b1 - 95% Dark mode Conversion
// Example Screenshot - https://i.imgur.com/9q5VPQk.png
// (Note - Once I ran this, I had to hit play and then it took effect)
// ----------------------------------------------------------------------------
using System;
using System.Text.RegularExpressions;
@SradnickDev
SradnickDev / HttpServer.cs
Last active June 14, 2020 08:42
HttpServer
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading;
namespace Websocket
{
public class HttpServer
{
@SradnickDev
SradnickDev / SerializedScriptableObject.cs
Last active June 24, 2020 21:09
SerializedScriptableObject allows to serialize stuff that unity cant like, inheritance for custom classes in e.g in lists. With the use of https://www.newtonsoft.com/json
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine;
namespace Core.Utilities
{
/// <summary>
/// To extend Unity's serialization process.
/// Unity cant serializes inheritance properly e.g in a list of base types, adding an inherited class won’t be serialized as it.
@SradnickDev
SradnickDev / ResharperExclude.ps1
Last active July 5, 2020 17:13
Powershell script that apply resharper recommendations and exclude certain files and folders from windows defender.
[Collections.ArrayList]$vsFolders = @()
[Collections.ArrayList]$excludedFolders = @("$env:LOCALAPPDATA\JetBrains\Transient")
[Collections.ArrayList]$excludedFiles = @()
$vsVersions = @('2017', '2018', '2019')
Function Invoke-AsAdmin()
{
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator'))
{
@SradnickDev
SradnickDev / DeferredExecutor.cs
Last active September 1, 2021 23:58
Delay calls by time or frames, alternative for coroutines and Monobehaviour.Invoke.
using System.Collections.Generic;
using UnityEngine;
public interface IDeferredAction
{
void OnExecuteDeferred(byte iKey);
}
/// <summary>
/// Delay method calls by time,frame and/or execute repeatedly.
@SradnickDev
SradnickDev / MessageHub.cs
Last active April 7, 2022 01:48
Static generic message hub / message system.
using System;
using System.Collections.Generic;
using UnityEngine;
public interface IMessage { }
public static class MessageHub
{
public delegate void MessageSubscription<in T>(T message) where T : IMessage;