Skip to content

Commit

Permalink
Reactivate Generator function in Unity 2018.4. (#106)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Ramberg <adam@mambojambostudios.com>
  • Loading branch information
fakegood and AdamRamberg committed Feb 23, 2020
1 parent e2fb8ce commit 5f66ed0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Packages/Core/Editor/Generator/Generator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_2019_1_OR_NEWER
#if UNITY_2018_4_OR_NEWER
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -56,8 +56,9 @@ public void Generate(string type, string baseWritePath, bool isEquatable, List<A

// Recursively search for template files. TODO: Is there a better way to find and load templates?
var templateSearchPath = Runtime.IsUnityAtomsRepo ?
Directory.GetParent(baseWritePath).FullName : // "Packages"
Directory.GetParent(Application.dataPath).Parent.FullName : // "Packages"
Directory.GetParent(Application.dataPath).FullName;

var templatePaths = Directory.GetFiles(templateSearchPath, "UA_Template*.txt", SearchOption.AllDirectories);
var templateConditions = new List<string>();
if (isEquatable) { templateConditions.Add("EQUATABLE"); }
Expand Down
13 changes: 11 additions & 2 deletions Packages/Core/Editor/Generator/GeneratorEditor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#if UNITY_2019_1_OR_NEWER
#if UNITY_2018_4_OR_NEWER
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;
#elif UNITY_2018_4_OR_NEWER
using UnityEditor.Experimental.UIElements;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleEnums;
#endif

namespace UnityAtoms.Editor
{
Expand Down Expand Up @@ -146,8 +152,11 @@ private void OnEnable()
AtomTypes.VARIABLE
};
generator = generator == null ? new Generator() : generator;

#if UNITY_2019_1_OR_NEWER
var root = this.rootVisualElement;
#elif UNITY_2018_4_OR_NEWER
var root = this.GetRootVisualContainer();
#endif
var pathRow = new VisualElement() { style = { flexDirection = FlexDirection.Row } };
pathRow.Add(new Label() { text = "Relative Write Path", style = { width = 180, marginRight = 8 } });
var textfield = new TextField() { value = _writePath, style = { flexGrow = 1 } };
Expand Down
2 changes: 1 addition & 1 deletion Packages/Core/Editor/Generator/RegenerateAllAtoms.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_2019_1_OR_NEWER
#if UNITY_2018_4_OR_NEWER
using System;
using System.Linq;
using System.Collections.Generic;
Expand Down

0 comments on commit 5f66ed0

Please sign in to comment.