Skip to content

Commit

Permalink
Move source to src directory and clean up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukespragg committed Apr 6, 2018
1 parent 12bd3a8 commit 682550e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Oxide.Unity.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2008
MinimumVisualStudioVersion = 15.0
Project("{AC016865-AE43-4FEF-BD68-8B9AEFDA0B1A}") = "Oxide.Unity", "Oxide.Unity\Oxide.Unity.csproj", "{52C26C5B-23E5-48A2-B403-5FF5C898E91A}"
Project("{AC016865-AE43-4FEF-BD68-8B9AEFDA0B1A}") = "Oxide.Unity", "src\Oxide.Unity.csproj", "{52C26C5B-23E5-48A2-B403-5FF5C898E91A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class ExtensionMethods
/// <returns></returns>
public static Vector3 ToVector3(this string vector3)
{
var split = vector3.Split(',').Select(Convert.ToSingle).ToArray();
float[] split = vector3.Split(',').Select(Convert.ToSingle).ToArray();
return split.Length == 3 ? new Vector3(split[0], split[1], split[2]) : Vector3.zero;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Threading;
using UnityEngine;

using Logger = Oxide.Core.Logging.Logger;
using LogType = Oxide.Core.Logging.LogType;

Expand Down
6 changes: 4 additions & 2 deletions Oxide.Unity/Oxide.Unity.csproj → src/Oxide.Unity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
-->
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35' And '$(OS)' == 'Windows_NT'">C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35' And '$(OS)' == 'OSX'">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/2.0-api</FrameworkPathOverride>
<ThisAssemblyNamespace>Oxide.Core.Unity</ThisAssemblyNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitInfo" Version="2.0.*" />
<PackageReference Include="Oxide.References" Version="2.0.*" />
<PackageReference Include="Oxide.Core" Version="2.0.*" />
<PackageReference Include="Oxide.Core" Version="2.0.3797-develop" />
<Reference Include="UnityEngine">
<HintPath>Dependencies\UnityEngine.dll</HintPath>
</Reference>
Expand All @@ -32,7 +34,7 @@
<Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
<ItemGroup>
<ReferencePath Condition="'%(FileName)' == 'Oxide.References'">
<Aliases>Oxide</Aliases>
<Aliases>References</Aliases>
</ReferencePath>
</ItemGroup>
</Target>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 18 additions & 8 deletions Oxide.Unity/UnityScript.cs → src/UnityScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ private void Awake()
{
oxideMod = Interface.Oxide;

var eventInfo = typeof(Application).GetEvent("logMessageReceived");
EventInfo eventInfo = typeof(Application).GetEvent("logMessageReceived");
if (eventInfo == null)
{
// Unity 4
var logCallbackField = typeof(Application).GetField("s_LogCallback", BindingFlags.Static | BindingFlags.NonPublic);
var logCallback = logCallbackField?.GetValue(null) as Application.LogCallback;
if (logCallback == null) Interface.Oxide.LogWarning("No Unity application log callback is registered");
FieldInfo logCallbackField = typeof(Application).GetField("s_LogCallback", BindingFlags.Static | BindingFlags.NonPublic);
Application.LogCallback logCallback = logCallbackField?.GetValue(null) as Application.LogCallback;
if (logCallback == null)
{
Interface.Oxide.LogWarning("No Unity application log callback is registered");
}

#pragma warning disable 0618
Application.RegisterLogCallback((message, stack_trace, type) =>
Expand All @@ -42,7 +45,7 @@ private void Awake()
else
{
// Unity 5
var handleException = Delegate.CreateDelegate(eventInfo.EventHandlerType, this, "LogMessageReceived");
Delegate handleException = Delegate.CreateDelegate(eventInfo.EventHandlerType, this, "LogMessageReceived");
eventInfo.GetAddMethod().Invoke(null, new object[] { handleException });
}
}
Expand All @@ -51,7 +54,11 @@ private void Awake()

private void OnDestroy()
{
if (oxideMod.IsShuttingDown) return;
if (oxideMod.IsShuttingDown)
{
return;
}

oxideMod.LogWarning("The Oxide Unity Script was destroyed (creating a new instance)");
oxideMod.NextTick(Create);
}
Expand All @@ -65,9 +72,12 @@ private void OnApplicationQuit()
}
}

private void LogMessageReceived(string message, string stackTrace, LogType type)
private static void LogMessageReceived(string message, string stackTrace, LogType type)
{
if (type == LogType.Exception) RemoteLogger.Exception(message, stackTrace);
if (type == LogType.Exception)
{
RemoteLogger.Exception(message, stackTrace);
}
}
}
}

0 comments on commit 682550e

Please sign in to comment.