Skip to content

Instantly share code, notes, and snippets.

@shrinath-kopare
shrinath-kopare / ActionDemo.cs
Created June 5, 2018 14:03
Action, Delegate, Lambda expression and Callbacks in C#. I have created these scripts in Unity, so the only diff is that, starting point here is Start().
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class ActionDemo : MonoBehaviour {
void Start(){
Action<string> SampleAction; //action dont need an explicit delegate to be declared (Action is special kind of delegate which takes parameters but returns nothing)
@shrinath-kopare
shrinath-kopare / Anim.cs
Created January 29, 2018 14:38
Adding and controlling Animator Controller at runtime using script in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Anim : MonoBehaviour {
public GameObject cg;
public RuntimeAnimatorController animator;
void Start () {
cg.gameObject.AddComponent<Animator>();
cg.gameObject.GetComponent<Animator>().runtimeAnimatorController = animator;