Skip to content

Instantly share code, notes, and snippets.

View jfranmora's full-sized avatar

JfranMora jfranmora

View GitHub Profile
@jfranmora
jfranmora / RemoveMobileWarningWebGL.cs
Last active September 20, 2019 12:15
PostBuildAction to Remove Mobile Warning in WebGL builds
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
public class RemoveMobileWarningWebGL
{
private const string JS_EXTENSION = ".js";
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string targetPath)
@jfranmora
jfranmora / UIExtensions.cs
Created July 16, 2019 19:00
Extension for Unity.UI.Toggle to set isOn value without send callbacks
using System.Reflection;
using UnityEngine.UI;
public static class UIExtensions
{
private static readonly MethodInfo toggleMethod;
static UIExtensions()
{
toggleMethod = GetSetMethod(typeof(Toggle));
@jfranmora
jfranmora / CompileBeforePlay.cs
Last active June 25, 2020 08:47
Editor extension, automatically triggers a compilation when entering play mode.
using UnityEditor;
namespace JfranMora
{
public static class CompileBeforePlay
{
[InitializeOnLoadMethod]
public static void Initialize()
{
if (EditorApplication.isPlaying) return;
@jfranmora
jfranmora / StringTagExt.cs
Last active June 26, 2022 13:52
Extension class to use rich text in Unity Console. https://docs.unity3d.com/Manual/StyledText.html
public static class StringTagExt
{
public static string AddBoldTag(this string text)
{
return text.AddTag("b");
}
public static string AddItalicTag(this string text)
{
return text.AddTag("i");
@jfranmora
jfranmora / AnimatorEventsGenerator.cs
Created June 26, 2018 20:47
Function to autogenerate a script with the events of an animator as Unity Events ^^ (Works for events with 0 arguments)
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
public class AnimatorEventsGenerator
{
private const string ScriptTemplate = "// AUTOGENERATED CODE: {CLASSNAME}\n" +
"\nusing UnityEngine;" +
@jfranmora
jfranmora / DebugDrawGameObjectMesh.cs
Last active February 21, 2017 13:23
Debug meshes
using UnityEngine;
public class DebugDrawGameObjectMesh : MonoBehaviour
{
[Header("Configuration")]
[Space]
public bool drawWireMesh = true;
public Color wireColor = new Color(0, 0, 0, .8f);