Skip to content

Instantly share code, notes, and snippets.

View romainPechot's full-sized avatar

Romain Péchot romainPechot

View GitHub Profile
@romainPechot
romainPechot / CircleLineRenderer.cs
Created August 19, 2015 14:37
Circle Line Renderer
[System.Serializable]
public class CirclelLineRenderer
{
[SerializeField]
private LineRenderer lineRenderer;
public LineRenderer LINE_RENDERER
{
get { return lineRenderer; }
set
@romainPechot
romainPechot / PaddleBounceDirectionController.cs
Last active October 1, 2015 12:05
simple paddle bounce controller for arkanoid like game
using UnityEngine;
using System.Collections;
public class PaddleBounceDirectionController : MonoBehaviour
{
[SerializeField]
private Transform bounceSurface;
[SerializeField]
private float bounceSurfaceLength = 2f;
@romainPechot
romainPechot / DualMap.shader
Last active February 7, 2020 07:55
Dual Maps Shader. Use last texture like a filter. Show first texture if pixel transparent, second if pixel is full visible (crossfade if value is inbetween)
Shader "DualMaps"
{
Properties
{
_MainTex("Main (RGB)", 2D) = "black" {}
_SecTex("Main (RGB)", 2D) = "white" {}
_FilTex("Filter (Alpha)", 2D) = "black"{}
}
SubShader
@romainPechot
romainPechot / ComponentsViewer.cs
Created October 9, 2015 13:05
Unity EditorWindow to show how many components there is inside a gameObject hierarchy (put the script inside an "Editor" folder)
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class ComponentsViewer : EditorWindow
{
[MenuItem("Window/Help/GameObject/Components Viewer")]
private static void Init()
@romainPechot
romainPechot / ClearPlayerPrefs.cs
Created October 10, 2015 10:52
Quick Unity Editor Tool for cleaning ALL the PlayerPrefs
using UnityEngine;
using UnityEditor;
public class ClearPlayerPrefs
{
[MenuItem("Tools/Clear PlayerPrefs")]
private static void ClearAllPlayerPrefs()
{
if(EditorUtility.DisplayDialog("Clear ALL PlayerPrefs", "Do you really want to clear ALL the PlayerPrefs\nof this project ?\n\nYou cannot undo this action.", "Yep", "Nah"))
{
@romainPechot
romainPechot / ReadOnlyInspector.cs
Last active October 21, 2015 12:09
[ReadOnly] attribute. Combined with [SerializeField] on a private variable.
using UnityEngine;
// put this script inside your Scripts folder.
public class ReadOnlyInspector : PropertyAttribute { }
@romainPechot
romainPechot / ReadOnlyInspectorDrawer.cs
Last active October 21, 2015 12:09
ReadOnlyDrawer for the [ReadOnlyInspector] PropertyAttribute
using UnityEngine;
using UnityEditor;
// put this script inside an Editor folder.
[CustomPropertyDrawer(typeof(ReadOnlyInspector))]
public class ReadOnlyInspectorDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
@romainPechot
romainPechot / ReplaceMesh.cs
Created November 18, 2015 17:14
Unity Editor Script Replace Mesh
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
public class ReplaceMesh : EditorWindow
{
[MenuItem("Window/Help/Mesh/Replace")]
private static void Init()
{
@romainPechot
romainPechot / SkinnedMeshRendererMerger.cs
Created December 8, 2015 15:30
Quick tool for batching a lot of small meshes inside a SkinnedMesh. The genuine meshes have to use the same Material because of the SkinnedMeshRenderer.
using UnityEngine;
using UnityEngine.Rendering;
using System.Collections.Generic;
[System.Serializable]
public class RendererShadowLightSetup
{
[SerializeField]
private ShadowCastingMode shadowCastingMode = ShadowCastingMode.TwoSided;
public ShadowCastingMode SHADOW_CASTIN_MODE { get { return shadowCastingMode; } }
@romainPechot
romainPechot / MenuItemTransformHierarchyFindPath.cs
Created March 13, 2016 16:04
MenuItem for quick copy/paste a Transform hierarchy inside a Unity Scene
using UnityEngine;
using UnityEditor;
public static class MenuItemTransformHierarchyFindPath
{
[MenuItem("CONTEXT/Transform/Copy Transform Path")]
private static void CopySelectionPath(MenuCommand cmd)
{
if(cmd.context)
{