Skip to content

Instantly share code, notes, and snippets.

View romainPechot's full-sized avatar

Romain Péchot romainPechot

View GitHub Profile
using UnityEngine;
[ExecuteInEditMode]
public class CameraController : MonoBehaviour
{
public Transform target = null;
public float distanceFromTarget = 10.0f;
public float elevationFromTarget = 5.0f;
@romainPechot
romainPechot / SceneHierarchyWindowUtility.cs
Last active July 3, 2019 13:02
Generic SceneHierarchyWindow static utility methods.
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
public static class SceneHierarchyWindowUtility
{
@romainPechot
romainPechot / OrbitPivot.cs
Created December 19, 2016 23:11
3rd Camera Scripts
using UnityEngine;
public class OrbitPivot : MonoBehaviour
{
public float sensitivity = 10f;
private void LateUpdate()
{
if(Input.GetMouseButton(1))
@romainPechot
romainPechot / InspectorButtonAttribute.cs
Created December 6, 2016 17:09
Custom Tweak Propertie Attribute Add Button to Inspector w/out complete CustomInspector (put InspectorButtonPropertyDrawer.cs inside an Editor folder)
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
// format from this thread : https://www.reddit.com/r/Unity3D/comments/1s6czv/inspectorbutton_add_a_custom_button_to_your/
[System.AttributeUsage(System.AttributeTargets.Field)]
public class InspectorButtonAttribute : PropertyAttribute
{
@romainPechot
romainPechot / ArrayExtensions.cs
Created November 28, 2016 13:00
Array Extensions
using System.Collections.Generic;
using UnityEngine;
public static class ArrayExtensions
{
public static T GetRandom<T>(this T[] array)
{
return array[Random.Range(0, array.Length - 1)];
@romainPechot
romainPechot / CameraBackgroundSetup.cs
Last active November 11, 2016 11:47
CameraBackgroundSetup (ScriptableObject)
using UnityEngine;
public enum eBackgroundType
{
Skybox = 0,
Color = 1
}
@romainPechot
romainPechot / ProgressBarAttribute.cs
Last active October 11, 2016 11:57
Progress Bar Attribute/Drawer for Unity float Inspector
using UnityEngine;
public class ProgressBarAttribute : PropertyAttribute
{
public string name = "Float";
public ProgressBarAttribute(string name)
{
this.name = name;
@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)
{
@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 / 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()
{