Skip to content

Commit

Permalink
add setip test to enable disable qol fishnet attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
stilnat committed Aug 24, 2023
1 parent d7ff534 commit 7896c2a
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Assets/Scripts/Tests/Edit Mode/SetUpTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace EditorTests
{
[SetUpFixture]
public class SetUpTest
{

private const string QOL_ATTRIBUTES_DEFINE = "DISABLE_QOL_ATTRIBUTES";

[OneTimeSetUp]
public void RunBeforeAnyTests()
{
bool result = RemoveOrAddDefine(QOL_ATTRIBUTES_DEFINE, true);
}

[OneTimeTearDown]
public void RunAfterAnyTests()
{
bool result = RemoveOrAddDefine(QOL_ATTRIBUTES_DEFINE, false);
}

private static bool RemoveOrAddDefine(string define, bool removeDefine)
{
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
HashSet<string> definesHs = new HashSet<string>();
string[] currentArr = currentDefines.Split(';');

//Add any define which doesn't contain MIRROR.
foreach (string item in currentArr)
definesHs.Add(item);

int startingCount = definesHs.Count;

if (removeDefine)
definesHs.Remove(define);
else
definesHs.Add(define);

bool modified = (definesHs.Count != startingCount);
if (modified)
{
string changedDefines = string.Join(";", definesHs);
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, changedDefines);
}

return modified;
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Tests/Edit Mode/SetUpTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7896c2a

Please sign in to comment.