Skip to content

Instantly share code, notes, and snippets.

View TheOctan's full-sized avatar
🎮

Timofey Kanatush TheOctan

🎮
View GitHub Profile
using UnityEngine;
namespace HappyCanvas.Scripts.Components.Common
{
public class DontDestroyOnLoadComponent : MonoBehaviour
{
protected void Awake()
{
DontDestroyOnLoad(this);
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[RequireComponent(typeof(Canvas))]
public class CanvasHelper : MonoBehaviour
{
private static List<CanvasHelper> helpers = new List<CanvasHelper>();
public static UnityEvent OnResolutionOrOrientationChanged = new UnityEvent();
@TheOctan
TheOctan / SceneGenerator.cs
Created July 23, 2021 13:25
Generates scene with Hierarchy 2 asset
using Hierarchy2;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
namespace OctanGames
{
@TheOctan
TheOctan / ScriptInfoEditor.cs
Last active July 23, 2021 13:26
Generates script template
using System;
using System.IO;
using UnityEditor;
namespace OctanGames
{
public class ScriptInfoEditor : UnityEditor.AssetModificationProcessor
{
public const string authorName = "TheOctan";
@TheOctan
TheOctan / CreateProjectTree.cs
Created April 28, 2021 19:18
Generates Unity project structure
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System.IO;
namespace ProjectTreeGenerator
{
class Folder
{
public string DirPath { get; private set; }
@TheOctan
TheOctan / UIBillboard.cs
Last active March 29, 2021 14:42
UI Billboard
using UnityEngine;
[ExecuteAlways]
public class UIBillboard : MonoBehaviour
{
public bool flipVerticalOrientation = true;
private Transform cameraTransform;
private void OnEnable()
public class SafeArea : MonoBehaviour
{
[SerializeField] private float _safeAreaMargin = 40f;
[Tooltip("Conform to screen safe area on X-axis (default true, disable to ignore)")]
[SerializeField] private bool _conformX = true;
[Tooltip("Conform to screen safe area on Y-axis (default true, disable to ignore)")]
[SerializeField] private bool _conformY = true;
[SerializeField] private bool _isSymmetrical = true;
using UnityEngine;
using UnityEngine.Events;
public class CharacterController2D : MonoBehaviour
{
[SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps.
[Range(0, 1)] [SerializeField] private float m_CrouchSpeed = .36f; // Amount of maxSpeed applied to crouching movement. 1 = 100%
[Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement
[SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping;
[SerializeField] private LayerMask m_WhatIsGround; // A mask determining what is ground to the character
using UnityEngine;
namespace Eccentric
{
[AddComponentMenu("Camera/CameraMove")]
public class CameraMove : MonoBehaviour
{
[SerializeField] private float mouseSensitivity = 0.4f;
[SerializeField] private float moveSpeed = 20f;
[Range(1, 10), SerializeField] private float shiftMultiplier = 3.7f;
@TheOctan
TheOctan / Crypt.cs
Last active May 29, 2021 17:37
Generates hash code
using System;
using System.Security.Cryptography;
using System.Text;
namespace Cryptography
{
public enum HashAlgorithmType
{
MD5 = 0,
SHA1 = 1,