Skip to content

Commit f864edb

Browse files
committed
Initial commit
0 parents  commit f864edb

29 files changed

+417
-0
lines changed

Examples.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/HelloWorld.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using UnityEngine;
2+
using IronPython.Hosting;
3+
4+
namespace Exodrifter.UnityPython.Examples
5+
{
6+
public class HelloWorld : MonoBehaviour
7+
{
8+
void Start()
9+
{
10+
var engine = Python.CreateEngine();
11+
var scope = engine.CreateScope();
12+
13+
string code = "str = 'Hello world!'";
14+
15+
var source = engine.CreateScriptSourceFromString(code);
16+
source.Execute(scope);
17+
18+
Debug.Log(scope.GetVariable<string>("str"));
19+
}
20+
}
21+
}

Examples/HelloWorld.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/HelloWorldUnity.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using UnityEngine;
2+
3+
namespace Exodrifter.UnityPython.Examples
4+
{
5+
public class HelloWorldUnity : MonoBehaviour
6+
{
7+
void Start()
8+
{
9+
var engine = global::UnityPython.CreateEngine();
10+
var scope = engine.CreateScope();
11+
12+
string code = "import UnityEngine\n";
13+
code += "UnityEngine.Debug.Log('Hello world!')";
14+
15+
var source = engine.CreateScriptSourceFromString(code);
16+
source.Execute(scope);
17+
}
18+
}
19+
}

Examples/HelloWorldUnity.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IronPython-2.6.2.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
454 KB
Binary file not shown.

IronPython-2.6.2/IronPython.Modules.dll.meta

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IronPython-2.6.2/IronPython.dll

1.43 MB
Binary file not shown.

IronPython-2.6.2/IronPython.dll.meta

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
934 KB
Binary file not shown.

IronPython-2.6.2/Microsoft.Dynamic.dll.meta

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
394 KB
Binary file not shown.

IronPython-2.6.2/Microsoft.Scripting.Core.dll.meta

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

IronPython-2.6.2/Microsoft.Scripting.Debugging.dll.meta

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

IronPython-2.6.2/Microsoft.Scripting.ExtensionAttribute.dll.meta

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
174 KB
Binary file not shown.

IronPython-2.6.2/Microsoft.Scripting.dll.meta

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE_IronPython.txt

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Microsoft Public License (Ms-PL)
2+
3+
This license governs use of the accompanying software. If you use the software,
4+
you accept this license. If you do not accept the license, do not use the
5+
software.
6+
7+
1. Definitions
8+
==============
9+
The terms "reproduce," "reproduction," "derivative works," and "distribution"
10+
have the same meaning here as under U.S. copyright law.
11+
12+
A "contribution" is the original software, or any additions or changes to the
13+
software.
14+
15+
A "contributor" is any person that distributes its contribution under this
16+
license.
17+
18+
"Licensed patents" are a contributor's patent claims that read directly on its
19+
contribution.
20+
21+
2. Grant of Rights
22+
==================
23+
(A) Copyright Grant- Subject to the terms of this license, including the
24+
license conditions and limitations in section 3, each contributor grants you a
25+
non-exclusive, worldwide, royalty-free copyright license to reproduce its
26+
contribution, prepare derivative works of its contribution, and distribute its
27+
contribution or any derivative works that you create.
28+
29+
(B) Patent Grant- Subject to the terms of this license, including the license
30+
conditions and limitations in section 3, each contributor grants you a
31+
non-exclusive, worldwide, royalty-free license under its licensed patents to
32+
make, have made, use, sell, offer for sale, import, and/or otherwise dispose of
33+
its contribution in the software or derivative works of the contribution in the
34+
software.
35+
36+
3. Conditions and Limitations
37+
=============================
38+
(A) No Trademark License- This license does not grant you rights to use any
39+
contributors' name, logo, or trademarks.
40+
41+
(B) If you bring a patent claim against any contributor over patents that you
42+
claim are infringed by the software, your patent license from such contributor
43+
to the software ends automatically.
44+
45+
(C) If you distribute any portion of the software, you must retain all
46+
copyright, patent, trademark, and attribution notices that are present in the
47+
software.
48+
49+
(D) If you distribute any portion of the software in source code form, you may
50+
do so only under this license by including a complete copy of this license with
51+
your distribution. If you distribute any portion of the software in compiled or
52+
object code form, you may only do so under a license that complies with this
53+
license.
54+
55+
(E) The software is licensed "as-is." You bear the risk of using it. The
56+
contributors give no express warranties, guarantees or conditions. You may have
57+
additional consumer rights under your local laws which this license cannot
58+
change. To the extent permitted under your local laws, the contributors exclude
59+
the implied warranties of merchantability, fitness for a particular purpose and
60+
non-infringement.

LICENSE_IronPython.txt.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE_UnityPython.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Exodrifter
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

LICENSE_UnityPython.txt.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
UnityPython
2+
===========
3+
UnityPython is a plugin for Unity3D that provides support for running Python
4+
code in Unity.
5+
6+
Special thanks to the developers of IronPython who developed the open-source
7+
integration of Python and .NET, which this plugin uses.
8+
9+
Thanks to Steve Theodore of the [Tech Art Survival Guide](http://techartsurvival.blogspot.com/2013/12/embedding-ironpython-in-unity-tech-art.html)
10+
who provided many instructions and examples.
11+
12+
13+
Setup
14+
=====
15+
Place the source of this project within a "Plugins" folder. For convenience,
16+
you can use the latest `.unitypackage` release from the [releases]
17+
(https://github.com/exodrifter/unity-python/releases) page to do this.
18+
19+
Then, go to `Edit > Project Settings > Player > Optimization` and select the
20+
`.NET 2.0` option for Api Compatability Level.
21+
22+
If you would like to use this project only in the Editor, changing the Api
23+
Compatability Level is unnecessary. Instead, place the project inside an
24+
"Editor" folder.
25+
26+
27+
Usage
28+
=====
29+
An example is provided below. More examples can be found in the
30+
`Examples/` folder.
31+
32+
using UnityEngine;
33+
using IronPython.Hosting;
34+
35+
public class HelloWorld : MonoBehaviour
36+
{
37+
void Start()
38+
{
39+
var engine = Python.CreateEngine();
40+
var scope = engine.CreateScope();
41+
42+
string code = "str = 'Hello world!'";
43+
44+
var source = engine.CreateScriptSourceFromString(code);
45+
source.Execute(scope);
46+
47+
Debug.Log(scope.GetVariable<string>("str"));
48+
}
49+
}

README.md.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)