Skip to content

Instantly share code, notes, and snippets.

@talecrafter
talecrafter / AtlasFileRenamer.cs
Last active Dec 29, 2015
Unity3D Editor Script that renames .atlas files on import to .atlas.txt. Put this script in an "Editor" subfolder.
View AtlasFileRenamer.cs
using UnityEngine;
using UnityEditor;
using System.IO;
/// <summary>
/// editor script that renames imported .atlas files to .atlas.txt files
/// </summary>
public class AtlasFileRenamer : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
@talecrafter
talecrafter / Open.bat
Created Mar 5, 2014
Windows batch file that opens Unity project and C# solution
View Open.bat
@echo off
:: find first filename with *csharp.sln
FOR %%F IN (*csharp.sln) DO (
set filename=%%F
goto filenamefound
)
:: no csharp solution found, skip to opening unity
goto openunity
View ListExtensions.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class ListExtensions
{
public static T PickRandom<T>(this IList<T> source)
{
if (source.Count == 0)
return default(T);
View ExampleGameInput.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using CraftingLegends.Framework;
using CraftingLegends.Core;
using System;
using CraftingLegends.ExtendedFramework;
/// <summary>
/// short example class showing how you can adapt to user switching control scheme
View 81-C# Script-NewBehaviourScript.cs.txt
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using Random = UnityEngine.Random;
public class #SCRIPTNAME# : MonoBehaviour
{
void Start()
{
View SpriteImportProcessor.cs
using UnityEngine;
using UnityEditor;
using System.IO;
// example PostProcessor for adjusting automatic Sprite Import settings
// save this in any "Editor" Folder
public class SpriteImportProcessor : AssetPostprocessor
{
void OnPostprocessSprites(Texture2D texture, Sprite[] sprites)
{
View ColorToCSharp.cs
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
public class ColorToCSharp : EditorWindow
{
[SerializeField]
private bool _usedColorPickerOnce = false;
View PivotUtilities.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
public static class PivotUtilities
{
[MenuItem("GameObject/Pivot/Create Pivot", false, 0)]
static void CreatePivotObject()
{
View Sprites-PixelArt.shader
/*
Basic Sprite Shader for aligning pixel art to the same grid, based on the Unity Sprite Shader.
Create one Material where you assign the same Pixels Per Unit value you use on your imported Sprites,
then reuse this Material on all appropriate Sprite Renderers.
(You can use Shader.SetGlobalFloat to set that Pixels Per Unit value for all your shaders:
https://docs.unity3d.com/ScriptReference/Shader.SetGlobalFloat.html)
This is not for scaled or rotated artwork. If you need those features, look at low res render textures.
Use this however you want.
View TestScriptWithReorderableList.cs
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditorInternal;
#endif