You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
828 B
41 lines
828 B
10 years ago
|
using UnityEngine;
|
||
|
using UnityEditor;
|
||
10 years ago
|
using System.IO;
|
||
10 years ago
|
using System.Collections;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
|
|
||
10 years ago
|
public class FlowchartMenuItems
|
||
10 years ago
|
{
|
||
10 years ago
|
[MenuItem("Tools/Fungus/Create/Flowchart", false, 0)]
|
||
|
static void CreateFlowchart()
|
||
10 years ago
|
{
|
||
10 years ago
|
SpawnPrefab("Flowchart");
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
public static GameObject SpawnPrefab(string prefabName)
|
||
10 years ago
|
{
|
||
10 years ago
|
GameObject prefab = Resources.Load<GameObject>(prefabName);
|
||
10 years ago
|
if (prefab == null)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
|
||
10 years ago
|
|
||
10 years ago
|
Camera sceneCam = SceneView.currentDrawingSceneView.camera;
|
||
|
|
||
|
Vector3 pos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f));
|
||
|
pos.z = 0f;
|
||
|
go.transform.position = pos;
|
||
|
|
||
|
Selection.activeGameObject = go;
|
||
|
|
||
|
Undo.RegisterCreatedObjectUndo(go, "Create Object");
|
||
|
|
||
|
return go;
|
||
|
}
|
||
10 years ago
|
}
|
||
|
|
||
|
}
|