diff --git a/Allocators/IAllocator.cs b/Allocators/IAllocator.cs index 5530049..2729488 100644 --- a/Allocators/IAllocator.cs +++ b/Allocators/IAllocator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; namespace ProfilerDataExporter { @@ -9,4 +10,4 @@ public interface IAllocator void Free(IList elements); } } - +#endif diff --git a/Allocators/ListPool.cs b/Allocators/ListPool.cs index 8ab43d5..30021bc 100644 --- a/Allocators/ListPool.cs +++ b/Allocators/ListPool.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Collections.Generic; namespace ProfilerDataExporter @@ -17,4 +18,4 @@ public override void Free(List element) } } } - +#endif diff --git a/Allocators/ObjectPool.cs b/Allocators/ObjectPool.cs index 650491e..c165b8a 100644 --- a/Allocators/ObjectPool.cs +++ b/Allocators/ObjectPool.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Collections.Generic; namespace ProfilerDataExporter @@ -57,4 +58,4 @@ public void Free(IList elements) } } } - +#endif diff --git a/Factories/BaseFactory.cs b/Factories/BaseFactory.cs index d73c463..c6fd2e9 100644 --- a/Factories/BaseFactory.cs +++ b/Factories/BaseFactory.cs @@ -1,4 +1,5 @@ -namespace ProfilerDataExporter +#if UNITY_EDITOR +namespace ProfilerDataExporter { public class BaseFactory : IFactory where T : new() @@ -10,4 +11,4 @@ public T Create() } } } - +#endif diff --git a/Factories/IFactory.cs b/Factories/IFactory.cs index d6a343e..0b64849 100644 --- a/Factories/IFactory.cs +++ b/Factories/IFactory.cs @@ -1,8 +1,9 @@ -namespace ProfilerDataExporter +#if UNITY_EDITOR +namespace ProfilerDataExporter { public interface IFactory { T Create(); } } - +#endif diff --git a/Factories/ListFactory.cs b/Factories/ListFactory.cs index 8a478d7..ad00945 100644 --- a/Factories/ListFactory.cs +++ b/Factories/ListFactory.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Collections.Generic; namespace ProfilerDataExporter @@ -28,4 +29,4 @@ public List Create() } } } - +#endif diff --git a/FunctionTableState.cs b/FunctionTableState.cs index 6047f9a..3b06131 100644 --- a/FunctionTableState.cs +++ b/FunctionTableState.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; #if !UNITY_2019_1_OR_NEWER using UnityEditorInternal.Profiling; #endif @@ -70,3 +71,4 @@ string TableGUILayout.ITableState.SortHeader } } } +#endif \ No newline at end of file diff --git a/ProfilerData.cs b/ProfilerData.cs index ddac03b..eba0df9 100644 --- a/ProfilerData.cs +++ b/ProfilerData.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Collections.Generic; using UnityEditorInternal; #if !UNITY_2019_1_OR_NEWER @@ -196,4 +197,5 @@ public void Clear() value = string.Empty; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/ProfilerDataExporter.cs b/ProfilerDataExporter.cs index 4423aff..485638c 100644 --- a/ProfilerDataExporter.cs +++ b/ProfilerDataExporter.cs @@ -1,4 +1,5 @@ -using UnityEngine; +#if UNITY_EDITOR +using UnityEngine; using UnityEditor; using UnityEditorInternal; #if !UNITY_2019_1_OR_NEWER @@ -268,5 +269,5 @@ private void ExtractData(int firstFrameIndex, int lastFrameIndex, string selecte profilerData.Clear(); } } - -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/StatsCalculator/AvgStatsCalculator.cs b/StatsCalculator/AvgStatsCalculator.cs index 236d9fb..9927248 100644 --- a/StatsCalculator/AvgStatsCalculator.cs +++ b/StatsCalculator/AvgStatsCalculator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; namespace ProfilerDataExporter { @@ -14,4 +15,5 @@ protected override float AggregateValues(IList values) return sum / values.Count; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/StatsCalculator/MaxStatsCalculator.cs b/StatsCalculator/MaxStatsCalculator.cs index 3d9e246..51dc416 100644 --- a/StatsCalculator/MaxStatsCalculator.cs +++ b/StatsCalculator/MaxStatsCalculator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; namespace ProfilerDataExporter { @@ -18,4 +19,5 @@ protected override float AggregateValues(IList values) return max; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/StatsCalculator/MinStatsCalculator.cs b/StatsCalculator/MinStatsCalculator.cs index 1f76212..79070cd 100644 --- a/StatsCalculator/MinStatsCalculator.cs +++ b/StatsCalculator/MinStatsCalculator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; namespace ProfilerDataExporter { @@ -18,4 +19,5 @@ protected override float AggregateValues(IList values) return min; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/StatsCalculator/StatsCalculatorBase.cs b/StatsCalculator/StatsCalculatorBase.cs index b044fbc..55f3af4 100644 --- a/StatsCalculator/StatsCalculatorBase.cs +++ b/StatsCalculator/StatsCalculatorBase.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Collections.Generic; using UnityEditorInternal; #if !UNITY_2019_1_OR_NEWER @@ -139,4 +140,5 @@ private FunctionDataValue GetValue(IList framesData, ProfilerColum protected abstract float AggregateValues(IList values); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/StatsCalculator/StatsCalculatorProvider.cs b/StatsCalculator/StatsCalculatorProvider.cs index a4b911a..1f38fc1 100644 --- a/StatsCalculator/StatsCalculatorProvider.cs +++ b/StatsCalculator/StatsCalculatorProvider.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; namespace ProfilerDataExporter { @@ -25,4 +26,5 @@ public static StatsCalculatorBase GetStatsCalculator(StatsType statsType) return Calculators[statsType]; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/StatsCalculator/SumStatsCalculator.cs b/StatsCalculator/SumStatsCalculator.cs index 7ff0701..6646f0a 100644 --- a/StatsCalculator/SumStatsCalculator.cs +++ b/StatsCalculator/SumStatsCalculator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; namespace ProfilerDataExporter { @@ -14,4 +15,5 @@ protected override float AggregateValues(IList values) return sum; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/UnityWrappers/GUIClip.cs b/UnityWrappers/GUIClip.cs index 5e80c5e..1b79c4c 100644 --- a/UnityWrappers/GUIClip.cs +++ b/UnityWrappers/GUIClip.cs @@ -1,3 +1,4 @@ +#if UNITY_EDITOR using System; using System.Reflection; using UnityEngine; @@ -36,3 +37,4 @@ public static Rect visibleRect } } } +#endif \ No newline at end of file diff --git a/UnityWrappers/SplitterGUILayout.cs b/UnityWrappers/SplitterGUILayout.cs index 7b1c236..18c96d1 100644 --- a/UnityWrappers/SplitterGUILayout.cs +++ b/UnityWrappers/SplitterGUILayout.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Reflection; using UnityEditor; using UnityEngine; @@ -192,3 +193,4 @@ public void ApplyOptions(GUILayoutOption[] options) } } } +#endif \ No newline at end of file diff --git a/UnityWrappers/SplitterState.cs b/UnityWrappers/SplitterState.cs index e7550fd..37bc35a 100644 --- a/UnityWrappers/SplitterState.cs +++ b/UnityWrappers/SplitterState.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Reflection; using UnityEditor; using UnityEngine; @@ -28,7 +29,7 @@ public SplitterState(float[] relativeSizes, int[] minSizes, int[] maxSizes) BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new object[] { relativeSizes, minSizes, maxSizes }); - realSizes = (int[])RealSizesInfo.GetValue(splitter); + realSizes = Array.ConvertAll((float[])RealSizesInfo.GetValue(splitter), x => (int)x); } public SplitterState(object splitter) @@ -69,10 +70,19 @@ public int splitSize { get { - return (int)SplitterStateType.InvokeMember("splitSize", + var splitSize = SplitterStateType.InvokeMember("splitSize", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, splitter, null); + + if (splitSize is int) + { + return (int)splitSize; + } + else + { + return 0; + } } } public float[] relativeSizes @@ -135,3 +145,4 @@ public void DoSplitter(int currentActiveSplitter, int v, int num3) } } } +#endif \ No newline at end of file diff --git a/Utils/ByteSize.cs b/Utils/ByteSize.cs index a07eee6..d431271 100644 --- a/Utils/ByteSize.cs +++ b/Utils/ByteSize.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Globalization; namespace ByteSizeLib @@ -406,4 +407,5 @@ public static bool TryParse(string s, out ByteSize result) } } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Utils/TableGUILayout.cs b/Utils/TableGUILayout.cs index 2c74d46..d5ede46 100644 --- a/Utils/TableGUILayout.cs +++ b/Utils/TableGUILayout.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; using UnityEditor; using UnityEngine; @@ -65,3 +66,4 @@ public static void AddRow(ITableState tableState, int rowIndex, IEnumerable