Skip to content

Instantly share code, notes, and snippets.

@rutcreate
rutcreate / ProcessBuild.cs
Created October 19, 2015 05:01
Unity3D: Example of post process build
using UnityEditor;
using UnityEditor.Callbacks;
using System.Diagnostics;
using System.IO;
public static class ProcessBuild
{
[PostProcessBuild(1000)]
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
@rutcreate
rutcreate / BaseField.cs
Last active September 8, 2015 03:32
Unity3D: Basic Editor Field
[System.Serializable]
public class BaseField<T> {
public string name;
public T value;
public Field(string name) {
this.name = name;
this.value = default(T);
@rutcreate
rutcreate / GUIControlEditorWindow.cs
Created July 25, 2015 01:56
Unity3D: GUI control name explanation.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class GUIControlEditorWindow : EditorWindow {
[MenuItem("Window/GUIControl Test")]
public static void OpenGUIControlEditorWindow() {
EditorWindow.GetWindow<GUIControlEditorWindow>();
}
@rutcreate
rutcreate / ExampleRotate.cs
Created June 16, 2015 03:14
Unity3D: Rotate specific angle
using UnityEngine;
using System.Collections;
namespace Opendream {
public class ExampleRotate : MonoBehaviour {
public Transform m_Transform;
public Vector3 angle;
@rutcreate
rutcreate / CustomEditorWindow.cs
Last active October 3, 2016 11:13
Unity3D: Master-detail layout in custom editor.
using UnityEngine;
using UnityEditor;
using System.Collections;
using Opendream.Layouts;
namespace Opendream {
public partial class CustomEditorWindow : EditorWindow {
[MenuItem("Window/Custom Editor", false, 2)]
@rutcreate
rutcreate / StringExample.cs
Created June 15, 2015 03:02
Unity3D: String extension ToInt(), ToFloat(), ToBool(), BetterFormat().
public class StringExample {
private int intFromString;
private float floatFromString;
private bool boolFromString;
private string format = "Hi {Name} {Last}, I'm {Age} years old. I'm from {Country}.";
@rutcreate
rutcreate / CameraLayout.cs
Created May 30, 2015 10:33
Unity3d: 2D Pixel Perfect Camera
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
namespace RutCreate {
[ExecuteInEditMode]
public class CameraLayout : MonoBehaviour {
public Vector2 referenceResolution = new Vector2(800f, 600f);
@rutcreate
rutcreate / MyButton.cs
Last active March 11, 2024 00:02
Unity3D: Best way to add listener programmatically for Button onClick
using UnityEngine;
public class MyButton {
public Button[] buttons;
private void Start() {
for (int i = 0; i < buttons.Length; i++) {
Button button = buttons[i];
var index = i;
@rutcreate
rutcreate / SceneManager.cs
Last active March 21, 2020 00:27
Unity3D: Scene Manager (Loading asynchronously)
using UnityEngine;
public class SceneManager : MonoBehaviour {
private const string LOADING_LEVEL_KEY = "Loading Level";
private static AsyncOperation operation;
public float delayBefore = 0.5f;
@rutcreate
rutcreate / MyProperty.cs
Created May 19, 2015 02:29
Unity3D Editor : How to get other fields in PropertyDrawer.OnGUI
using UnityEngine;
public class MyProperty : PropertyAttribute {
public int intValue = 33;
public float floatValue = 12.5f;
public bool boolValue = true;