Tanoda
GeneratorEditor.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System;
10using UnityEngine;
11using UnityEditor;
12
13namespace Leap.Unity.Generation {
14
15 [CanEditMultipleObjects]
16 [CustomEditor(typeof(GeneratorBase), editorForChildClasses: true)]
17 public class GeneratorEditor : CustomEditorBase<GeneratorBase> {
18
19 [MenuItem("Assets/Run All Generators")]
20 public static void TriggerGeneration() {
21 int successfulGenerators = 0;
22 int failedGenerators = 0;
23 foreach (var gen in EditorResources.FindAllAssetsOfType<GeneratorBase>()) {
24 try {
25 gen.Generate();
26 successfulGenerators++;
27 } catch (Exception e) {
28 Debug.LogException(e);
29 failedGenerators++;
30 }
31 }
32
33 if (successfulGenerators == 1) {
34 Debug.Log("Successfully ran 1 generator.");
35 } else if (successfulGenerators > 1) {
36 Debug.Log("Successfully ran " + successfulGenerators + " generators.");
37 }
38
39 if (failedGenerators == 1) {
40 Debug.LogError("1 generator failed to run.");
41 } else if (failedGenerators > 1) {
42 Debug.LogError(failedGenerators + " generators failed to run.");
43 }
44
45 AssetDatabase.Refresh();
46 AssetDatabase.SaveAssets();
47 }
48
49 protected override void OnEnable() {
50 base.OnEnable();
51
53 }
54
55 public override void OnInspectorGUI() {
57
58 if (GUILayout.Button("Generate")) {
59 foreach (var target in targets) {
60 target.Generate();
61 }
62
63 AssetDatabase.Refresh();
64 AssetDatabase.SaveAssets();
65 }
66
67 base.OnInspectorGUI();
68 }
69 }
70}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19