v2
Add tests Modify syntax to be clearer Add Query function
This commit is contained in:
parent
a0e23300a5
commit
e68b1a5214
23 changed files with 222 additions and 48 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -38,3 +38,9 @@ sysinfo.txt
|
||||||
|
|
||||||
# Crashlytics generated file
|
# Crashlytics generated file
|
||||||
Assets/StreamingAssets/crashlytics-build.properties
|
Assets/StreamingAssets/crashlytics-build.properties
|
||||||
|
|
||||||
|
# IDEA files
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# vim tmp files
|
||||||
|
*.swp
|
||||||
|
|
|
@ -192,7 +192,7 @@ GameObject:
|
||||||
- component: {fileID: 1143534761}
|
- component: {fileID: 1143534761}
|
||||||
- component: {fileID: 1143534760}
|
- component: {fileID: 1143534760}
|
||||||
- component: {fileID: 1143534759}
|
- component: {fileID: 1143534759}
|
||||||
- component: {fileID: 1143534758}
|
- component: {fileID: 1143534762}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Main Camera
|
m_Name: Main Camera
|
||||||
m_TagString: MainCamera
|
m_TagString: MainCamera
|
||||||
|
@ -200,18 +200,6 @@ GameObject:
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 1
|
||||||
--- !u!114 &1143534758
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1143534757}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: a119dc90f88e78893b575c2c6fe4c866, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!81 &1143534759
|
--- !u!81 &1143534759
|
||||||
AudioListener:
|
AudioListener:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -276,3 +264,15 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1143534762
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1143534757}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 37e3f85ce68c6c2f186d5cf8cc78661a, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
|
@ -1,28 +0,0 @@
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
public class LinuxGameMode : MonoBehaviour
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
|
|
||||||
[DllImport("UnityGameMode")]
|
|
||||||
private static extern int UnityEnterGameMode();
|
|
||||||
[DllImport("UnityGameMode")]
|
|
||||||
private static extern int UnityExitGameMode();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
|
|
||||||
UnityEnterGameMode();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private void End()
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
|
|
||||||
UnityExitGameMode();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
8
Assets/Plugins/Editor.meta
Normal file
8
Assets/Plugins/Editor.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: da6cb113744887d629850cb8dce05b10
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/Plugins/Editor/JetBrains.meta
Normal file
8
Assets/Plugins/Editor/JetBrains.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8fe847eedc5778747a5be0ecd8904676
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7d84d2d22a9787157af526ae74b0d0da
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
Windows Store Apps: WindowsStoreApps
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
42
Assets/Plugins/UnityGameMode/LinuxGameMode.cs
Normal file
42
Assets/Plugins/UnityGameMode/LinuxGameMode.cs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
public class LinuxGameMode : MonoBehaviour
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
|
||||||
|
|
||||||
|
// Import functions from native lib
|
||||||
|
[DllImport("UnityGameMode")]
|
||||||
|
public static extern int GameModeRequestStart();
|
||||||
|
[DllImport("UnityGameMode")]
|
||||||
|
public static extern int GameModeRequestEnd();
|
||||||
|
[DllImport("UnityGameMode")]
|
||||||
|
public static extern int GameModeQueryStatus();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
Debug.Log("Requesting Linux GameMode Start");
|
||||||
|
var ret = GameModeRequestStart();
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
Debug.Log($"Linux GameMode Start Failed: #{ret}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnApplicationQuit()
|
||||||
|
{
|
||||||
|
Debug.Log("Requesting Linux GameMode End");
|
||||||
|
var ret = GameModeRequestEnd();
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
Debug.Log($"Linux GameMode End failed: #{ret}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public static int GameModeRequestStart() { return 0; }
|
||||||
|
public static int GameModeRequestEnd() { return 0; }
|
||||||
|
public static int GameModeQueryStatus() { return 0; }
|
||||||
|
#endif // UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a119dc90f88e78893b575c2c6fe4c866
|
guid: 37e3f85ce68c6c2f186d5cf8cc78661a
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
8
Assets/Plugins/UnityGameMode/Tests.meta
Normal file
8
Assets/Plugins/UnityGameMode/Tests.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 861cc3c09d2156d259770af563e138ee
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
42
Assets/Plugins/UnityGameMode/Tests/LinuxGameModeTests.cs
Normal file
42
Assets/Plugins/UnityGameMode/Tests/LinuxGameModeTests.cs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
|
||||||
|
namespace Tests
|
||||||
|
{
|
||||||
|
public class LinuxGameModeTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void GameModeRequestStartWorks()
|
||||||
|
{
|
||||||
|
var ret = LinuxGameMode.GameModeRequestStart();
|
||||||
|
Assert.IsTrue( ret == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GameModeRequestEndWorks()
|
||||||
|
{
|
||||||
|
var ret = LinuxGameMode.GameModeRequestStart();
|
||||||
|
Assert.IsTrue( ret == 0 );
|
||||||
|
ret = LinuxGameMode.GameModeRequestEnd();
|
||||||
|
Assert.IsTrue( ret == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GameModeGameModeQueryStatusWorks()
|
||||||
|
{
|
||||||
|
var ret = LinuxGameMode.GameModeRequestStart();
|
||||||
|
Assert.IsTrue( ret == 0 );
|
||||||
|
|
||||||
|
ret = LinuxGameMode.GameModeQueryStatus();
|
||||||
|
Assert.IsTrue( ret == 2 );
|
||||||
|
|
||||||
|
ret = LinuxGameMode.GameModeRequestEnd();
|
||||||
|
Assert.IsTrue( ret == 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 10924db4abe9770f4afcae590ef633b4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
16
Assets/Plugins/UnityGameMode/Tests/Tests.asmdef
Normal file
16
Assets/Plugins/UnityGameMode/Tests/Tests.asmdef
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "Tests",
|
||||||
|
"references": [
|
||||||
|
"UnityGameMode"
|
||||||
|
],
|
||||||
|
"optionalUnityReferences": [
|
||||||
|
"TestAssemblies"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": []
|
||||||
|
}
|
7
Assets/Plugins/UnityGameMode/Tests/Tests.asmdef.meta
Normal file
7
Assets/Plugins/UnityGameMode/Tests/Tests.asmdef.meta
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 988460cbe66440da5957c2009cf1716c
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
3
Assets/Plugins/UnityGameMode/UnityGameMode.asmdef
Normal file
3
Assets/Plugins/UnityGameMode/UnityGameMode.asmdef
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"name": "UnityGameMode"
|
||||||
|
}
|
7
Assets/Plugins/UnityGameMode/UnityGameMode.asmdef.meta
Normal file
7
Assets/Plugins/UnityGameMode/UnityGameMode.asmdef.meta
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b64a5e540ca9753878ce248d3c605b90
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,2 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
g++ unitygamemode.c -shared -ldl -o libUnityGameMode.so
|
g++ unitygamemode.c -shared -ldl -o libUnityGameMode.so
|
||||||
|
nm -C libUnityGameMode.so | grep GameMode
|
||||||
|
|
7
Assets/Plugins/UnityGameMode/compile.sh.meta
Normal file
7
Assets/Plugins/UnityGameMode/compile.sh.meta
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 034bb0da8726741ad84b3f98590ac9b9
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -1,9 +1,13 @@
|
||||||
#include "gamemode_client.h"
|
#include "gamemode_client.h"
|
||||||
|
|
||||||
extern "C" int UnityEnterGameMode() {
|
extern "C" int GameModeRequestStart() {
|
||||||
gamemode_request_start();
|
return gamemode_request_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int UnityExitGameMode() {
|
extern "C" int GameModeRequestEnd() {
|
||||||
gamemode_request_end();
|
return gamemode_request_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" int GameModeQueryStatus() {
|
||||||
|
return gamemode_query_status();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ EditorBuildSettings:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/BaseScene.unity
|
path: Assets/ExampleScene.unity
|
||||||
guid: 507495ce39e9816769b71a30e39d443e
|
guid: 507495ce39e9816769b71a30e39d443e
|
||||||
m_configObjects: {}
|
m_configObjects: {}
|
||||||
|
|
|
@ -68,7 +68,7 @@ PlayerSettings:
|
||||||
androidBlitType: 0
|
androidBlitType: 0
|
||||||
defaultIsNativeResolution: 1
|
defaultIsNativeResolution: 1
|
||||||
macRetinaSupport: 1
|
macRetinaSupport: 1
|
||||||
runInBackground: 0
|
runInBackground: 1
|
||||||
captureSingleScreen: 0
|
captureSingleScreen: 0
|
||||||
muteOtherAudioSources: 0
|
muteOtherAudioSources: 0
|
||||||
Prepare IOS For Recording: 0
|
Prepare IOS For Recording: 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue