forked from jacksondunstan/UnityNativeScripting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
94 lines (84 loc) · 2.14 KB
/
Game.cpp
File metadata and controls
94 lines (84 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/// <summary>
/// Game-specific code for the native plugin
/// </summary>
/// <author>
/// Jackson Dunstan, 2017, http://JacksonDunstan.com
/// </author>
/// <license>
/// MIT
/// </license>
#include "Bindings.h"
using namespace System;
using namespace UnityEngine;
void PrintPlatformDefines();
// Called when the plugin is initialized
// This is mostly full of test code. Feel free to remove it all.
void PluginMain()
{
PrintPlatformDefines();
Debug::Log(String("Game booted up"));
GameObject go(String("GameObject with a TestScript"));
go.AddComponent<MyGame::MonoBehaviours::TestScript>();
}
void MyGame::MonoBehaviours::TestScript::Awake()
{
Debug::Log(String("C++ TestScript Awake"));
}
void MyGame::MonoBehaviours::TestScript::OnAnimatorIK(int32_t param0)
{
Debug::Log(String("C++ TestScript OnAnimatorIK"));
}
void MyGame::MonoBehaviours::TestScript::OnCollisionEnter(UnityEngine::Collision param0)
{
Debug::Log(String("C++ TestScript OnCollisionEnter"));
}
void MyGame::MonoBehaviours::TestScript::Update()
{
static int32_t numCreated = 0;
if (numCreated < 10)
{
GameObject go;
Transform transform = go.GetTransform();
float comp = (float)numCreated;
Vector3 position(comp, comp*10.0f, comp*100.0f);
transform.SetPosition(position);
numCreated++;
if (numCreated == 10)
{
Debug::Log(String("Done spawning game objects"));
}
}
}
void PrintPlatformDefines()
{
#if defined(UNITY_EDITOR)
Debug::Log(String("UNITY_EDITOR"));
#endif
#if defined(UNITY_STANDALONE)
Debug::Log(String("UNITY_STANDALONE"));
#endif
#if defined(UNITY_IOS)
Debug::Log(String("UNITY_IOS"));
#endif
#if defined(UNITY_ANDROID)
Debug::Log(String("UNITY_ANDROID"));
#endif
#if defined(UNITY_EDITOR_WIN)
Debug::Log(String("UNITY_EDITOR_WIN"));
#endif
#if defined(UNITY_EDITOR_OSX)
Debug::Log(String("UNITY_EDITOR_OSX"));
#endif
#if defined(UNITY_EDITOR_LINUX)
Debug::Log(String("UNITY_EDITOR_LINUX"));
#endif
#if defined(UNITY_STANDALONE_OSX)
Debug::Log(String("UNITY_STANDALONE_OSX"));
#endif
#if defined(UNITY_STANDALONE_WIN)
Debug::Log(String("UNITY_STANDALONE_WIN"));
#endif
#if defined(UNITY_STANDALONE_LINUX)
Debug::Log(String("UNITY_STANDALONE_LINUX"));
#endif
}