Skip to content

Instantly share code, notes, and snippets.

void imageTexture::LoadTexture()
{
if (tObject == 0) // We don't yet have an OpenGL texture target
{
// This code counts the number of images and if there are none simply
// returns without doing anything
int nImages = 0;
while (tName[nImages][0] != '\0' && nImages < MAX_IMAGES)
nImages++;
@cjacobwade
cjacobwade / DoorAnim
Created March 29, 2015 03:14
Saving references
Animator anim = null;
void Start()
{
// this saves a reference to the Animator
// way better because you don't have to do an expensive getcomponent each time
anim = GetComponent<Animator>();
}
void Update()
using UnityEngine;
using System.Collections;
public class WadeBehaviour : MonoBehaviour
{
Transform __transform = null;
protected Transform _transform
{
get
{
@cjacobwade
cjacobwade / CheapFlip.shader
Created August 18, 2015 21:19
#unity3d shader showing how to use the step function to avoid using if/else while splitting colors on a shape.
Shader "Custom/CheapFlip"
{
Properties
{
_ColorA ( "Color A", Color ) = ( 1, 1, 1, 1 )
_ColorB ( "Color B", Color ) = ( 1, 1, 1, 1 )
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
@cjacobwade
cjacobwade / CheapToggle.shader
Created August 18, 2015 21:22
#unity3d example showing how to add a checkbox to a shader property and use it to flip between colors.
Shader "Custom/CheapToggle"
{
Properties
{
_ColorA ( "Color A", Color ) = ( 1, 1, 1, 1 )
_ColorB ( "Color B", Color ) = ( 1, 1, 1, 1 )
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
Keywords (for each, explain it in a sentence or two, write a script showing its use case):
- virtual/override
- abstract
- sealed
- delegate
- action, func, predicate
- interface
- generics
- difference between a struct and class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextTweenIn : Text
{
List<Vector3> charCorners = new List<Vector3>();
List<float> _charScales = new List<float>();
using UnityEngine;
using System.Collections;
using System.IO;
public class ExportScreenshot : SingletonBehaviour<ExportScreenshot>
{
// You need to register your game or application in Twitter to get cosumer key and secret.
// Go to this page for registration: http://dev.twitter.com/apps/new
string CONSUMER_KEY = "FindYoursFromTwitter.com";
string CONSUMER_SECRET = "FindYoursFromTwitter.com";
using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Linq;
using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Linq;