Skip to content

Instantly share code, notes, and snippets.

@Koroeskohr
Created February 28, 2017 10:49
Show Gist options
  • Save Koroeskohr/9acbb1d0049cd54ff076e3634fd7e9b1 to your computer and use it in GitHub Desktop.
Save Koroeskohr/9acbb1d0049cd54ff076e3634fd7e9b1 to your computer and use it in GitHub Desktop.
Instantiate object in scene Unity (GUI)
var canvas3D = FindCanvas3D();
if (canvas3D == null) throw new System.Exception(TODO);
var gizmo = Instantiate(Resources.Load<GameObject>("GizmoLine"));
gizmo.transform.SetParent(canvas3D.transform);
gizmo.transform.localScale = TODO;
static Canvas FindCanvas3D() {
var canvas = FindObjectsOfType<Canvas>();
foreach (var c in canvas) {
if (c.name == "Canvas3D") return c;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment