Skip to content

Instantly share code, notes, and snippets.

@Marsgames
Marsgames / 81-C# Script-NewBehaviourScript.cs
Last active March 23, 2021 17:48
This is my own version of Unity MonoBehavior script Template
#region Author
/////////////////////////////////////////
// RAPHAEL DAUMAS --> #SCRIPTNAME#
// https://raphdaumas.wixsite.com/portfolio
// https://github.com/Marsgames
/////////////////////////////////////////
#endregion
using UnityEngine;
public class #SCRIPTNAME# : MonoBehaviour
@Marsgames
Marsgames / 01_Snippets_Unity.md
Last active October 26, 2023 08:47
Some useful functions snippet for Unity

Useful Unity snippets

A simple lerp from x value to y value in z seconds.

A function that allow a 2D GameObject to look at another GameObject, rotating only around Z axis.

A class (only 1 function is really important) that allow you to move a GameObject describing a simple Bezier curve (Only one tangent point).

@Marsgames
Marsgames / csc.rsp
Created November 28, 2019 17:06
Warnings as error for Unity (Just download this file and put it in your Assets folder)
-warnaserror+
@Marsgames
Marsgames / GameManager.cs
Last active September 2, 2020 07:48
Exemple of static Instance for a GameManager, SoundManager, etc... in Unity + GameManager version ready for ads
#region Author
/////////////////////////////////////////
// RAPHAËL DAUMAS --> GameManager
// https://raphdaumas.wixsite.com/portfolio
// https://github.com/Marsgames
/////////////////////////////////////////
#endregion
using UnityEngine;
[HelpURL("https://gist.github.com/Marsgames/f5808a289f2ee135ac08930937787c68")]
@Marsgames
Marsgames / .gitignore
Last active April 21, 2024 05:27
Generic Unity .gitignore (Ignores git, unity, macos, csharp, windows, visualstudio, visualstudiocode)
# Created by https://www.gitignore.io/api/git,unity,macos,csharp,windows,visualstudio,visualstudiocode
# Edit at https://www.gitignore.io/?templates=git,unity,macos,csharp,windows,visualstudio,visualstudiocode
### Csharp ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
@Marsgames
Marsgames / AutoSave.cs
Last active March 24, 2021 10:05
Put it in Assets/Editor. Automaticaly save scene every time you press play
using UnityEditor;
using UnityEngine;
using UnityEditor.SceneManagement;
[InitializeOnLoad, HelpURL("https://forum.unity.com/threads/we-need-auto-save-feature.483853")]
public static class AutoSave
{
/// <summary>
/// Static constructor that gets called when unity fires up.
/// </summary>
@Marsgames
Marsgames / MarioJump.cs
Last active January 31, 2020 17:17
Unity version of Mario jumping physics. If you get jump key down you jump higher than just a press
// Source : https://www.youtube.com/watch?v=7KiK0Aqtmzc
#region Variables
[SerializeField] private float jumpVelocity = 5;
[SerializeField] private float fallOffMultiplier = 2.5f;
[SerializeField] private float lowJumpMultiplier = 2;
private Rigidbody2D rigidbody;
#endregion Variables
@Marsgames
Marsgames / ICanRewind.cs
Last active November 5, 2020 21:40
A simple system to rewind time like in Prince of Persia
// Source : https://www.twitch.tv/videos/519292916?filter=all&sort=time
#region Author
/////////////////////////////////////////
// RAPHAËL DAUMAS --> ICanRewind
// https://raphdaumas.wixsite.com/portfolio
// https://github.com/Marsgames
/////////////////////////////////////////
#endregion
public interface ICanRewind
@Marsgames
Marsgames / Utils.cs
Last active October 7, 2020 13:58
Fonctions that can be usefull in all Unity projects (put this file into Assets/Editor folder)
#region Author
/////////////////////////////////////////
// RAPHAEL DAUMAS --> Utils
// https://raphdaumas.wixsite.com/portfolio
// https://github.com/Marsgames
/////////////////////////////////////////
#endregion
using System;
using System.Collections.Generic;
using System.Reflection;
@Marsgames
Marsgames / Guidelines.md
Last active February 15, 2024 09:06
Ce document présente les good practices que nous respectons au sein de Headcrab.

Programmation Guideline

Ce document présente les good practices que nous respectons au sein de Headcrab.

Quand vous clonez un projet Unity OU que vous créez un nouveau projet Unity, vérifiez que le fichier setup.py est présent et exécutez le avant toute chose.

General programming

  • Les noms des classes sont en PascalCase --> class MyClass
  • Les classes de base servant à l'héritage doivent avoir comme suffixe Base --> class PlayerBase