fishbait/UnityProject/Assets/FishNet/Runtime/Editor/ScriptingDefines.cs
NIMFER bf403a8f97 Ducktaped together a FishNet version of the Transport
Ducktaped together a FishNet version of the Transport, now I need to edit the LoadBalancer and Server so it connects and actually trades information
2022-08-14 03:55:25 +02:00

50 lines
No EOL
1.8 KiB
C#

#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace FishNet
{
internal static class ScriptingDefines
{
[InitializeOnLoadMethod]
public static void AddDefineSymbols()
{
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
/* Convert current defines into a hashset. This is so we can
* determine if any of our defines were added. Only save playersettings
* when a define is added. */
HashSet<string> definesHs = new HashSet<string>();
string[] currentArr = currentDefines.Split(';');
//Add current defines into hs.
foreach (string item in currentArr)
definesHs.Add(item);
string proDefine = "FISHNET_PRO";
string[] fishNetDefines = new string[]
{
"FISHNET",
};
bool modified = false;
//Now add FN defines.
foreach (string item in fishNetDefines)
modified |= definesHs.Add(item);
/* Remove pro define if not on pro. This might look a little
* funny because the code below varies depending on if pro or not. */
#pragma warning disable CS0162 // Unreachable code detected
modified |= definesHs.Remove(proDefine);
#pragma warning restore CS0162 // Unreachable code detected
if (modified)
{
Debug.Log("Added Fish-Networking defines to player settings.");
string changedDefines = string.Join(";", definesHs);
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, changedDefines);
}
}
}
}
#endif