Skip to content

Instantly share code, notes, and snippets.

@arunkarnann
Created October 27, 2016 14:15
Show Gist options
  • Save arunkarnann/e2b844bfe391524cd4fa263a91e3b3aa to your computer and use it in GitHub Desktop.
Save arunkarnann/e2b844bfe391524cd4fa263a91e3b3aa to your computer and use it in GitHub Desktop.
A simple Unity3D Editor script to toggle canvas setactive. Useful when you want to design something in Editor and often messing up by selecting canvas instead of objects.
using UnityEngine;
using System.Collections;
using UnityEditor;
public class CanvasToggler : Editor {
public static GameObject[] canvases = GameObject.FindGameObjectsWithTag("Canvas") as GameObject[];
[MenuItem("Editor Tools/Toggle canvas")]
static void ActivateOrDeactivate(){
foreach( GameObject i in canvases){
i.gameObject.SetActive(!i.gameObject.activeSelf);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment