Skip to content

Instantly share code, notes, and snippets.

View pacoelayudante's full-sized avatar

Paco pacoelayudante

View GitHub Profile
@pacoelayudante
pacoelayudante / AutoBuscarObjetoAttribute.cs
Last active October 15, 2023 01:35
despues la actualizao
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.SceneManagement;
#endif
///<summary>
@pacoelayudante
pacoelayudante / PlayerPrefsInspector.cs
Created April 2, 2022 17:21
Unity Decorator Drawer Attribute Display PlayerPrefs or EditorPrefs in the inspector (see comment for an example)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[System.AttributeUsage(System.AttributeTargets.Field, Inherited = true, AllowMultiple = true)]
public class PlayerPrefsInspector : PropertyAttribute
{
@pacoelayudante
pacoelayudante / KeepSat.shader
Created March 2, 2020 17:57
Colorea Shader Sin Perder Blanco
Shader "Sprites/KeepSat"
{
Properties
{
[PerRendererData] _MainTex ("Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_Exponente ("Exponente", Float) = 2.4
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
[MaterialToggle] Premultiply("Premultiply Alfa y Color", Int) = 1
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
@pacoelayudante
pacoelayudante / OcultadorAttributeDrawer.cs
Last active October 1, 2019 20:59
Este decorator es una forma facil y rapida de que los fields se oculten en el inspector dependiendo del valor de otros fields sin tener que hacer un Editor
// No esta funcionando como se espera al usar arrays (muestra array y oculta los children mas bien)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class OcultadorAttribute : PropertyAttribute
@pacoelayudante
pacoelayudante / AnimatorStringListAttributeDrawer.cs
Last active October 3, 2019 21:54
Attribute Drawer para generar un popup con los strings que existen en el animator (en vez de escribir a mano, por ahi despues muestro un gif clarificando)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using an = UnityEditor.Animations;
#endif
// el "Tipo que Listar" indica si busca los parametros o todos los estados del AnimatorController
// el "buscar en children" indica que se le permite buscar en sus hijos algun Animator (en vez de solo en si mismo)
@pacoelayudante
pacoelayudante / IdeaVariableLinker Unity
Last active November 23, 2018 19:20
Idea Variable Linker Unity
algo que vincule varias fields de un mismo tipo, cuando se modifica le avisa a les demas...
tiene zarpado peligro de entrar en un loop recursivo!
UnityEvent OnChange
UnityEvent<T> Check
T valor;
Suscribir ( (Color set)=> spriteRenderer.color = set , ()=> return spriteRenderer.color );
T Valor {
@pacoelayudante
pacoelayudante / SceneAssetPathAsStringAttributeDrawer.cs
Last active September 3, 2019 19:53
Unity: Un attributo para usar en strings, te lo muestra como selector de Asset de Escenas en el Inspector, (pero escribe el path a al escena o el nombre de la escena). ¡Funciona con Arrays!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class SceneAssetPathAsStringAttribute : PropertyAttribute
{
readonly bool incluirTodoElPath;
@pacoelayudante
pacoelayudante / CamSort.cs
Created November 16, 2017 23:53
Cambiar el sorting mode de la Camara de Unity
using UnityEngine;
using System.Collections;
public class CamSort : MonoBehaviour {
public TransparencySortMode sortMode = TransparencySortMode.Orthographic;
void OnValidate()
{
GetComponent<Camera>().transparencySortMode = sortMode;
}
@pacoelayudante
pacoelayudante / Pin.cs
Created November 10, 2017 01:39
Copia del Pin de Construct 2. Toma la posicion, rotacion y/o esacala de otro transform. Para cuando no te sirve o no alcanza hacer que sea relacion hijo-padre
/*
* Para esas veces que poner un objeto como hijo no alcanza o no sirve
*
*
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@pacoelayudante
pacoelayudante / ListaDeImagenes.cs
Created November 10, 2017 01:37
Un Scriptable Object (Asset) que basicamente es una lista de Sprites, con un Editor que lo muestra como Reorderable List. Ademas que se puede usar onda "ListaDeImagenes miLista; Sprite miSprite = miLista[2]" y Anda
/*
* Agradecimientos a
* Valentin Simonov https://twitter.com/valyard
* Unity: make your lists functional with ReorderableList
* http://va.lent.in/unity-make-your-lists-functional-with-reorderablelist/
*
*
*/
using System.Collections;