├── ProjectSettings
├── ProjectVersion.txt
├── NavMeshLayers.asset
├── ClusterInputManager.asset
├── NetworkManager.asset
├── TimeManager.asset
├── UnityAdsSettings.asset
├── EditorBuildSettings.asset
├── UnityConnectSettings.asset
├── AudioManager.asset
├── EditorSettings.asset
├── TagManager.asset
├── DynamicsManager.asset
├── Physics2DSettings.asset
├── NavMeshAreas.asset
├── GraphicsSettings.asset
├── QualitySettings.asset
├── InputManager.asset
└── ProjectSettings.asset
├── Assets
├── dll
│ ├── IronPython.dll
│ ├── IronPython.Modules.dll
│ ├── IronPython.SQLite.dll
│ ├── Microsoft.Dynamic.dll
│ ├── Microsoft.Scripting.dll
│ ├── Microsoft.Scripting.Core.dll
│ └── Microsoft.Scripting.AspNet.dll
├── font
│ └── Monaco12.ttf
├── src
│ ├── python
│ │ ├── Player.py
│ │ ├── RigidbodyExample.py
│ │ └── CubeClass.py
│ ├── interpreter
│ │ ├── ErrorHandle.cs
│ │ └── Interpreter.cs
│ ├── PyEventLinker.cs
│ ├── editor
│ │ ├── ColorScheme.cs
│ │ ├── EditorDataBase.cs
│ │ ├── PythonMenu.cs
│ │ ├── EditorViewStyles.cs
│ │ ├── PythonInspector.cs
│ │ ├── Code.cs
│ │ └── EditorView.cs
│ └── PythonBase.cs
├── materials
│ ├── base2.mat
│ └── base1.mat
└── scenes
│ └── Scene.unity
├── .gitignore
├── README.md
└── LICENSE
/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 5.3.2p1
2 | m_StandardAssetsVersion: 0
3 |
--------------------------------------------------------------------------------
/Assets/dll/IronPython.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/dll/IronPython.dll
--------------------------------------------------------------------------------
/Assets/font/Monaco12.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/font/Monaco12.ttf
--------------------------------------------------------------------------------
/Assets/dll/IronPython.Modules.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/dll/IronPython.Modules.dll
--------------------------------------------------------------------------------
/Assets/dll/IronPython.SQLite.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/dll/IronPython.SQLite.dll
--------------------------------------------------------------------------------
/Assets/dll/Microsoft.Dynamic.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/dll/Microsoft.Dynamic.dll
--------------------------------------------------------------------------------
/Assets/dll/Microsoft.Scripting.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/dll/Microsoft.Scripting.dll
--------------------------------------------------------------------------------
/ProjectSettings/NavMeshLayers.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/ProjectSettings/NavMeshLayers.asset
--------------------------------------------------------------------------------
/Assets/dll/Microsoft.Scripting.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/dll/Microsoft.Scripting.Core.dll
--------------------------------------------------------------------------------
/Assets/dll/Microsoft.Scripting.AspNet.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cesardeazevedo/Unity3D-Python-Editor/HEAD/Assets/dll/Microsoft.Scripting.AspNet.dll
--------------------------------------------------------------------------------
/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!236 &1
4 | ClusterInputManager:
5 | m_ObjectHideFlags: 0
6 | m_Inputs: []
7 |
--------------------------------------------------------------------------------
/ProjectSettings/NetworkManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!149 &1
4 | NetworkManager:
5 | m_ObjectHideFlags: 0
6 | m_DebugLevel: 0
7 | m_Sendrate: 15
8 | m_AssetToPrefab: {}
9 |
--------------------------------------------------------------------------------
/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!5 &1
4 | TimeManager:
5 | m_ObjectHideFlags: 0
6 | Fixed Timestep: 0.02
7 | Maximum Allowed Timestep: 0.33333334
8 | m_TimeScale: 1
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | [Ll]ibrary/
2 | [Tt]emp/
3 | [Oo]bj/
4 | build/
5 | .DS_Store
6 | *.meta
7 | *.swp
8 |
9 | # Autogenerated VS/MD solution and project files
10 | /*.csproj
11 | /*.unityproj
12 | /*.sln
13 | /*.suo
14 | /*.user
15 | /*.userprefs
16 | /*.pidb
17 | /*.booproj
18 |
--------------------------------------------------------------------------------
/ProjectSettings/UnityAdsSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!292 &1
4 | UnityAdsSettings:
5 | m_ObjectHideFlags: 0
6 | m_Enabled: 0
7 | m_InitializeOnStartup: 1
8 | m_TestMode: 0
9 | m_EnabledPlatforms: 4294967295
10 | m_IosGameId:
11 | m_AndroidGameId:
12 |
--------------------------------------------------------------------------------
/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1045 &1
4 | EditorBuildSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Scenes:
8 | - enabled: 0
9 | path: Assets/Scene2.unity
10 | - enabled: 1
11 | path: Assets/scenes/Scene.unity
12 |
--------------------------------------------------------------------------------
/Assets/src/python/Player.py:
--------------------------------------------------------------------------------
1 | import UnityEngine as u
2 |
3 | class Player():
4 |
5 | def Start(self, this):
6 | pass
7 |
8 | def Update(self, this):
9 | this.transform.Rotate(u.Vector3(20,20,10))
10 | this.transform.position = u.Vector3(u.Mathf.Sin(u.Time.time), 0, u.Mathf.Cos(u.Time.time))
11 |
--------------------------------------------------------------------------------
/Assets/src/python/RigidbodyExample.py:
--------------------------------------------------------------------------------
1 | import UnityEngine as u
2 |
3 | class RigidbodyExample():
4 |
5 | rigid = None
6 |
7 | def Awake(self, this):
8 | self.rigid = this.GetComponent(u.Rigidbody)
9 |
10 | def Update(self, this):
11 |
12 | if(u.Input.GetKeyDown(u.KeyCode.Space)):
13 | self.rigid.velocity = u.Vector3(0, 5, 0)
14 |
15 |
--------------------------------------------------------------------------------
/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!310 &1
4 | UnityConnectSettings:
5 | m_ObjectHideFlags: 0
6 | UnityPurchasingSettings:
7 | m_Enabled: 0
8 | m_TestMode: 0
9 | UnityAnalyticsSettings:
10 | m_Enabled: 0
11 | m_InitializeOnStartup: 1
12 | m_TestMode: 0
13 | m_TestEventUrl:
14 | m_TestConfigUrl:
15 |
--------------------------------------------------------------------------------
/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!11 &1
4 | AudioManager:
5 | m_ObjectHideFlags: 0
6 | m_Volume: 1
7 | Rolloff Scale: 1
8 | Doppler Factor: 1
9 | Default Speaker Mode: 2
10 | m_SampleRate: 0
11 | m_DSPBufferSize: 0
12 | m_VirtualVoiceCount: 512
13 | m_RealVoiceCount: 32
14 | m_SpatializerPlugin:
15 | m_DisableAudio: 0
16 |
--------------------------------------------------------------------------------
/Assets/src/python/CubeClass.py:
--------------------------------------------------------------------------------
1 | import UnityEngine as unity
2 |
3 | class CubeClass():
4 |
5 | vel = 1.5
6 |
7 | def Awake(self, this):
8 | unity.Debug.Log("Awake Method")
9 |
10 | def Start(self, this):
11 | unity.Debug.Log("Start Method")
12 |
13 | def Update(self, this):
14 | horizontal = unity.Input.GetAxis("Horizontal") * self.vel * unity.Time.deltaTime
15 | vertical = unity.Input.GetAxis("Vertical") * self.vel * unity.Time.deltaTime
16 | this.transform.Translate(horizontal, 0, vertical)
17 |
18 |
--------------------------------------------------------------------------------
/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!159 &1
4 | EditorSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 3
7 | m_ExternalVersionControlSupport: Asset Server
8 | m_SerializationMode: 2
9 | m_WebSecurityEmulationEnabled: 0
10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d
11 | m_DefaultBehaviorMode: 0
12 | m_SpritePackerMode: 0
13 | m_SpritePackerPaddingPower: 1
14 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
15 | m_ProjectGenerationRootNamespace:
16 |
--------------------------------------------------------------------------------
/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!78 &1
4 | TagManager:
5 | serializedVersion: 2
6 | tags: []
7 | layers:
8 | - Default
9 | - TransparentFX
10 | - Ignore Raycast
11 | -
12 | - Water
13 | - UI
14 | -
15 | -
16 | - ground
17 | - ground2
18 | - ground3
19 | -
20 | -
21 | -
22 | -
23 | -
24 | -
25 | -
26 | -
27 | -
28 | -
29 | -
30 | -
31 | -
32 | -
33 | -
34 | -
35 | -
36 | -
37 | -
38 | -
39 | -
40 | m_SortingLayers:
41 | - name: Default
42 | uniqueID: 0
43 | locked: 0
44 |
--------------------------------------------------------------------------------
/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!55 &1
4 | PhysicsManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Gravity: {x: 0, y: -9.81, z: 0}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_BounceThreshold: 2
10 | m_SleepThreshold: 0.005
11 | m_DefaultContactOffset: 0.01
12 | m_SolverIterationCount: 6
13 | m_QueriesHitTriggers: 1
14 | m_EnableAdaptiveForce: 0
15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Unity3D-Python-Editor
2 | =====================
3 |
4 | Python interface based on IronPython for Unity3D with sweet editor for inspector
5 |
6 | 
7 |
8 | > NOTE
9 | >
10 | > The project is a crazy experiment. i haven't tested about performance and others benchmarks.
11 | > Even though the interpreter works fine for a development environment, if you want to use Unity methods such as Start and Update (which works),
12 | > i dot not recommend that you use for anything important yet.
13 |
14 |
15 | ## Editor
16 | 
17 |
18 | ## Interpreter
19 | 
20 |
21 | ## LICENSE
22 | [MIT](./LICENSE)
23 |
--------------------------------------------------------------------------------
/Assets/src/interpreter/ErrorHandle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using IronPython.Hosting;
3 | using IronPython.Modules;
4 | using Microsoft.Scripting;
5 | using Microsoft.Scripting.Hosting;
6 |
7 | ///
8 | /// Exceptions of ironpython
9 | ///
10 | public class ErrorHandle : ErrorListener {
11 |
12 | public string Message { get; set; }
13 | public int ErrorCode { get; set; }
14 | public Severity Sev { get; set; }
15 | public SourceSpan Span { get; set; }
16 |
17 | public override void ErrorReported(ScriptSource source, string message, Microsoft.Scripting.SourceSpan span, int errorCode, Microsoft.Scripting.Severity severity)
18 | {
19 | Message = message;
20 | ErrorCode = errorCode;
21 | Sev = severity;
22 | Span = span;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Assets/src/PyEventLinker.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using UnityEngine;
3 |
4 | public class PyEventLinker : MonoBehaviour
5 | {
6 | private PythonBase py;
7 |
8 | private Interpreter machine = new Interpreter();
9 |
10 | private object ClassReference;
11 |
12 | private void Awake(){
13 | py = GetComponent();
14 | machine.Compile(py.FilePath, Microsoft.Scripting.SourceCodeKind.Statements);
15 | ClassReference = machine.GetVariable(Path.GetFileNameWithoutExtension(py.FilePath));
16 |
17 | InvokeMethod("Awake");
18 | }
19 |
20 | private void Start()
21 | {
22 | InvokeMethod("Start");
23 | }
24 |
25 | private void Update()
26 | {
27 | InvokeMethod("Update");
28 | }
29 | private void InvokeMethod(string Method)
30 | {
31 | machine.InvokeMethod(ClassReference, Method,this);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ProjectSettings/Physics2DSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!19 &1
4 | Physics2DSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Gravity: {x: 0, y: -9.81}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_VelocityIterations: 8
10 | m_PositionIterations: 3
11 | m_VelocityThreshold: 1
12 | m_MaxLinearCorrection: 0.2
13 | m_MaxAngularCorrection: 8
14 | m_MaxTranslationSpeed: 100
15 | m_MaxRotationSpeed: 360
16 | m_MinPenetrationForPenalty: 0.01
17 | m_BaumgarteScale: 0.2
18 | m_BaumgarteTimeOfImpactScale: 0.75
19 | m_TimeToSleep: 0.5
20 | m_LinearSleepTolerance: 0.01
21 | m_AngularSleepTolerance: 2
22 | m_QueriesHitTriggers: 1
23 | m_QueriesStartInColliders: 1
24 | m_ChangeStopsCallbacks: 0
25 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 César Augusto D. Azevedo
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 all
13 | 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 THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ProjectSettings/NavMeshAreas.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!126 &1
4 | NavMeshAreas:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | areas:
8 | - name: Walkable
9 | cost: 1
10 | - name: Not Walkable
11 | cost: 1
12 | - name: Jump
13 | cost: 2
14 | - name:
15 | cost: 1
16 | - name:
17 | cost: 1
18 | - name:
19 | cost: 1
20 | - name:
21 | cost: 1
22 | - name:
23 | cost: 1
24 | - name:
25 | cost: 1
26 | - name:
27 | cost: 1
28 | - name:
29 | cost: 1
30 | - name:
31 | cost: 1
32 | - name:
33 | cost: 1
34 | - name:
35 | cost: 1
36 | - name:
37 | cost: 1
38 | - name:
39 | cost: 1
40 | - name:
41 | cost: 1
42 | - name:
43 | cost: 1
44 | - name:
45 | cost: 1
46 | - name:
47 | cost: 1
48 | - name:
49 | cost: 1
50 | - name:
51 | cost: 1
52 | - name:
53 | cost: 1
54 | - name:
55 | cost: 1
56 | - name:
57 | cost: 1
58 | - name:
59 | cost: 1
60 | - name:
61 | cost: 1
62 | - name:
63 | cost: 1
64 | - name:
65 | cost: 1
66 | - name:
67 | cost: 1
68 | - name:
69 | cost: 1
70 | - name:
71 | cost: 1
72 |
--------------------------------------------------------------------------------
/ProjectSettings/GraphicsSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!30 &1
4 | GraphicsSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 5
7 | m_Deferred:
8 | m_Mode: 1
9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
10 | m_DeferredReflections:
11 | m_Mode: 1
12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
13 | m_LegacyDeferred:
14 | m_Mode: 1
15 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
16 | m_AlwaysIncludedShaders:
17 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
18 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
19 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
20 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
21 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
22 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
23 | m_PreloadedShaders: []
24 | m_ShaderSettings:
25 | useScreenSpaceShadows: 0
26 | m_BuildTargetShaderSettings: []
27 | m_LightmapStripping: 0
28 | m_FogStripping: 0
29 | m_LightmapKeepPlain: 1
30 | m_LightmapKeepDirCombined: 1
31 | m_LightmapKeepDirSeparate: 1
32 | m_LightmapKeepDynamicPlain: 1
33 | m_LightmapKeepDynamicDirCombined: 1
34 | m_LightmapKeepDynamicDirSeparate: 1
35 | m_FogKeepLinear: 1
36 | m_FogKeepExp: 1
37 | m_FogKeepExp2: 1
38 |
--------------------------------------------------------------------------------
/Assets/src/editor/ColorScheme.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | ///
4 | /// Syntax HighLight Code
5 | ///
6 | public static class ColorScheme
7 | {
8 | ///
9 | /// The color of the background.
10 | ///
11 | public static Color32 Background = new Color32(42, 50, 50, 255);
12 |
13 | ///
14 | /// The background color2.
15 | ///
16 | public static Color32 Background2 = new Color32(34, 34, 34, 255);
17 |
18 | ///
19 | /// The background color3.
20 | ///
21 | public static Color32 Background3 = new Color32(39, 40, 34, 255);
22 |
23 | ///
24 | /// White Letters
25 | ///
26 | public static Color32 White = new Color32(255, 255, 255, 255);
27 |
28 | ///
29 | /// Pink Keywords
30 | ///
31 | public static Color32 Pink = new Color32(244, 0, 101, 255);
32 |
33 | ///
34 | /// Molokai Green
35 | ///
36 | public static Color32 Green = new Color32(165, 255, 11 , 255);
37 |
38 | ///
39 | /// Orange Strings
40 | ///
41 | public static Color32 Orange = new Color32(237, 158, 38, 255);
42 |
43 | ///
44 | /// Comments
45 | ///
46 | public static Color32 Gray = new Color32(100, 100, 100, 255);
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/Assets/src/PythonBase.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections.Generic;
3 |
4 | [System.Serializable]
5 | public class PythonBase : MonoBehaviour
6 | {
7 | ///
8 | /// The path of file
9 | ///
10 | public string FilePath;
11 |
12 | ///
13 | /// The name of the file.
14 | ///
15 | public string FileName = "Untitled.py";
16 |
17 | ///
18 | /// The file created.
19 | ///
20 | public bool FileCreated, Saved, InMemory;
21 | ///
22 | /// Has changes in file
23 | ///
24 | public bool HasChanges = true;
25 |
26 | public enum Views {
27 | Code,
28 | Interpreter
29 | };
30 |
31 | ///
32 | /// The current view.
33 | ///
34 | public Views CurrentView;
35 |
36 | ///
37 | /// The lib path.
38 | ///
39 | public static List SysPath = new List();
40 |
41 | ///
42 | /// The default code.
43 | ///
44 | public static string DefaultCode = "import UnityEngine as unity\n\n"+
45 | "class Untitled(): \n\n"+
46 | "\tdef Start(self, this):\n"+
47 | "\t\tpass\n\n"+
48 | "\tdef Update(self, this):\n"+
49 | "\t\tpass";
50 |
51 | ///
52 | /// Reset this instance.
53 | ///
54 | public void Reset()
55 | {
56 | FilePath = string.Empty;
57 | Saved = false;
58 | HasChanges = true;
59 | FileCreated = false;
60 | FileName = "Untitled.py";
61 | }
62 |
63 | //TODO:
64 | [ContextMenu("Cursor Block")]
65 | private void Menu()
66 | {
67 | Debug.Log("CursorBlock");
68 | }
69 | //TODO:
70 | [ContextMenu("Vertical Bar")]
71 | private void Menu2()
72 | {
73 | Debug.Log("CursorBlock");
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Assets/src/editor/EditorDataBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using System.Collections.Generic;
4 |
5 | ///
6 | /// Keep buffers in memory
7 | ///
8 | [Serializable]
9 | public class EditorDataBase : ScriptableObject
10 | {
11 | ///
12 | /// InstanceID and the instance of buffer
13 | ///
14 | [SerializeField]
15 | public Dictionary Buffers = new Dictionary();
16 |
17 | ///
18 | /// The _instance.
19 | ///
20 | private static EditorDataBase _instance;
21 |
22 | ///
23 | /// Singleton of instance
24 | ///
25 | /// The instance.
26 | public static EditorDataBase Instance {
27 | get {
28 | if(_instance == null) {
29 |
30 | //Create instance of ScriptableObject.
31 | _instance = ScriptableObject.CreateInstance();
32 |
33 | //Remove existing instances
34 | _instance.RemoveAllInstances();
35 |
36 | //Leaks
37 | _instance.hideFlags = HideFlags.HideAndDontSave;
38 | }
39 |
40 | return _instance;
41 | }
42 | }
43 |
44 | ///
45 | /// Raises the enable event.
46 | ///
47 | public void OnEnable()
48 | {
49 | //Leaks
50 | hideFlags = HideFlags.HideAndDontSave;
51 |
52 | if (_instance == null)
53 | _instance = this;
54 |
55 | }
56 |
57 | ///
58 | /// Adds the instance.
59 | ///
60 | /// Instance I.
61 | /// E.
62 | public void AddInstance(int InstanceID, Code e)
63 | {
64 | if(!Instance.Buffers.ContainsKey(InstanceID))
65 | Instance.Buffers.Add(InstanceID,e);
66 | }
67 |
68 | ///
69 | /// Gets the instance.
70 | ///
71 | /// The instance.
72 | /// Instance I.
73 | public Code GetInstance(int InstanceID)
74 | {
75 | if(Instance.Buffers.ContainsKey(InstanceID))
76 | return Instance.Buffers[InstanceID];
77 |
78 | //return a default buffer
79 | return CreateInstance().Initialize();
80 | }
81 |
82 | ///
83 | /// Removes the instance.
84 | ///
85 | /// Instance I.
86 | public void RemoveInstance(int InstanceID)
87 | {
88 | Instance.Buffers.Remove(InstanceID);
89 | }
90 |
91 | ///
92 | /// Removes the instances.
93 | ///
94 | private void RemoveAllInstances()
95 | {
96 | Instance.Buffers.Clear();
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Assets/src/editor/PythonMenu.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections;
4 |
5 | ///
6 | /// Python menu.
7 | ///
8 | public class PythonMenu : EditorWindow
9 | {
10 |
11 | private static string Title = "Window";
12 |
13 | private GUIStyle SysPathStyle;
14 |
15 | private static void CreateWindow()
16 | {
17 | EditorWindow.GetWindow(typeof(PythonMenu));
18 | }
19 |
20 | private static void CreateWindow(Rect rect)
21 | {
22 | EditorWindow.GetWindowWithRect(typeof(PythonMenu),rect);
23 | }
24 |
25 | [MenuItem("Python/New Python Script",false,0)]
26 | private static void AddComponent()
27 | {
28 | if(Selection.activeGameObject != null) {
29 | GameObject Selected = Selection.activeTransform.gameObject;
30 | Selected.AddComponent();
31 | } else
32 | EditorUtility.DisplayDialog("Missing GameObject", "Please, Select a GameObject", "OK");
33 | }
34 |
35 | [MenuItem("Python/External Library",false, 1)]
36 | private static void SetPythonLibs()
37 | {
38 | Title = "Locate Library";
39 |
40 | CreateWindow();
41 |
42 | if(PythonBase.SysPath.Count == 0)
43 | PythonBase.SysPath.Add("\\");
44 | }
45 |
46 | [MenuItem("Python/About")]
47 | private static void About()
48 | {
49 | //TODO
50 | Title = "About";
51 | CreateWindow();
52 | }
53 |
54 | private void OnEnable()
55 | {
56 | title = Title;
57 | }
58 |
59 | private void OnGUI()
60 | {
61 |
62 | SysPathStyle = new GUIStyle(GUI.skin.textField);
63 |
64 | EditorGUILayout.Space();
65 |
66 | EditorGUILayout.BeginVertical();
67 | EditorGUILayout.BeginHorizontal();
68 |
69 | int top = 5;
70 | for (int i = 0; i < PythonBase.SysPath.Count; i++) {
71 |
72 | GUI.Label(new Rect(5,top,Screen.width-180,20),PythonBase.SysPath[i], SysPathStyle);
73 |
74 | if(GUI.Button(new Rect(Screen.width-170,top,80,20), "Open")) {
75 | PythonBase.SysPath[i] = DialogLocation(PythonBase.SysPath[i]);
76 |
77 | string paths = string.Join("\n", PythonBase.SysPath.ToArray());
78 |
79 | EditorPrefs.SetString("SysPath",paths);
80 |
81 | }
82 | if(GUI.Button(new Rect(Screen.width-85,top,80,20), "Delete"))
83 | PythonBase.SysPath.RemoveAt(i);
84 |
85 | top += 25;
86 | }
87 |
88 | EditorGUILayout.EndHorizontal();
89 | EditorGUILayout.EndVertical();
90 |
91 | if(GUI.Button(new Rect(0,Screen.height-45,Screen.width,20), "Add Path")) {
92 | PythonBase.SysPath.Add("\\");
93 | }
94 | }
95 |
96 | ///
97 | /// Dialogs the location.
98 | ///
99 | private string DialogLocation(string DefaultPath)
100 | {
101 | return EditorUtility.OpenFolderPanel("Python Library Path", DefaultPath,"");
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/Assets/materials/base2.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: base2
10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 5
13 | m_CustomRenderQueue: -1
14 | stringTagMap: {}
15 | m_SavedProperties:
16 | serializedVersion: 2
17 | m_TexEnvs:
18 | data:
19 | first:
20 | name: _MainTex
21 | second:
22 | m_Texture: {fileID: 10305, guid: 0000000000000000f000000000000000, type: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | data:
26 | first:
27 | name: _BumpMap
28 | second:
29 | m_Texture: {fileID: 0}
30 | m_Scale: {x: 1, y: 1}
31 | m_Offset: {x: 0, y: 0}
32 | data:
33 | first:
34 | name: _DetailNormalMap
35 | second:
36 | m_Texture: {fileID: 0}
37 | m_Scale: {x: 1, y: 1}
38 | m_Offset: {x: 0, y: 0}
39 | data:
40 | first:
41 | name: _ParallaxMap
42 | second:
43 | m_Texture: {fileID: 0}
44 | m_Scale: {x: 1, y: 1}
45 | m_Offset: {x: 0, y: 0}
46 | data:
47 | first:
48 | name: _OcclusionMap
49 | second:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | data:
54 | first:
55 | name: _EmissionMap
56 | second:
57 | m_Texture: {fileID: 0}
58 | m_Scale: {x: 1, y: 1}
59 | m_Offset: {x: 0, y: 0}
60 | data:
61 | first:
62 | name: _DetailMask
63 | second:
64 | m_Texture: {fileID: 0}
65 | m_Scale: {x: 1, y: 1}
66 | m_Offset: {x: 0, y: 0}
67 | data:
68 | first:
69 | name: _DetailAlbedoMap
70 | second:
71 | m_Texture: {fileID: 0}
72 | m_Scale: {x: 1, y: 1}
73 | m_Offset: {x: 0, y: 0}
74 | data:
75 | first:
76 | name: _MetallicGlossMap
77 | second:
78 | m_Texture: {fileID: 0}
79 | m_Scale: {x: 1, y: 1}
80 | m_Offset: {x: 0, y: 0}
81 | m_Floats:
82 | data:
83 | first:
84 | name: _SrcBlend
85 | second: 1
86 | data:
87 | first:
88 | name: _DstBlend
89 | second: 0
90 | data:
91 | first:
92 | name: _Cutoff
93 | second: 0.5
94 | data:
95 | first:
96 | name: _Parallax
97 | second: 0.02
98 | data:
99 | first:
100 | name: _ZWrite
101 | second: 1
102 | data:
103 | first:
104 | name: _Glossiness
105 | second: 0.752
106 | data:
107 | first:
108 | name: _BumpScale
109 | second: 1
110 | data:
111 | first:
112 | name: _OcclusionStrength
113 | second: 1
114 | data:
115 | first:
116 | name: _DetailNormalMapScale
117 | second: 1
118 | data:
119 | first:
120 | name: _UVSec
121 | second: 0
122 | data:
123 | first:
124 | name: _EmissionScaleUI
125 | second: 0
126 | data:
127 | first:
128 | name: _Mode
129 | second: 0
130 | data:
131 | first:
132 | name: _Metallic
133 | second: 0.321
134 | m_Colors:
135 | data:
136 | first:
137 | name: _EmissionColor
138 | second: {r: 0, g: 0, b: 0, a: 0}
139 | data:
140 | first:
141 | name: _Color
142 | second: {r: 0.7941176, g: 0.7941176, b: 0.7941176, a: 1}
143 | data:
144 | first:
145 | name: _EmissionColorUI
146 | second: {r: 1, g: 1, b: 1, a: 1}
147 |
--------------------------------------------------------------------------------
/Assets/materials/base1.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: base1
10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 5
13 | m_CustomRenderQueue: -1
14 | stringTagMap: {}
15 | m_SavedProperties:
16 | serializedVersion: 2
17 | m_TexEnvs:
18 | data:
19 | first:
20 | name: _MainTex
21 | second:
22 | m_Texture: {fileID: 10305, guid: 0000000000000000f000000000000000, type: 0}
23 | m_Scale: {x: 10, y: 10}
24 | m_Offset: {x: 0, y: 0}
25 | data:
26 | first:
27 | name: _BumpMap
28 | second:
29 | m_Texture: {fileID: 0}
30 | m_Scale: {x: 1, y: 1}
31 | m_Offset: {x: 0, y: 0}
32 | data:
33 | first:
34 | name: _DetailNormalMap
35 | second:
36 | m_Texture: {fileID: 0}
37 | m_Scale: {x: 1, y: 1}
38 | m_Offset: {x: 0, y: 0}
39 | data:
40 | first:
41 | name: _ParallaxMap
42 | second:
43 | m_Texture: {fileID: 0}
44 | m_Scale: {x: 1, y: 1}
45 | m_Offset: {x: 0, y: 0}
46 | data:
47 | first:
48 | name: _OcclusionMap
49 | second:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | data:
54 | first:
55 | name: _EmissionMap
56 | second:
57 | m_Texture: {fileID: 0}
58 | m_Scale: {x: 10, y: 10}
59 | m_Offset: {x: 0, y: 0}
60 | data:
61 | first:
62 | name: _DetailMask
63 | second:
64 | m_Texture: {fileID: 0}
65 | m_Scale: {x: 1, y: 1}
66 | m_Offset: {x: 0, y: 0}
67 | data:
68 | first:
69 | name: _DetailAlbedoMap
70 | second:
71 | m_Texture: {fileID: 0}
72 | m_Scale: {x: 1, y: 1}
73 | m_Offset: {x: 0, y: 0}
74 | data:
75 | first:
76 | name: _MetallicGlossMap
77 | second:
78 | m_Texture: {fileID: 0}
79 | m_Scale: {x: 1, y: 1}
80 | m_Offset: {x: 0, y: 0}
81 | m_Floats:
82 | data:
83 | first:
84 | name: _SrcBlend
85 | second: 1
86 | data:
87 | first:
88 | name: _DstBlend
89 | second: 0
90 | data:
91 | first:
92 | name: _Cutoff
93 | second: 0.5
94 | data:
95 | first:
96 | name: _Parallax
97 | second: 0.02
98 | data:
99 | first:
100 | name: _ZWrite
101 | second: 1
102 | data:
103 | first:
104 | name: _Glossiness
105 | second: 0.81
106 | data:
107 | first:
108 | name: _BumpScale
109 | second: 1
110 | data:
111 | first:
112 | name: _OcclusionStrength
113 | second: 1
114 | data:
115 | first:
116 | name: _DetailNormalMapScale
117 | second: 1
118 | data:
119 | first:
120 | name: _UVSec
121 | second: 0
122 | data:
123 | first:
124 | name: _EmissionScaleUI
125 | second: 0
126 | data:
127 | first:
128 | name: _Mode
129 | second: 0
130 | data:
131 | first:
132 | name: _Metallic
133 | second: 0
134 | m_Colors:
135 | data:
136 | first:
137 | name: _EmissionColor
138 | second: {r: 0, g: 0, b: 0, a: 0}
139 | data:
140 | first:
141 | name: _Color
142 | second: {r: 0.60294116, g: 0.60294116, b: 0.60294116, a: 1}
143 | data:
144 | first:
145 | name: _EmissionColorUI
146 | second: {r: 1, g: 1, b: 1, a: 1}
147 |
--------------------------------------------------------------------------------
/ProjectSettings/QualitySettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!47 &1
4 | QualitySettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 5
7 | m_CurrentQuality: 3
8 | m_QualitySettings:
9 | - serializedVersion: 2
10 | name: Fastest
11 | pixelLightCount: 0
12 | shadows: 0
13 | shadowResolution: 0
14 | shadowProjection: 1
15 | shadowCascades: 1
16 | shadowDistance: 15
17 | shadowNearPlaneOffset: 2
18 | shadowCascade2Split: 0.33333334
19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
20 | blendWeights: 1
21 | textureQuality: 1
22 | anisotropicTextures: 0
23 | antiAliasing: 0
24 | softParticles: 0
25 | softVegetation: 0
26 | realtimeReflectionProbes: 0
27 | billboardsFaceCameraPosition: 0
28 | vSyncCount: 0
29 | lodBias: 0.3
30 | maximumLODLevel: 0
31 | particleRaycastBudget: 4
32 | asyncUploadTimeSlice: 2
33 | asyncUploadBufferSize: 4
34 | excludedTargetPlatforms: []
35 | - serializedVersion: 2
36 | name: Fast
37 | pixelLightCount: 0
38 | shadows: 0
39 | shadowResolution: 0
40 | shadowProjection: 1
41 | shadowCascades: 1
42 | shadowDistance: 20
43 | shadowNearPlaneOffset: 2
44 | shadowCascade2Split: 0.33333334
45 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
46 | blendWeights: 2
47 | textureQuality: 0
48 | anisotropicTextures: 0
49 | antiAliasing: 0
50 | softParticles: 0
51 | softVegetation: 0
52 | realtimeReflectionProbes: 0
53 | billboardsFaceCameraPosition: 0
54 | vSyncCount: 0
55 | lodBias: 0.4
56 | maximumLODLevel: 0
57 | particleRaycastBudget: 16
58 | asyncUploadTimeSlice: 2
59 | asyncUploadBufferSize: 4
60 | excludedTargetPlatforms: []
61 | - serializedVersion: 2
62 | name: Simple
63 | pixelLightCount: 1
64 | shadows: 1
65 | shadowResolution: 0
66 | shadowProjection: 1
67 | shadowCascades: 1
68 | shadowDistance: 20
69 | shadowNearPlaneOffset: 2
70 | shadowCascade2Split: 0.33333334
71 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
72 | blendWeights: 2
73 | textureQuality: 0
74 | anisotropicTextures: 1
75 | antiAliasing: 0
76 | softParticles: 0
77 | softVegetation: 0
78 | realtimeReflectionProbes: 0
79 | billboardsFaceCameraPosition: 0
80 | vSyncCount: 0
81 | lodBias: 0.7
82 | maximumLODLevel: 0
83 | particleRaycastBudget: 64
84 | asyncUploadTimeSlice: 2
85 | asyncUploadBufferSize: 4
86 | excludedTargetPlatforms: []
87 | - serializedVersion: 2
88 | name: Good
89 | pixelLightCount: 2
90 | shadows: 2
91 | shadowResolution: 1
92 | shadowProjection: 1
93 | shadowCascades: 2
94 | shadowDistance: 40
95 | shadowNearPlaneOffset: 2
96 | shadowCascade2Split: 0.33333334
97 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
98 | blendWeights: 2
99 | textureQuality: 0
100 | anisotropicTextures: 1
101 | antiAliasing: 0
102 | softParticles: 0
103 | softVegetation: 1
104 | realtimeReflectionProbes: 1
105 | billboardsFaceCameraPosition: 1
106 | vSyncCount: 1
107 | lodBias: 1
108 | maximumLODLevel: 0
109 | particleRaycastBudget: 256
110 | asyncUploadTimeSlice: 2
111 | asyncUploadBufferSize: 4
112 | excludedTargetPlatforms: []
113 | - serializedVersion: 2
114 | name: Beautiful
115 | pixelLightCount: 3
116 | shadows: 2
117 | shadowResolution: 2
118 | shadowProjection: 1
119 | shadowCascades: 2
120 | shadowDistance: 70
121 | shadowNearPlaneOffset: 2
122 | shadowCascade2Split: 0.33333334
123 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
124 | blendWeights: 4
125 | textureQuality: 0
126 | anisotropicTextures: 2
127 | antiAliasing: 2
128 | softParticles: 1
129 | softVegetation: 1
130 | realtimeReflectionProbes: 1
131 | billboardsFaceCameraPosition: 1
132 | vSyncCount: 1
133 | lodBias: 1.5
134 | maximumLODLevel: 0
135 | particleRaycastBudget: 1024
136 | asyncUploadTimeSlice: 2
137 | asyncUploadBufferSize: 4
138 | excludedTargetPlatforms: []
139 | - serializedVersion: 2
140 | name: Fantastic
141 | pixelLightCount: 4
142 | shadows: 2
143 | shadowResolution: 2
144 | shadowProjection: 1
145 | shadowCascades: 4
146 | shadowDistance: 150
147 | shadowNearPlaneOffset: 2
148 | shadowCascade2Split: 0.33333334
149 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
150 | blendWeights: 4
151 | textureQuality: 0
152 | anisotropicTextures: 2
153 | antiAliasing: 2
154 | softParticles: 1
155 | softVegetation: 1
156 | realtimeReflectionProbes: 1
157 | billboardsFaceCameraPosition: 1
158 | vSyncCount: 1
159 | lodBias: 2
160 | maximumLODLevel: 0
161 | particleRaycastBudget: 4096
162 | asyncUploadTimeSlice: 2
163 | asyncUploadBufferSize: 4
164 | excludedTargetPlatforms: []
165 | m_PerPlatformDefaultQuality:
166 | Android: 2
167 | BlackBerry: 2
168 | FlashPlayer: 3
169 | GLES Emulation: 3
170 | PS3: 3
171 | PS4: 3
172 | PSM: 3
173 | PSP2: 3
174 | Samsung TV: 2
175 | Standalone: 3
176 | Tizen: 2
177 | WP8: 3
178 | Web: 3
179 | Windows Store Apps: 3
180 | XBOX360: 3
181 | XboxOne: 3
182 | iPhone: 2
183 |
--------------------------------------------------------------------------------
/Assets/src/interpreter/Interpreter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using UnityEngine;
5 | using System.Text;
6 | using System.Collections;
7 | using IronPython.Hosting;
8 | using IronPython.Modules;
9 | using System.Collections.Generic;
10 | using Microsoft.Scripting.Hosting;
11 |
12 |
13 | ///
14 | /// Interpreter for IronPython.
15 | ///
16 | public class Interpreter
17 | {
18 | ///
19 | /// The scope.
20 | ///
21 | private ScriptScope Scope;
22 |
23 | ///
24 | /// The engine.
25 | ///
26 | private ScriptEngine Engine;
27 |
28 | ///
29 | /// The source.
30 | ///
31 | private ScriptSource Source;
32 |
33 | ///
34 | /// The compiled.
35 | ///
36 | private CompiledCode Compiled;
37 |
38 | ///
39 | /// The operation.
40 | ///
41 | private ObjectOperations Operation;
42 |
43 | ///
44 | /// The python class.
45 | ///
46 | private object PythonClass;
47 |
48 | ///
49 | /// Initializes a new instance of the class.
50 | ///
51 | public Interpreter()
52 | {
53 | Engine = Python.CreateEngine();
54 | Scope = Engine.CreateScope();
55 | SetLibrary();
56 | }
57 |
58 | ///
59 | /// Initializes a new instance of the class.
60 | ///
61 | /// Source.
62 | public Interpreter(string src) : this()
63 | {
64 | Compile(src);
65 | }
66 |
67 | ///
68 | /// Compile the specified src.
69 | ///
70 | /// Source.
71 | public string Compile(string src, Microsoft.Scripting.SourceCodeKind CodeKind =
72 | Microsoft.Scripting.SourceCodeKind.SingleStatement)
73 | {
74 | if(src == string.Empty)
75 | return string.Empty;
76 |
77 | LoadRuntime();
78 |
79 |
80 | Source = CodeKind == Microsoft.Scripting.SourceCodeKind.SingleStatement ?
81 | Engine.CreateScriptSourceFromString(src, CodeKind) :
82 | Engine.CreateScriptSourceFromFile(src);
83 |
84 | ErrorHandle errors = new ErrorHandle();
85 |
86 | MemoryStream stream = new MemoryStream();
87 | //Set IO Ouput of execution
88 | Engine.Runtime.IO.SetOutput(stream, new StreamWriter(stream));
89 |
90 | Compiled = Source.Compile(errors);
91 | Operation = Engine.CreateOperations();
92 |
93 | try {
94 | Compiled.Execute(Scope);
95 | return FormatOutput(ReadFromStream(stream));
96 |
97 | } catch(Exception ex) {
98 | return Engine.GetService().FormatException(ex);
99 | }
100 | }
101 |
102 | ///
103 | /// Formats the output of execution
104 | ///
105 | /// The output.
106 | /// Output.
107 | private string FormatOutput(string output)
108 | {
109 | return string.IsNullOrEmpty(output) ? string.Empty
110 | : string.Join("\n", output.Remove(output.Length-1)
111 | .Split('\n')
112 | .Reverse().ToArray());
113 | }
114 |
115 | ///
116 | /// Reads MemoryStream.
117 | ///
118 | /// The from stream.
119 | /// Ms.
120 | private string ReadFromStream(MemoryStream ms) {
121 |
122 | int length = (int)ms.Length;
123 | Byte[] bytes = new Byte[ms.Length];
124 | ms.Seek(0, SeekOrigin.Begin);
125 | ms.Read(bytes, 0, length);
126 |
127 | return Encoding.GetEncoding("utf-8").GetString(bytes, 0, length);
128 | }
129 |
130 | ///
131 | /// Set sys paths
132 | ///
133 | private void SetLibrary()
134 | {
135 | if(PythonBase.SysPath.Count > 0) {
136 |
137 | ICollection SysPath = Engine.GetSearchPaths();
138 |
139 | foreach(string path in PythonBase.SysPath)
140 | SysPath.Add(path);
141 |
142 | Engine.SetSearchPaths(SysPath);
143 |
144 | }
145 | }
146 |
147 | ///
148 | /// Load runtime Assemblies of Unity3D
149 | ///
150 | private void LoadRuntime()
151 | {
152 | Engine.Runtime.LoadAssembly(typeof(GameObject).Assembly);
153 | }
154 |
155 | public void AddRuntime()
156 | {
157 | Engine.Runtime.LoadAssembly(typeof(T).Assembly);
158 | }
159 |
160 | public void AddRuntime(Type type)
161 | {
162 | Engine.Runtime.LoadAssembly(type.Assembly);
163 | }
164 |
165 | ///
166 | /// Gets the variable or class
167 | ///
168 | /// The variable.
169 | /// Name.
170 | public object GetVariable(string name)
171 | {
172 | return Operation.Invoke(Scope.GetVariable(name));
173 | }
174 |
175 | ///
176 | /// Calls the method.
177 | ///
178 | /// Name.
179 | public void InvokeMethod(object nameClass, string Method, params object[] parameters)
180 | {
181 | object output = new object();
182 | if(Operation.TryGetMember(nameClass, Method, out output)) {
183 | object Func = Operation.GetMember(nameClass, Method);
184 | Operation.Invoke(Func, parameters);
185 | }
186 | }
187 |
188 | }
189 |
--------------------------------------------------------------------------------
/ProjectSettings/InputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!13 &1
4 | InputManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Axes:
8 | - serializedVersion: 3
9 | m_Name: Horizontal
10 | descriptiveName:
11 | descriptiveNegativeName:
12 | negativeButton: left
13 | positiveButton: right
14 | altNegativeButton: a
15 | altPositiveButton: d
16 | gravity: 3
17 | dead: 0.001
18 | sensitivity: 3
19 | snap: 1
20 | invert: 0
21 | type: 0
22 | axis: 0
23 | joyNum: 0
24 | - serializedVersion: 3
25 | m_Name: Vertical
26 | descriptiveName:
27 | descriptiveNegativeName:
28 | negativeButton: down
29 | positiveButton: up
30 | altNegativeButton: s
31 | altPositiveButton: w
32 | gravity: 3
33 | dead: 0.001
34 | sensitivity: 3
35 | snap: 1
36 | invert: 0
37 | type: 0
38 | axis: 0
39 | joyNum: 0
40 | - serializedVersion: 3
41 | m_Name: Fire1
42 | descriptiveName:
43 | descriptiveNegativeName:
44 | negativeButton:
45 | positiveButton: left ctrl
46 | altNegativeButton:
47 | altPositiveButton: mouse 0
48 | gravity: 1000
49 | dead: 0.001
50 | sensitivity: 1000
51 | snap: 0
52 | invert: 0
53 | type: 0
54 | axis: 0
55 | joyNum: 0
56 | - serializedVersion: 3
57 | m_Name: Fire2
58 | descriptiveName:
59 | descriptiveNegativeName:
60 | negativeButton:
61 | positiveButton: left alt
62 | altNegativeButton:
63 | altPositiveButton: mouse 1
64 | gravity: 1000
65 | dead: 0.001
66 | sensitivity: 1000
67 | snap: 0
68 | invert: 0
69 | type: 0
70 | axis: 0
71 | joyNum: 0
72 | - serializedVersion: 3
73 | m_Name: Fire3
74 | descriptiveName:
75 | descriptiveNegativeName:
76 | negativeButton:
77 | positiveButton: left cmd
78 | altNegativeButton:
79 | altPositiveButton: mouse 2
80 | gravity: 1000
81 | dead: 0.001
82 | sensitivity: 1000
83 | snap: 0
84 | invert: 0
85 | type: 0
86 | axis: 0
87 | joyNum: 0
88 | - serializedVersion: 3
89 | m_Name: Jump
90 | descriptiveName:
91 | descriptiveNegativeName:
92 | negativeButton:
93 | positiveButton: space
94 | altNegativeButton:
95 | altPositiveButton:
96 | gravity: 1000
97 | dead: 0.001
98 | sensitivity: 1000
99 | snap: 0
100 | invert: 0
101 | type: 0
102 | axis: 0
103 | joyNum: 0
104 | - serializedVersion: 3
105 | m_Name: Mouse X
106 | descriptiveName:
107 | descriptiveNegativeName:
108 | negativeButton:
109 | positiveButton:
110 | altNegativeButton:
111 | altPositiveButton:
112 | gravity: 0
113 | dead: 0
114 | sensitivity: 0.1
115 | snap: 0
116 | invert: 0
117 | type: 1
118 | axis: 0
119 | joyNum: 0
120 | - serializedVersion: 3
121 | m_Name: Mouse Y
122 | descriptiveName:
123 | descriptiveNegativeName:
124 | negativeButton:
125 | positiveButton:
126 | altNegativeButton:
127 | altPositiveButton:
128 | gravity: 0
129 | dead: 0
130 | sensitivity: 0.1
131 | snap: 0
132 | invert: 0
133 | type: 1
134 | axis: 1
135 | joyNum: 0
136 | - serializedVersion: 3
137 | m_Name: Mouse ScrollWheel
138 | descriptiveName:
139 | descriptiveNegativeName:
140 | negativeButton:
141 | positiveButton:
142 | altNegativeButton:
143 | altPositiveButton:
144 | gravity: 0
145 | dead: 0
146 | sensitivity: 0.1
147 | snap: 0
148 | invert: 0
149 | type: 1
150 | axis: 2
151 | joyNum: 0
152 | - serializedVersion: 3
153 | m_Name: Horizontal
154 | descriptiveName:
155 | descriptiveNegativeName:
156 | negativeButton:
157 | positiveButton:
158 | altNegativeButton:
159 | altPositiveButton:
160 | gravity: 0
161 | dead: 0.19
162 | sensitivity: 1
163 | snap: 0
164 | invert: 0
165 | type: 2
166 | axis: 0
167 | joyNum: 0
168 | - serializedVersion: 3
169 | m_Name: Vertical
170 | descriptiveName:
171 | descriptiveNegativeName:
172 | negativeButton:
173 | positiveButton:
174 | altNegativeButton:
175 | altPositiveButton:
176 | gravity: 0
177 | dead: 0.19
178 | sensitivity: 1
179 | snap: 0
180 | invert: 1
181 | type: 2
182 | axis: 1
183 | joyNum: 0
184 | - serializedVersion: 3
185 | m_Name: Fire1
186 | descriptiveName:
187 | descriptiveNegativeName:
188 | negativeButton:
189 | positiveButton: joystick button 0
190 | altNegativeButton:
191 | altPositiveButton:
192 | gravity: 1000
193 | dead: 0.001
194 | sensitivity: 1000
195 | snap: 0
196 | invert: 0
197 | type: 0
198 | axis: 0
199 | joyNum: 0
200 | - serializedVersion: 3
201 | m_Name: Fire2
202 | descriptiveName:
203 | descriptiveNegativeName:
204 | negativeButton:
205 | positiveButton: joystick button 1
206 | altNegativeButton:
207 | altPositiveButton:
208 | gravity: 1000
209 | dead: 0.001
210 | sensitivity: 1000
211 | snap: 0
212 | invert: 0
213 | type: 0
214 | axis: 0
215 | joyNum: 0
216 | - serializedVersion: 3
217 | m_Name: Fire3
218 | descriptiveName:
219 | descriptiveNegativeName:
220 | negativeButton:
221 | positiveButton: joystick button 2
222 | altNegativeButton:
223 | altPositiveButton:
224 | gravity: 1000
225 | dead: 0.001
226 | sensitivity: 1000
227 | snap: 0
228 | invert: 0
229 | type: 0
230 | axis: 0
231 | joyNum: 0
232 | - serializedVersion: 3
233 | m_Name: Jump
234 | descriptiveName:
235 | descriptiveNegativeName:
236 | negativeButton:
237 | positiveButton: joystick button 3
238 | altNegativeButton:
239 | altPositiveButton:
240 | gravity: 1000
241 | dead: 0.001
242 | sensitivity: 1000
243 | snap: 0
244 | invert: 0
245 | type: 0
246 | axis: 0
247 | joyNum: 0
248 | - serializedVersion: 3
249 | m_Name: Submit
250 | descriptiveName:
251 | descriptiveNegativeName:
252 | negativeButton:
253 | positiveButton: return
254 | altNegativeButton:
255 | altPositiveButton: joystick button 0
256 | gravity: 1000
257 | dead: 0.001
258 | sensitivity: 1000
259 | snap: 0
260 | invert: 0
261 | type: 0
262 | axis: 0
263 | joyNum: 0
264 | - serializedVersion: 3
265 | m_Name: Submit
266 | descriptiveName:
267 | descriptiveNegativeName:
268 | negativeButton:
269 | positiveButton: enter
270 | altNegativeButton:
271 | altPositiveButton: space
272 | gravity: 1000
273 | dead: 0.001
274 | sensitivity: 1000
275 | snap: 0
276 | invert: 0
277 | type: 0
278 | axis: 0
279 | joyNum: 0
280 | - serializedVersion: 3
281 | m_Name: Cancel
282 | descriptiveName:
283 | descriptiveNegativeName:
284 | negativeButton:
285 | positiveButton: escape
286 | altNegativeButton:
287 | altPositiveButton: joystick button 1
288 | gravity: 1000
289 | dead: 0.001
290 | sensitivity: 1000
291 | snap: 0
292 | invert: 0
293 | type: 0
294 | axis: 0
295 | joyNum: 0
296 |
--------------------------------------------------------------------------------
/Assets/src/editor/EditorViewStyles.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using UnityEngine;
3 | using UnityEditor;
4 | using System.Text.RegularExpressions;
5 |
6 | ///
7 | /// Editor view styles.
8 | ///
9 | public class EditorViewStyles
10 | {
11 | private GUIStyle background;
12 | private GUIStyle font;
13 | private GUIStyle backgroundLines;
14 | private GUIStyle numberLines;
15 | private GUIStyle highLine;
16 | private GUIStyle cursor;
17 | private GUIStyle interpreter;
18 |
19 | ///
20 | /// Python keywords
21 | ///
22 | private static string[] KeyWords = new string[] {"False", "None", "True", "and", "as", "assert", "break", "class", "continue", "def", "del", "elif",
23 | "else", "except", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "nonlocal",
24 | "not", "or", "pass", "raise", "return", "try", "while", "with", "yield", "self" };
25 |
26 | public bool BlockComment, LineComment, IsString = false;
27 |
28 | private string WhichQuote, triplequotes = string.Empty;
29 |
30 | public GUIStyle Background {
31 | get {
32 | if(background == null)
33 | {
34 | background = new GUIStyle();
35 | background.normal.background = TextureColor(ColorScheme.Background2);
36 | return background;
37 | }
38 |
39 | return background;
40 | }
41 | }
42 |
43 | public GUIStyle FontGUIStyle {
44 | get {
45 | if(font == null)
46 | {
47 | font = new GUIStyle();
48 | font.font = (Font)AssetDatabase.LoadMainAssetAtPath("Assets/font/Monaco12.ttf");
49 | return font;
50 | }
51 |
52 | return font;
53 | }
54 | }
55 |
56 | public GUIStyle BackgroundLines {
57 | get {
58 | if(backgroundLines == null)
59 | {
60 | backgroundLines = new GUIStyle();
61 | backgroundLines.normal.background = TextureColor(new Color32(15,15,15,255));
62 | return backgroundLines;
63 | }
64 |
65 | return backgroundLines;
66 | }
67 | }
68 |
69 | public GUIStyle NumberLines{
70 | get {
71 | if(numberLines == null)
72 | {
73 | numberLines = new GUIStyle();
74 | numberLines.normal.textColor = Color.white;
75 | numberLines.font = FontGUIStyle.font;
76 | numberLines.alignment = TextAnchor.UpperRight;
77 | return numberLines;
78 | }
79 |
80 | return numberLines;
81 | }
82 | }
83 |
84 | public GUIStyle HighLine{
85 |
86 | get {
87 | if(highLine == null)
88 | {
89 | highLine = new GUIStyle();
90 | highLine.normal.background = TextureColor(new Color32(255,255,255,45));
91 | return highLine;
92 | }
93 |
94 | return highLine;
95 | }
96 | }
97 |
98 | public GUIStyle Cursor{
99 |
100 | get{
101 | if(cursor == null)
102 | {
103 | cursor = new GUIStyle();
104 | cursor.normal.background = TextureColor(new Color(255,255,255,0.8f));
105 | return cursor;
106 | }
107 |
108 | return cursor;
109 | }
110 | }
111 |
112 | public GUIStyle Interpreter{
113 |
114 | get{
115 | if(interpreter == null)
116 | {
117 | interpreter = new GUIStyle();;
118 | interpreter.font = FontGUIStyle.font;
119 | interpreter.fontSize = 14;
120 | interpreter.normal.textColor = new Color(255,255,255,1);
121 | return interpreter;
122 | }
123 |
124 | return interpreter;
125 | }
126 | }
127 |
128 | ///
129 | /// Checks the word style.
130 | ///
131 | /// The word style.
132 | /// Word.
133 | /// If set to true comment.
134 | public Color32 CheckWordStyle(string word)
135 | {
136 | LineComment = !LineComment ? word.StartsWith("#") : LineComment;
137 |
138 | return LineComment ? ColorScheme.Gray
139 | //Block Comment
140 | : BlockCommentStyle(word) ? ColorScheme.Orange
141 | //Strings
142 | : StringStyle(word) ? ColorScheme.Orange
143 | //Keywords
144 | : KeyWords.Contains(word) ? ColorScheme.Pink
145 | //Default
146 | : ColorScheme.White;
147 | }
148 |
149 | ///
150 | /// Match block of comment e.g.: """ this is a comment in python """
151 | ///
152 | /// true, if comment style was blocked, false otherwise.
153 | /// Word.
154 | private bool BlockCommentStyle(string word)
155 | {
156 | if(Regex.IsMatch(word, "([\"'])"))
157 | {
158 | triplequotes += word;
159 |
160 | if(Regex.IsMatch(triplequotes, "([\"]{3})|([\']{3})"))
161 | {
162 | BlockComment = !BlockComment;
163 | triplequotes = string.Empty;
164 |
165 | return true;
166 | }
167 |
168 | return BlockComment;
169 | }else
170 | //Reset Quotes
171 | triplequotes = string.Empty;
172 |
173 | return BlockComment;
174 | }
175 |
176 | ///
177 | /// Match a strings quotes e.g.: "this is a string"
178 | ///
179 | /// true, if checker was strung, false otherwise.
180 | /// Word.
181 | private bool StringStyle(string word)
182 | {
183 | //Match quotes checker.
184 | if(Regex.IsMatch(word, "([\"'])") && !BlockComment)
185 | {
186 | //Check double quotes or single quotes.
187 | IsString = string.IsNullOrEmpty(WhichQuote) ? true : word != WhichQuote;
188 |
189 | //Check if close with the first quotes.
190 | WhichQuote = string.IsNullOrEmpty(WhichQuote) ? word
191 | : !IsString ? string.Empty
192 | : WhichQuote;
193 | return true;
194 | }
195 |
196 | return IsString;
197 | }
198 |
199 | ///
200 | /// Resets styles on new line
201 | ///
202 | public void ResetLineStyles()
203 | {
204 | IsString = false;
205 | LineComment = false;
206 | WhichQuote = string.Empty;
207 | triplequotes = string.Empty;
208 | }
209 |
210 | ///
211 | /// Applies a color to a texture.
212 | ///
213 | /// The color.
214 | /// Color.
215 | private static Texture2D TextureColor(Color color)
216 | {
217 | Texture2D TextureColor = new Texture2D(1, 1);
218 | TextureColor.SetPixels(new Color[] { color });
219 | TextureColor.Apply();
220 | TextureColor.hideFlags = HideFlags.HideAndDontSave;
221 | return TextureColor;
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/Assets/src/editor/PythonInspector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using UnityEngine;
4 | using UnityEditor;
5 | using System.Text;
6 | using System.Linq;
7 | using System.Collections;
8 |
9 | ///
10 | /// Call python.
11 | ///
12 | [Serializable, CustomEditor(typeof(PythonBase))]
13 | public class PythonInspector : Editor
14 | {
15 |
16 | [SerializeField]
17 | private PythonBase Target;
18 |
19 | private Interpreter python;
20 |
21 | public EditorView editor;
22 |
23 | private GUIStyle FontDrag, ButtonTabs;
24 |
25 | private int ColorSkinPro = 0;
26 |
27 | ///
28 | /// Raises the enable event.
29 | ///
30 | private void OnEnable()
31 | {
32 | Target = (PythonBase)target;
33 |
34 | if(editor == null)
35 | editor = new EditorView();
36 |
37 | editor.OnEnable(Target);
38 |
39 | //Repaint Action Delegate
40 | editor.RepaintAction += this.Repaint;
41 |
42 | //Set view back
43 | SwitchView(Target.CurrentView);
44 |
45 | LoadEditorPrefs();
46 |
47 | ColorSkinPro = !EditorGUIUtility.isProSkin ? 0 : 255;
48 |
49 | }
50 |
51 | ///
52 | /// Raises the disable event.
53 | ///
54 | private void OnDisable()
55 | {
56 | //Disable delegate
57 | editor.RepaintAction -= this.Repaint;
58 | //Ask for Save file
59 | DialogFileSystem();
60 | }
61 |
62 | ///
63 | /// Sets the styles on inspector (Tabs, Font)
64 | ///
65 | private void SetStyles()
66 | {
67 | //Style of text
68 | FontDrag = new GUIStyle(GUI.skin.box);
69 | FontDrag.fontSize = 16;
70 | FontDrag.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black;
71 | FontDrag.alignment = TextAnchor.MiddleCenter;
72 | FontDrag.hover.background = TextureColor(Color.yellow);
73 | //Style of Tabs
74 | ButtonTabs = new GUIStyle(GUI.skin.box);
75 | ButtonTabs.fontSize = 16;
76 | ButtonTabs.normal.textColor = Color.white;
77 | ButtonTabs.alignment = TextAnchor.MiddleCenter;
78 |
79 | Color ColorTabs = new Color(ColorSkinPro,ColorSkinPro,ColorSkinPro,0.9f);
80 | ButtonTabs.normal.background = TextureColor(ColorTabs);
81 | }
82 |
83 | ///
84 | /// Dialogs the file system.
85 | ///
86 | private void DialogFileSystem()
87 | {
88 | if(!Target.Saved && Target.HasChanges) {
89 |
90 | switch(DialogSave()) {
91 | //Save
92 | case 0:
93 | if(!Target.FileCreated)
94 | SaveFileLocation();
95 | else {
96 | SaveCodeToFile();
97 | Target.InMemory = false;
98 | }
99 | break;
100 | //Cancel
101 | case 1:
102 | if(Target.FileCreated) {
103 | Target.Saved = true;
104 | Target.HasChanges = false;
105 | }
106 | break;
107 | //Keep in Memory
108 | case 2:
109 | EditorDataBase.Instance.AddInstance(Target.GetInstanceID(), editor.Buffer);
110 | Target.InMemory = true;
111 | break;
112 | }
113 | }
114 | }
115 | ///
116 | /// Saves the file system.
117 | ///
118 | /// The file system.
119 | private void SaveFileLocation()
120 | {
121 | string Path = EditorUtility.SaveFilePanel("Save Python Script","Assets",this.name,"py");
122 |
123 | CreateFile(Path);
124 | }
125 |
126 | ///
127 | /// Dialog this instance.
128 | ///
129 | private int DialogSave()
130 | {
131 | return EditorUtility.DisplayDialogComplex("Save Python File ", "Save File?", "Save", "Cancel", "Keep in Memory");
132 | }
133 |
134 | ///
135 | /// Creates the file.
136 | ///
137 | /// File path.
138 | /// File name.
139 | private void CreateFile(string FilePath)
140 | {
141 | if(FilePath != string.Empty) {
142 | File.WriteAllText(FilePath,editor.Buffer.CodeBuffer);
143 | Target.FilePath = FilePath;
144 | Target.FileName = Path.GetFileName(FilePath);
145 | Target.FileCreated = true;
146 | Target.Saved = true;
147 | Target.HasChanges = false;
148 | }
149 | }
150 |
151 | ///
152 | /// Saves the code to file.
153 | ///
154 | private void SaveCodeToFile()
155 | {
156 | File.WriteAllText(Target.FilePath,editor.Buffer.CodeBuffer, Encoding.UTF8);
157 | Target.Saved = true;
158 | Target.InMemory = false;
159 | Target.HasChanges = false;
160 | //Remove from memory
161 | EditorDataBase.Instance.RemoveInstance(Target.GetInstanceID());
162 | }
163 |
164 | ///
165 | // "Compile" on save file
166 | ///
167 | private void CompileOnSave()
168 | {
169 | python = new Interpreter();
170 | string Response = python.Compile(Target.FilePath, Microsoft.Scripting.SourceCodeKind.Statements);
171 |
172 | //Display if returned something, error, print, etc.
173 | if(!String.IsNullOrEmpty(Response))
174 | Debug.Log(Response);
175 | }
176 |
177 | ///
178 | /// Show a box dialog
179 | ///
180 | /// String of error
181 | public static void DialogError(string error)
182 | {
183 | EditorUtility.DisplayDialog("Error Occurred",error,"OK");
184 | }
185 |
186 | ///
187 | /// Loads the editor prefs.
188 | ///
189 | private void LoadEditorPrefs()
190 | {
191 |
192 | string Paths = EditorPrefs.HasKey("SysPath") ?
193 | EditorPrefs.GetString("SysPath") : "\\";
194 |
195 | PythonBase.SysPath = Paths.Split('\n').ToList();
196 | }
197 |
198 | ///
199 | /// Raises the inspector GU event.
200 | ///
201 | public override void OnInspectorGUI()
202 | {
203 |
204 | SetStyles();
205 |
206 | DoSpace();
207 |
208 | Rect DropArea = GUILayoutUtility.GetRect(Screen.width,50,GUILayout.ExpandWidth(true));
209 |
210 | GUI.Box(DropArea,"Drag Python Script", FontDrag);
211 |
212 | DragAndDropFile(DropArea);
213 |
214 | DoSpace();
215 |
216 | ToogleButtons();
217 |
218 | editor.EditorViewGUI(Target.CurrentView == PythonBase.Views.Interpreter);
219 |
220 | if(GUILayout.Button("Save and Compile")) {
221 |
222 | Target.Saved = true;
223 | Target.HasChanges = false;
224 |
225 | if(!Target.FileCreated)
226 | SaveFileLocation();
227 | else
228 | SaveCodeToFile();
229 |
230 | CompileOnSave();
231 | }
232 | }
233 |
234 | ///
235 | /// Drags the and drop file.
236 | ///
237 | /// Drop area.
238 | private void DragAndDropFile(Rect DropArea)
239 | {
240 | Event current = Event.current;
241 |
242 | switch(current.type) {
243 |
244 | case EventType.DragUpdated:
245 | case EventType.DragPerform:
246 |
247 | if(DropArea.Contains(current.mousePosition)) {
248 | DragAndDrop.visualMode = DragAndDrop.paths.Length == 0 ? DragAndDropVisualMode.Rejected
249 | : DragAndDrop.paths[0].EndsWith(".py") ? DragAndDropVisualMode.Copy
250 | : DragAndDrop.paths[0].EndsWith(".txt") ? DragAndDropVisualMode.Copy
251 | : DragAndDropVisualMode.Rejected;
252 |
253 | if(current.type == EventType.DragPerform) {
254 |
255 | Target.FilePath = DragAndDrop.paths[0];
256 |
257 | Target.FileName = Path.GetFileName(Target.FilePath);
258 |
259 | StreamReader file = new StreamReader(Target.FilePath,Encoding.UTF8);
260 |
261 | editor.Buffer.Initialize();
262 |
263 | string LocalBuffer = file.ReadToEnd();
264 | editor.Buffer.CodeBuffer = LocalBuffer == "" ? " " : LocalBuffer;
265 |
266 | Target.FileCreated = true;
267 |
268 | SwitchView(PythonBase.Views.Code);
269 |
270 | DragAndDrop.AcceptDrag();
271 |
272 | current.Use();
273 | }
274 | }
275 | break;
276 | }
277 | }
278 |
279 | ///
280 | /// Toogles the tabs
281 | ///
282 | private void ToogleButtons()
283 | {
284 | GUILayout.BeginHorizontal();
285 |
286 | bool Active = Target.CurrentView == PythonBase.Views.Code;
287 |
288 | SwitchColors(Target.CurrentView == PythonBase.Views.Code);
289 |
290 | //Check if file has changes and put "*"
291 | string FileName = Target.FileName + ((Target.HasChanges) ? "*" : "");
292 |
293 | //Limit the width of Tab
294 | int width = Math.Min(Screen.width-200, 100 + FileName.Length*9);
295 | if(GUILayout.Toggle(Active, FileName, ButtonTabs, GUILayout.Width(width),
296 | GUILayout.Height(40)) != Active) {
297 |
298 | SwitchView(PythonBase.Views.Code);
299 | }
300 |
301 | SwitchColors(Target.CurrentView == PythonBase.Views.Interpreter);
302 | if(GUILayout.Toggle(Active, "Interpreter", ButtonTabs, GUILayout.Width(170),
303 | GUILayout.Height(40)) != Active) {
304 |
305 | SwitchView(PythonBase.Views.Interpreter);
306 | editor.Buffer.CurrentLine = string.Empty;
307 | editor.InitializeInterpreter();
308 | }
309 |
310 | GUILayout.EndHorizontal();
311 | }
312 |
313 | private void SwitchView(PythonBase.Views view)
314 | {
315 | editor.Buffer.InterpreterView = editor.InterpreterView
316 | = (view == PythonBase.Views.Interpreter);
317 | Target.CurrentView = view;
318 | }
319 |
320 | private void SwitchColors(bool view)
321 | {
322 | Color ActiveColor = view ? new Color(ColorSkinPro,ColorSkinPro,ColorSkinPro,0.35f) :
323 | new Color(ColorSkinPro,ColorSkinPro,ColorSkinPro,0.50f);
324 |
325 | ButtonTabs.normal.background = TextureColor(ActiveColor);
326 | }
327 |
328 | ///
329 | /// Spacing of InspectorGUI
330 | ///
331 | private void DoSpace()
332 | {
333 | EditorGUILayout.Space();
334 | }
335 |
336 | ///
337 | /// Applies a color to a texture.
338 | ///
339 | /// The color.
340 | /// Color.
341 | private static Texture2D TextureColor(Color color)
342 | {
343 | Texture2D TextureColor = new Texture2D(1, 1);
344 | TextureColor.SetPixels(new Color[] { color });
345 | TextureColor.Apply();
346 | TextureColor.hideFlags = HideFlags.HideAndDontSave;
347 | return TextureColor;
348 | }
349 |
350 | }
351 |
--------------------------------------------------------------------------------
/Assets/src/editor/Code.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Linq;
4 | using UnityEngine;
5 | using System.Collections.Generic;
6 | using System.Text.RegularExpressions;
7 |
8 | ///
9 | /// Code.
10 | ///
11 | [Serializable]
12 | public class Code : ScriptableObject
13 | {
14 | ///
15 | /// Current Number Line
16 | ///
17 | public int Line;
18 |
19 | ///
20 | /// Current Number Column;
21 | ///
22 | public int Column;
23 |
24 | ///
25 | /// Current Number Column Index
26 | ///
27 | public int ColumnIndex;
28 |
29 | ///
30 | /// The total lines.
31 | ///
32 | public int TotalLines = 1;
33 |
34 | ///
35 | /// List with all lines and all words
36 | ///
37 | public List> Lines = new List>();
38 |
39 | public string CodeBuffer = string.Empty;
40 | public string CurrentLine = string.Empty;
41 | public string InterpreterBuffer = string.Empty;
42 | public string InterpreterBlock = string.Empty;
43 |
44 | public bool InterpreterView;
45 | public bool BlockInspector;
46 |
47 | ///
48 | /// Initialize.
49 | ///
50 | /// Object.
51 | public Code Initialize()
52 | {
53 | this.Lines = new List>();
54 | this.CurrentLine = string.Empty;
55 | this.CodeBuffer = PythonBase.DefaultCode;
56 |
57 | SetColumnIndex();
58 |
59 | return this;
60 | }
61 |
62 | ///
63 | /// Initialize the specified Line and Column.
64 | ///
65 | /// Line.
66 | /// Column.
67 | public void Initialize(int Line, int Column)
68 | {
69 | this.Line = Line;
70 | this.Column = Column;
71 | this.CurrentLine = GetLine(this.Line);
72 | SetColumnIndex();
73 | }
74 |
75 | public void OnEnable()
76 | {
77 | hideFlags = HideFlags.HideAndDontSave;
78 | }
79 |
80 | ///
81 | /// Sets the index of the column.
82 | ///
83 | public void SetColumnIndex()
84 | {
85 | Trim();
86 |
87 | ColumnIndex = GetIndexColumn(this.Column,this.CurrentLine);
88 |
89 | ColumnIndex = CurrentLine.Length == 0 ? 0
90 | : ColumnIndex > CurrentLine.Length ? CurrentLine.Length
91 | : ColumnIndex;
92 | }
93 |
94 | ///
95 | /// Gets the index column.
96 | ///
97 | /// The index column.
98 | /// Column.
99 | public int GetIndexColumn(int column, string line)
100 | {
101 | if(column == 0)
102 | return 0;
103 |
104 | int index = 0;
105 | for(int i = 0; i <= line.Length; i++) {
106 |
107 | if(line.Length > 0) {
108 | index = line[i] == '\t' ? index+4 : index+1;
109 | if(index >= column)
110 | return ++i;
111 | }
112 | }
113 |
114 | return 0;
115 | }
116 |
117 | ///
118 | /// Gos up.
119 | ///
120 | public void GoUp()
121 | {
122 | Line--;
123 |
124 | CurrentLine = GetLine(Line);
125 |
126 | SetColumnIndex();
127 | }
128 |
129 | ///
130 | /// Gos down.
131 | ///
132 | public void GoDown()
133 | {
134 | Line++;
135 |
136 | CurrentLine = GetLine(Line);
137 |
138 | SetColumnIndex();
139 | }
140 |
141 | ///
142 | /// Gos the left.
143 | ///
144 | public void GoLeft()
145 | {
146 |
147 | if(Column == 0)
148 | Line--;
149 |
150 | if(Event.current.command)
151 | //Go to begin of line
152 | Column = Regex.Match(TabToSpace(CurrentLine),@"\w").Index;
153 | else {
154 |
155 | Column = Column > 0 ? Column-1: GetLine(Line).Length;
156 |
157 | Column = GetCharIndex(ColumnIndex-1) == '\t' ? Column-3 : Column;
158 | }
159 |
160 | SetColumnIndex();
161 | }
162 |
163 | ///
164 | /// Gos the right.
165 | ///
166 | public void GoRight()
167 | {
168 | if(Event.current.command)
169 | //Go to end of line
170 | Column = TabToSpace(CurrentLine).Length;
171 | else if(ColumnIndex >= CurrentLine.Length && !InterpreterView) {
172 | GoDown();
173 | Column = Regex.Match(TabToSpace(CurrentLine),@"\w").Index;
174 | }
175 | else
176 | Column = GetCharIndex(ColumnIndex) == '\t' ? Column+4 : Column+1;
177 |
178 | SetColumnIndex();
179 | }
180 |
181 | ///
182 | /// Inserts the line.
183 | ///
184 | /// Number line.
185 | public void InsertLine(int NumberLine)
186 | {
187 | this.Lines.Insert(NumberLine,new List());
188 | }
189 |
190 | ///
191 | /// Inserts the text.
192 | ///
193 | /// char
194 | public void InsertText(char c)
195 | {
196 | string StringJoin = this.CurrentLine;
197 |
198 | //Insert new Line
199 | if(c == '\n') {
200 |
201 | string LeftText = string.Empty;
202 | string RightText = string.Empty;
203 |
204 | for(int i = 0; i < StringJoin.Length; i++) {
205 | if(i >= this.ColumnIndex)
206 | RightText += StringJoin[i];
207 | else
208 | LeftText += StringJoin[i];
209 | }
210 |
211 | Match spaces = Regex.Match(LeftText, @"(^\t+)|(^\s+)");
212 |
213 | RightText = RightText.Insert(0,spaces.Value);
214 |
215 | UpdateLineText(Line,LeftText);
216 |
217 | InsertLine(Line);
218 |
219 | UpdateLineText(++Line,RightText);
220 |
221 | TotalLines++;
222 |
223 | //Jump cursor after indentation.
224 | Match Indentation = Regex.Match(TabToSpace(LeftText),@"\w");
225 | Column = Indentation.Success ? Indentation.Index : Column;
226 | SetColumnIndex();
227 |
228 | }else {
229 |
230 | //Insert a single char
231 | string newChar = (c.ToString());
232 |
233 | StringJoin = StringJoin.Insert(ColumnIndex, newChar);
234 |
235 | UpdateLineText(Line,StringJoin);
236 |
237 | Column = c == '\t' ? Column + 4 : ++Column;
238 | SetColumnIndex();
239 | }
240 | }
241 |
242 | ///
243 | /// Inserts the text interpreter.
244 | ///
245 | /// char
246 | public void InsertTextInterpreter(char c)
247 | {
248 | CurrentLine = CurrentLine.Insert(ColumnIndex,c.ToString());
249 | Column = c == '\t' ? Column + 4 : ++Column;
250 | SetColumnIndex();
251 | }
252 |
253 | ///
254 | /// Appends the interpreter.
255 | ///
256 | /// Output string
257 | public void AppendInterpreter(string output)
258 | {
259 | StringBuilder sb = new StringBuilder("\n"+InterpreterBuffer);
260 | string blockSeparator = this.BlockInspector ? "..." : ">>> ";
261 | string BreakLine = String.IsNullOrEmpty(output) ? "" : "\n";
262 | sb.Insert(0, output + BreakLine + blockSeparator + CurrentLine);
263 |
264 | InterpreterBuffer = sb.ToString();
265 | CurrentLine = string.Empty;
266 | SetColumnIndex();
267 | }
268 |
269 | ///
270 | /// Remove one char from line
271 | ///
272 | public void RemoveText()
273 | {
274 | if(!ElementInList(Line) && !InterpreterView)
275 | return;
276 |
277 | if(Column > 0) {
278 | //Remove single char.
279 | GoLeft();
280 | string LineTab = CurrentLine;
281 |
282 | LineTab = LineTab.Remove(Math.Max(0,ColumnIndex),1);
283 | UpdateLineText(Line,LineTab);
284 |
285 | }else if(!InterpreterView && Line != 1) {
286 | //Remove line.
287 | Lines[Line-2].Add(CurrentLine);
288 |
289 | Lines.RemoveAt(Line-1);
290 | GoUp();
291 |
292 | Column = GetLine(Line-1).IndexOf(CurrentLine);
293 | SetColumnIndex();
294 | }
295 | }
296 |
297 | ///
298 | /// Removes the range of text
299 | ///
300 | public void RemoveRange(int[] range)
301 | {
302 | CurrentLine = (CurrentLine).Remove(range[0],range[1]-range[0]);
303 |
304 | UpdateLineText(Line,CurrentLine);
305 |
306 | Column = range[0] + Regex.Matches(CurrentLine.Substring(0,range[0]),@"(\t)").Count*3;
307 | SetColumnIndex();
308 | }
309 |
310 | ///
311 | /// Updates the line text.
312 | ///
313 | /// Line number.
314 | /// Line text.
315 | private void UpdateLineText(int NumberLine, string LineText)
316 | {
317 | if(InterpreterView) {
318 | CurrentLine = LineText;
319 | return;
320 | }
321 |
322 | if(!ElementInList(NumberLine))
323 | return;
324 |
325 | Lines[NumberLine-1] = new List();
326 |
327 | foreach(Match results in Regex.Matches(LineText,@"(\t)|(\w+)|(\s+)|(.)"))
328 | Lines[NumberLine-1].Add(results.Value);
329 |
330 | CurrentLine = LineText;
331 | }
332 |
333 | ///
334 | /// Saves the code to memory.
335 | ///
336 | public void SaveCodeToBuffer()
337 | {
338 | StringBuilder text = new StringBuilder();
339 |
340 | foreach(List Line in Lines) {
341 | foreach(string word in Line)
342 | text.Append(word);
343 |
344 | text.AppendLine();
345 | }
346 |
347 | CodeBuffer = text.ToString();
348 | }
349 |
350 | ///
351 | /// Gets the index of the char.
352 | ///
353 | /// The char index.
354 | /// Index.
355 | public char GetCharIndex(int index)
356 | {
357 | return CurrentLine.ElementAtOrDefault(index);
358 | }
359 |
360 | ///
361 | /// Gets the line.
362 | ///
363 | /// The line.
364 | /// Number line.
365 | public string GetLine(int NumberLine)
366 | {
367 | if(!ElementInList(NumberLine))
368 | return string.Empty;
369 |
370 | return string.Join("",Lines[NumberLine-1].ToArray());
371 | }
372 |
373 | ///
374 | /// Elements the in list.
375 | ///
376 | /// true, if in list was elemented, false otherwise.
377 | /// Number line.
378 | private bool ElementInList(int NumberLine)
379 | {
380 | return this.Lines.ElementAtOrDefault(NumberLine-1) != null;
381 | }
382 |
383 | ///
384 | /// Limit Column of Cursor
385 | ///
386 | /// Column and Line position.
387 | public void Trim()
388 | {
389 | string line = CurrentLine.Replace("\t", " ");
390 |
391 | if(!InterpreterView) {
392 | Line = Line >= TotalLines ? TotalLines-1 : Line;
393 |
394 | Column = Column > line.Length ? line.Length : Column;
395 |
396 | } else
397 | Column = Column > line.Length ? CurrentLine.Length : Column;
398 |
399 | }
400 |
401 | ///
402 | /// Replace Tabs to whitespaces
403 | ///
404 | /// Value.
405 | private string TabToSpace(string value)
406 | {
407 | return value.Replace("\t", " ");
408 | }
409 |
410 | ///
411 | /// String Class representation
412 | ///
413 | /// string represented the current instance
414 | public override string ToString()
415 | {
416 | return string.Format("Line: {0}, Column: {1}, ColumnIndex: {2}, CurrentLine: {3}, TotalLine: {4}", Line, Column, ColumnIndex, CurrentLine, TotalLines);
417 | }
418 |
419 | }
420 |
--------------------------------------------------------------------------------
/ProjectSettings/ProjectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!129 &1
4 | PlayerSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 8
7 | AndroidProfiler: 0
8 | defaultScreenOrientation: 4
9 | targetDevice: 2
10 | useOnDemandResources: 0
11 | accelerometerFrequency: 60
12 | companyName: DefaultCompany
13 | productName: UnityIronPython
14 | defaultCursor: {fileID: 0}
15 | cursorHotspot: {x: 0, y: 0}
16 | m_ShowUnitySplashScreen: 1
17 | m_VirtualRealitySplashScreen: {fileID: 0}
18 | defaultScreenWidth: 1024
19 | defaultScreenHeight: 768
20 | defaultScreenWidthWeb: 960
21 | defaultScreenHeightWeb: 600
22 | m_RenderingPath: 1
23 | m_MobileRenderingPath: 1
24 | m_ActiveColorSpace: 0
25 | m_MTRendering: 1
26 | m_MobileMTRendering: 0
27 | m_Stereoscopic3D: 0
28 | iosShowActivityIndicatorOnLoading: -1
29 | androidShowActivityIndicatorOnLoading: -1
30 | iosAppInBackgroundBehavior: 0
31 | displayResolutionDialog: 1
32 | iosAllowHTTPDownload: 1
33 | allowedAutorotateToPortrait: 0
34 | allowedAutorotateToPortraitUpsideDown: 0
35 | allowedAutorotateToLandscapeRight: 1
36 | allowedAutorotateToLandscapeLeft: 1
37 | useOSAutorotation: 1
38 | use32BitDisplayBuffer: 1
39 | disableDepthAndStencilBuffers: 0
40 | defaultIsFullScreen: 1
41 | defaultIsNativeResolution: 1
42 | runInBackground: 0
43 | captureSingleScreen: 0
44 | Override IPod Music: 0
45 | Prepare IOS For Recording: 0
46 | submitAnalytics: 1
47 | usePlayerLog: 1
48 | bakeCollisionMeshes: 0
49 | forceSingleInstance: 0
50 | resizableWindow: 0
51 | useMacAppStoreValidation: 0
52 | gpuSkinning: 0
53 | xboxPIXTextureCapture: 0
54 | xboxEnableAvatar: 0
55 | xboxEnableKinect: 0
56 | xboxEnableKinectAutoTracking: 0
57 | xboxEnableFitness: 0
58 | visibleInBackground: 0
59 | allowFullscreenSwitch: 1
60 | macFullscreenMode: 2
61 | d3d9FullscreenMode: 1
62 | d3d11FullscreenMode: 1
63 | xboxSpeechDB: 0
64 | xboxEnableHeadOrientation: 0
65 | xboxEnableGuest: 0
66 | xboxEnablePIXSampling: 0
67 | n3dsDisableStereoscopicView: 0
68 | n3dsEnableSharedListOpt: 1
69 | n3dsEnableVSync: 0
70 | uiUse16BitDepthBuffer: 0
71 | ignoreAlphaClear: 0
72 | xboxOneResolution: 0
73 | ps3SplashScreen: {fileID: 0}
74 | videoMemoryForVertexBuffers: 0
75 | psp2PowerMode: 0
76 | psp2AcquireBGM: 1
77 | wiiUTVResolution: 0
78 | wiiUGamePadMSAA: 1
79 | wiiUSupportsNunchuk: 0
80 | wiiUSupportsClassicController: 0
81 | wiiUSupportsBalanceBoard: 0
82 | wiiUSupportsMotionPlus: 0
83 | wiiUSupportsProController: 0
84 | wiiUAllowScreenCapture: 1
85 | wiiUControllerCount: 0
86 | m_SupportedAspectRatios:
87 | 4:3: 1
88 | 5:4: 1
89 | 16:10: 1
90 | 16:9: 1
91 | Others: 1
92 | bundleIdentifier: com.unity.IronPython
93 | bundleVersion: 1.0
94 | preloadedAssets: []
95 | metroEnableIndependentInputSource: 0
96 | metroEnableLowLatencyPresentationAPI: 0
97 | xboxOneDisableKinectGpuReservation: 0
98 | virtualRealitySupported: 0
99 | productGUID: f4c01287c79a1463f91efb7a97a10358
100 | AndroidBundleVersionCode: 1
101 | AndroidMinSdkVersion: 9
102 | AndroidPreferredInstallLocation: 1
103 | aotOptions:
104 | apiCompatibilityLevel: 1
105 | stripEngineCode: 1
106 | iPhoneStrippingLevel: 0
107 | iPhoneScriptCallOptimization: 0
108 | iPhoneBuildNumber: 0
109 | ForceInternetPermission: 0
110 | ForceSDCardPermission: 0
111 | CreateWallpaper: 0
112 | APKExpansionFiles: 0
113 | preloadShaders: 0
114 | StripUnusedMeshComponents: 0
115 | VertexChannelCompressionMask:
116 | serializedVersion: 2
117 | m_Bits: 238
118 | iPhoneSdkVersion: 989
119 | iPhoneTargetOSVersion: 26
120 | uIPrerenderedIcon: 0
121 | uIRequiresPersistentWiFi: 0
122 | uIRequiresFullScreen: 1
123 | uIStatusBarHidden: 1
124 | uIExitOnSuspend: 0
125 | uIStatusBarStyle: 0
126 | iPhoneSplashScreen: {fileID: 0}
127 | iPhoneHighResSplashScreen: {fileID: 0}
128 | iPhoneTallHighResSplashScreen: {fileID: 0}
129 | iPhone47inSplashScreen: {fileID: 0}
130 | iPhone55inPortraitSplashScreen: {fileID: 0}
131 | iPhone55inLandscapeSplashScreen: {fileID: 0}
132 | iPadPortraitSplashScreen: {fileID: 0}
133 | iPadHighResPortraitSplashScreen: {fileID: 0}
134 | iPadLandscapeSplashScreen: {fileID: 0}
135 | iPadHighResLandscapeSplashScreen: {fileID: 0}
136 | appleTVSplashScreen: {fileID: 0}
137 | tvOSSmallIconLayers: []
138 | tvOSLargeIconLayers: []
139 | tvOSTopShelfImageLayers: []
140 | iOSLaunchScreenType: 0
141 | iOSLaunchScreenPortrait: {fileID: 0}
142 | iOSLaunchScreenLandscape: {fileID: 0}
143 | iOSLaunchScreenBackgroundColor:
144 | serializedVersion: 2
145 | rgba: 0
146 | iOSLaunchScreenFillPct: 1
147 | iOSLaunchScreenSize: 100
148 | iOSLaunchScreenCustomXibPath:
149 | iOSLaunchScreeniPadType: 0
150 | iOSLaunchScreeniPadImage: {fileID: 0}
151 | iOSLaunchScreeniPadBackgroundColor:
152 | serializedVersion: 2
153 | rgba: 0
154 | iOSLaunchScreeniPadFillPct: 100
155 | iOSLaunchScreeniPadSize: 100
156 | iOSLaunchScreeniPadCustomXibPath:
157 | iOSDeviceRequirements: []
158 | AndroidTargetDevice: 0
159 | AndroidSplashScreenScale: 0
160 | androidSplashScreen: {fileID: 0}
161 | AndroidKeystoreName:
162 | AndroidKeyaliasName:
163 | AndroidTVCompatibility: 1
164 | AndroidIsGame: 1
165 | androidEnableBanner: 1
166 | m_AndroidBanners:
167 | - width: 320
168 | height: 180
169 | banner: {fileID: 0}
170 | androidGamepadSupportLevel: 0
171 | resolutionDialogBanner: {fileID: 0}
172 | m_BuildTargetIcons:
173 | - m_BuildTarget:
174 | m_Icons:
175 | - serializedVersion: 2
176 | m_Icon: {fileID: 0}
177 | m_Width: 128
178 | m_Height: 128
179 | m_BuildTargetBatching: []
180 | m_BuildTargetGraphicsAPIs: []
181 | webPlayerTemplate: APPLICATION:Default
182 | m_TemplateCustomTags: {}
183 | wiiUTitleID: 0005000011000000
184 | wiiUGroupID: 00010000
185 | wiiUCommonSaveSize: 4096
186 | wiiUAccountSaveSize: 2048
187 | wiiUOlvAccessKey: 0
188 | wiiUTinCode: 0
189 | wiiUJoinGameId: 0
190 | wiiUJoinGameModeMask: 0000000000000000
191 | wiiUCommonBossSize: 0
192 | wiiUAccountBossSize: 0
193 | wiiUAddOnUniqueIDs: []
194 | wiiUMainThreadStackSize: 3072
195 | wiiULoaderThreadStackSize: 1024
196 | wiiUSystemHeapSize: 128
197 | wiiUTVStartupScreen: {fileID: 0}
198 | wiiUGamePadStartupScreen: {fileID: 0}
199 | wiiUProfilerLibPath:
200 | actionOnDotNetUnhandledException: 1
201 | enableInternalProfiler: 0
202 | logObjCUncaughtExceptions: 1
203 | enableCrashReportAPI: 0
204 | locationUsageDescription:
205 | XboxTitleId:
206 | XboxImageXexPath:
207 | XboxSpaPath:
208 | XboxGenerateSpa: 0
209 | XboxDeployKinectResources: 0
210 | XboxSplashScreen: {fileID: 0}
211 | xboxEnableSpeech: 0
212 | xboxAdditionalTitleMemorySize: 0
213 | xboxDeployKinectHeadOrientation: 0
214 | xboxDeployKinectHeadPosition: 0
215 | ps3TitleConfigPath:
216 | ps3DLCConfigPath:
217 | ps3ThumbnailPath:
218 | ps3BackgroundPath:
219 | ps3SoundPath:
220 | ps3NPAgeRating: 12
221 | ps3TrophyCommId:
222 | ps3NpCommunicationPassphrase:
223 | ps3TrophyPackagePath:
224 | ps3BootCheckMaxSaveGameSizeKB: 128
225 | ps3TrophyCommSig:
226 | ps3SaveGameSlots: 1
227 | ps3TrialMode: 0
228 | ps3VideoMemoryForAudio: 0
229 | ps3EnableVerboseMemoryStats: 0
230 | ps3UseSPUForUmbra: 0
231 | ps3EnableMoveSupport: 1
232 | ps3DisableDolbyEncoding: 0
233 | ps4NPAgeRating: 12
234 | ps4NPTitleSecret:
235 | ps4NPTrophyPackPath:
236 | ps4ParentalLevel: 1
237 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000
238 | ps4Category: 0
239 | ps4MasterVersion: 01.00
240 | ps4AppVersion: 01.00
241 | ps4AppType: 0
242 | ps4ParamSfxPath:
243 | ps4VideoOutPixelFormat: 0
244 | ps4VideoOutResolution: 4
245 | ps4PronunciationXMLPath:
246 | ps4PronunciationSIGPath:
247 | ps4BackgroundImagePath:
248 | ps4StartupImagePath:
249 | ps4SaveDataImagePath:
250 | ps4SdkOverride:
251 | ps4BGMPath:
252 | ps4ShareFilePath:
253 | ps4ShareOverlayImagePath:
254 | ps4PrivacyGuardImagePath:
255 | ps4NPtitleDatPath:
256 | ps4RemotePlayKeyAssignment: -1
257 | ps4RemotePlayKeyMappingDir:
258 | ps4EnterButtonAssignment: 1
259 | ps4ApplicationParam1: 0
260 | ps4ApplicationParam2: 0
261 | ps4ApplicationParam3: 0
262 | ps4ApplicationParam4: 0
263 | ps4DownloadDataSize: 0
264 | ps4GarlicHeapSize: 2048
265 | ps4Passcode: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE
266 | ps4pnSessions: 1
267 | ps4pnPresence: 1
268 | ps4pnFriends: 1
269 | ps4pnGameCustomData: 1
270 | playerPrefsSupport: 0
271 | ps4ReprojectionSupport: 0
272 | ps4UseAudio3dBackend: 0
273 | ps4SocialScreenEnabled: 0
274 | ps4Audio3dVirtualSpeakerCount: 14
275 | ps4attribCpuUsage: 0
276 | ps4PatchPkgPath:
277 | ps4PatchLatestPkgPath:
278 | ps4PatchChangeinfoPath:
279 | ps4attribUserManagement: 0
280 | ps4attribMoveSupport: 0
281 | ps4attrib3DSupport: 0
282 | ps4attribShareSupport: 0
283 | ps4IncludedModules: []
284 | monoEnv:
285 | psp2Splashimage: {fileID: 0}
286 | psp2NPTrophyPackPath:
287 | psp2NPSupportGBMorGJP: 0
288 | psp2NPAgeRating: 12
289 | psp2NPTitleDatPath:
290 | psp2NPCommsID:
291 | psp2NPCommunicationsID:
292 | psp2NPCommsPassphrase:
293 | psp2NPCommsSig:
294 | psp2ParamSfxPath:
295 | psp2ManualPath:
296 | psp2LiveAreaGatePath:
297 | psp2LiveAreaBackroundPath:
298 | psp2LiveAreaPath:
299 | psp2LiveAreaTrialPath:
300 | psp2PatchChangeInfoPath:
301 | psp2PatchOriginalPackage:
302 | psp2PackagePassword: RK5RhRXdCdG5nG5azdNMK66MuCV6GXi5
303 | psp2KeystoneFile:
304 | psp2MemoryExpansionMode: 0
305 | psp2DRMType: 0
306 | psp2StorageType: 0
307 | psp2MediaCapacity: 0
308 | psp2DLCConfigPath:
309 | psp2ThumbnailPath:
310 | psp2BackgroundPath:
311 | psp2SoundPath:
312 | psp2TrophyCommId:
313 | psp2TrophyPackagePath:
314 | psp2PackagedResourcesPath:
315 | psp2SaveDataQuota: 10240
316 | psp2ParentalLevel: 1
317 | psp2ShortTitle: Not Set
318 | psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF
319 | psp2Category: 0
320 | psp2MasterVersion: 01.00
321 | psp2AppVersion: 01.00
322 | psp2TVBootMode: 0
323 | psp2EnterButtonAssignment: 2
324 | psp2TVDisableEmu: 0
325 | psp2AllowTwitterDialog: 1
326 | psp2Upgradable: 0
327 | psp2HealthWarning: 0
328 | psp2UseLibLocation: 0
329 | psp2InfoBarOnStartup: 0
330 | psp2InfoBarColor: 0
331 | psmSplashimage: {fileID: 0}
332 | spritePackerPolicy:
333 | scriptingDefineSymbols: {}
334 | metroPackageName: UnityIronPython
335 | metroPackageVersion:
336 | metroCertificatePath:
337 | metroCertificatePassword:
338 | metroCertificateSubject:
339 | metroCertificateIssuer:
340 | metroCertificateNotAfter: 0000000000000000
341 | metroApplicationDescription: UnityIronPython
342 | wsaImages: {}
343 | metroTileShortName:
344 | metroCommandLineArgsFile:
345 | metroTileShowName: 0
346 | metroMediumTileShowName: 0
347 | metroLargeTileShowName: 0
348 | metroWideTileShowName: 0
349 | metroDefaultTileSize: 1
350 | metroTileForegroundText: 1
351 | metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1}
352 | metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1}
353 | metroSplashScreenUseBackgroundColor: 0
354 | platformCapabilities: {}
355 | metroFTAName:
356 | metroFTAFileTypes: []
357 | metroProtocolName:
358 | metroCompilationOverrides: 1
359 | blackberryDeviceAddress:
360 | blackberryDevicePassword:
361 | blackberryTokenPath:
362 | blackberryTokenExires:
363 | blackberryTokenAuthor:
364 | blackberryTokenAuthorId:
365 | blackberryCskPassword:
366 | blackberrySaveLogPath:
367 | blackberrySharedPermissions: 0
368 | blackberryCameraPermissions: 0
369 | blackberryGPSPermissions: 0
370 | blackberryDeviceIDPermissions: 0
371 | blackberryMicrophonePermissions: 0
372 | blackberryGamepadSupport: 0
373 | blackberryBuildId: 0
374 | blackberryLandscapeSplashScreen: {fileID: 0}
375 | blackberryPortraitSplashScreen: {fileID: 0}
376 | blackberrySquareSplashScreen: {fileID: 0}
377 | tizenProductDescription:
378 | tizenProductURL:
379 | tizenSigningProfileName:
380 | tizenGPSPermissions: 0
381 | tizenMicrophonePermissions: 0
382 | n3dsUseExtSaveData: 0
383 | n3dsCompressStaticMem: 1
384 | n3dsExtSaveDataNumber: 0x12345
385 | n3dsStackSize: 131072
386 | n3dsTargetPlatform: 2
387 | n3dsRegion: 7
388 | n3dsMediaSize: 0
389 | n3dsLogoStyle: 3
390 | n3dsTitle: GameName
391 | n3dsProductCode:
392 | n3dsApplicationId: 0xFF3FF
393 | stvDeviceAddress:
394 | stvProductDescription:
395 | stvProductAuthor:
396 | stvProductAuthorEmail:
397 | stvProductLink:
398 | stvProductCategory: 0
399 | XboxOneProductId:
400 | XboxOneUpdateKey:
401 | XboxOneSandboxId:
402 | XboxOneContentId:
403 | XboxOneTitleId:
404 | XboxOneSCId:
405 | XboxOneGameOsOverridePath:
406 | XboxOnePackagingOverridePath:
407 | XboxOneAppManifestOverridePath:
408 | XboxOnePackageEncryption: 0
409 | XboxOnePackageUpdateGranularity: 2
410 | XboxOneDescription:
411 | XboxOneIsContentPackage: 0
412 | XboxOneEnableGPUVariability: 0
413 | XboxOneSockets: {}
414 | XboxOneSplashScreen: {fileID: 0}
415 | XboxOneAllowedProductIds: []
416 | XboxOnePersistentLocalStorageSize: 0
417 | intPropertyNames:
418 | - Android::ScriptingBackend
419 | - Standalone::ScriptingBackend
420 | - WebGL::ScriptingBackend
421 | - WebGL::audioCompressionFormat
422 | - WebGL::exceptionSupport
423 | - WebGL::memorySize
424 | - iOS::Architecture
425 | - iOS::EnableIncrementalBuildSupportForIl2cpp
426 | - iOS::ScriptingBackend
427 | - tvOS::Architecture
428 | - tvOS::EnableIncrementalBuildSupportForIl2cpp
429 | - tvOS::ScriptingBackend
430 | Android::ScriptingBackend: 0
431 | Standalone::ScriptingBackend: 0
432 | WebGL::ScriptingBackend: 1
433 | WebGL::audioCompressionFormat: 4
434 | WebGL::exceptionSupport: 0
435 | WebGL::memorySize: 256
436 | iOS::Architecture: 2
437 | iOS::EnableIncrementalBuildSupportForIl2cpp: 1
438 | iOS::ScriptingBackend: 0
439 | tvOS::Architecture: 1
440 | tvOS::EnableIncrementalBuildSupportForIl2cpp: 0
441 | tvOS::ScriptingBackend: 1
442 | boolPropertyNames:
443 | - WebGL::analyzeBuildSize
444 | - WebGL::dataCaching
445 | - WebGL::useEmbeddedResources
446 | WebGL::analyzeBuildSize: 0
447 | WebGL::dataCaching: 0
448 | WebGL::useEmbeddedResources: 0
449 | stringPropertyNames:
450 | - WebGL::emscriptenArgs
451 | - WebGL::template
452 | - additionalIl2CppArgs::additionalIl2CppArgs
453 | WebGL::emscriptenArgs:
454 | WebGL::template: APPLICATION:Default
455 | additionalIl2CppArgs::additionalIl2CppArgs:
456 | cloudProjectId:
457 | projectName:
458 | organizationId:
459 | cloudEnabled: 0
460 |
--------------------------------------------------------------------------------
/Assets/src/editor/EditorView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using UnityEditor;
5 | using UnityEngine;
6 | using System.Collections.Generic;
7 | using System.Text.RegularExpressions;
8 |
9 | [Serializable]
10 | public class EditorView
11 | {
12 |
13 | protected PythonBase CurrentTarget;
14 |
15 | public Code Buffer;
16 |
17 | [SerializeField]
18 | private Rect HighLine, HighLightSelection, LayoutRect, PositionSyntax;
19 |
20 | [SerializeField]
21 | private Vector2 PositionScroll = Vector2.zero;
22 |
23 | [SerializeField]
24 | private Vector2 Padding = new Vector2(44, 15);
25 |
26 | [SerializeField]
27 | private Vector2 FontSizeXY = new Vector2(9, 19);
28 |
29 | [SerializeField]
30 | private int FocusID;
31 |
32 | [SerializeField]
33 | private bool isSelection, Focused;
34 |
35 | public bool InterpreterView;
36 |
37 | private float Bottom;
38 |
39 | private Interpreter PythonMachine = new Interpreter();
40 |
41 | ///
42 | /// Use for match code
43 | ///
44 | private const string MatchCode = @"(\t)|(\w+)|(\s+)|(.)";
45 |
46 | private EditorViewStyles Style = new EditorViewStyles();
47 |
48 | //Delegate For Repaint Inspector.
49 | public delegate void CodeRepaint();
50 |
51 | public event CodeRepaint RepaintAction;
52 |
53 | ///
54 | /// Enable
55 | ///
56 | public void OnEnable(UnityEngine.Object ObjectReference)
57 | {
58 |
59 | CurrentTarget = (PythonBase)ObjectReference;
60 |
61 | if(Buffer == null)
62 | Buffer = ScriptableObject.CreateInstance();
63 |
64 | if(CurrentTarget.InMemory)
65 | //Load buffer from Memory
66 | Buffer = EditorDataBase.Instance.GetInstance(CurrentTarget.GetInstanceID());
67 |
68 | else if(CurrentTarget.FileCreated)
69 | //Load buffer from file
70 | LoadFileStream();
71 | else
72 | //Load buffer by default
73 | Buffer.Initialize();
74 | }
75 |
76 | private void LoadFileStream()
77 | {
78 | try {
79 | StreamReader file = new StreamReader(CurrentTarget.FilePath,
80 | System.Text.Encoding.UTF8);
81 |
82 | Buffer.CodeBuffer = file.ReadToEnd();
83 | } catch(Exception ex) {
84 | //Show Message error
85 | PythonInspector.DialogError(ex.Message);
86 |
87 | CurrentTarget.Reset();
88 | }
89 | }
90 |
91 | ///
92 | /// Editors the view controll.
93 | ///
94 | public void EditorViewGUI(bool IsInterpreter)
95 | {
96 | //Get box rect and background
97 | GetBoxRect();
98 | //Begin ScrollView of box
99 | PositionScroll = GUI.BeginScrollView(new Rect(0, LayoutRect.y, LayoutRect.width + 15, LayoutRect.height),
100 | PositionScroll, new Rect(0, LayoutRect.yMin, 800, 23 * Buffer.TotalLines));
101 | //Draw Line Numbers.
102 | EventRepainted();
103 | //Draw Cursor for text
104 | Cursor();
105 | //HighLight Current Line.
106 | HighlighLine();
107 | //HightLigh Selection Text
108 | HighlighSelected();
109 |
110 | GUI.EndScrollView();
111 |
112 | if(InterpreterView)
113 | DrawInterpreter();
114 | //KeyBoard Events
115 | KeyBoardController();
116 | }
117 |
118 | ///
119 | /// Events the repainted.
120 | ///
121 | private void EventRepainted()
122 | {
123 | if(Event.current.type == EventType.repaint)
124 | {
125 | if(!InterpreterView)
126 | //Draw Code on Inspector
127 | DrawCodeOnGUI();
128 | else
129 | DrawInterpreterOnGUI();
130 |
131 | //Draw Number of Lines
132 | LineNumbers();
133 |
134 | //Trim Column to end of lines
135 | Buffer.Trim();
136 |
137 | }
138 | }
139 |
140 | private void GetBoxRect()
141 | {
142 | //Code Rect Layout
143 | PositionSyntax = LayoutRect = GUILayoutUtility.GetRect(0, Screen.width, 1, Screen.height - Padding.y);
144 |
145 | //Background ColorScheme
146 | GUI.Box(LayoutRect, GUIContent.none, Style.Background);
147 |
148 | //Bottom value of box
149 | Bottom = LayoutRect.yMax-40;
150 | }
151 |
152 | ///
153 | /// Draws code on Inspector
154 | ///
155 | private void DrawCodeOnGUI()
156 | {
157 | if(Buffer.Lines.Count == 0) {
158 | Buffer.Lines = new List>();
159 |
160 | using(StringReader readerLine = new StringReader(Buffer.CodeBuffer)) {
161 |
162 | string line = string.Empty;
163 |
164 | while((line = readerLine.ReadLine()) != null) {
165 |
166 | List words = new List();
167 |
168 | Regex pattern = new Regex(MatchCode);
169 |
170 | foreach(Match results in pattern.Matches(line))
171 | words.Add(results.Value);
172 |
173 | Buffer.Lines.Add(words);
174 | }
175 | }
176 |
177 | if(Buffer.CodeBuffer == string.Empty)
178 | Buffer.Lines.Add(new List());
179 | }
180 |
181 | Buffer.TotalLines = 1;
182 | PositionSyntax.y += 5;
183 |
184 | Style.BlockComment = false;
185 |
186 | for(int i = 0; i < Buffer.Lines.Count; i++) {
187 |
188 | PositionSyntax.x = Padding.x;
189 |
190 | //Reset Lines styles
191 | Style.ResetLineStyles();
192 |
193 | for(int j = 0; j < Buffer.Lines[i].Count; j++) {
194 |
195 | string word = TabToSpace(Buffer.Lines[i][j]);
196 |
197 | PositionSyntax.width = FontSizeXY.x * word.Length;
198 |
199 | Style.FontGUIStyle.normal.textColor = Style.CheckWordStyle(word);
200 |
201 | //Draw word in GUI Label
202 | GUI.Label(PositionSyntax, word, Style.FontGUIStyle);
203 |
204 | PositionSyntax.x += PositionSyntax.width;
205 |
206 | }
207 | Buffer.TotalLines++;
208 | PositionSyntax.y += FontSizeXY.y;
209 | }
210 | }
211 |
212 | ///
213 | /// Draws the interpreter on GU.
214 | ///
215 | private void DrawInterpreterOnGUI()
216 | {
217 | PositionSyntax.y = Bottom;
218 |
219 | PositionSyntax.x = 45;
220 |
221 | GUI.Label(PositionSyntax,TabToSpace(Buffer.CurrentLine),Style.FontGUIStyle);
222 |
223 | PositionSyntax.y -= FontSizeXY.y + 10;
224 |
225 | using(StringReader readerLine = new StringReader(Buffer.InterpreterBuffer)) {
226 |
227 | string line = string.Empty;
228 |
229 | while((line = readerLine.ReadLine()) != null) {
230 |
231 | PositionSyntax.x = 20;
232 |
233 | line = TabToSpace(line);
234 |
235 | PositionSyntax.width = FontSizeXY.x * line.Length;
236 |
237 | GUI.Label(PositionSyntax,line,Style.FontGUIStyle);
238 |
239 | PositionSyntax.y -= FontSizeXY.y;
240 |
241 | }
242 | }
243 | }
244 |
245 | private void DrawInterpreter()
246 | {
247 | isSelection = false;
248 |
249 | Rect Pointer = new Rect(18,Bottom,50,10);
250 |
251 | Style.FontGUIStyle.normal.textColor = Color.white;
252 |
253 | //Separate line
254 | GUI.Box(new Rect(0, Bottom-7, Screen.width , 1), GUIContent.none, Style.BackgroundLines);
255 | GUI.Label(Pointer, Buffer.BlockInspector ? "..." : ">>>", Style.Interpreter);
256 | }
257 |
258 | public void InitializeInterpreter()
259 | {
260 | float PointerX = Mathf.Max(Padding.x+15, Event.current.mousePosition.x);
261 |
262 | Vector2 VectorXY = ToNumberLine(PointerX, 0);
263 |
264 | Buffer.Line = 0;
265 | Buffer.TotalLines = 0;
266 | Buffer.Column = (int)VectorXY.x;
267 | Buffer.SetColumnIndex();
268 |
269 | Repaint();
270 | }
271 |
272 | ///
273 | /// Draw Line Numbers
274 | ///
275 | private void LineNumbers()
276 | {
277 | //Background Lines
278 | GUI.Box(new Rect(PositionScroll.x, LayoutRect.y, InterpreterView ? 15 : 40 , Screen.height + PositionScroll.y), GUIContent.none, Style.BackgroundLines);
279 |
280 | if(InterpreterView)
281 | return;
282 |
283 | Rect RectLineNumbers = new Rect(PositionScroll.x + 3, LayoutRect.y + 5, 30, LayoutRect.height - Padding.y);
284 | for(int i = 1; i <= Buffer.TotalLines+(int)(PositionScroll.y / Buffer.TotalLines-1); i++) {
285 |
286 | //Draw number.
287 | Style.NumberLines.Draw(RectLineNumbers, new GUIContent(i.ToString()), true, false, false, false);
288 | //Increase line height.
289 | RectLineNumbers.y += FontSizeXY.y;
290 |
291 | }
292 | }
293 |
294 | ///
295 | /// Cursors
296 | ///
297 | public void Cursor()
298 | {
299 | //Cursor for Editing Text.
300 | EditorGUIUtility.AddCursorRect(new Rect(LayoutRect.x, LayoutRect.y, LayoutRect.width + PositionScroll.x, LayoutRect.height - 15), MouseCursor.Text);
301 |
302 | if(!isSelection) {
303 |
304 | Vector2 PositionCursor = ToPixelLine(new Vector2(Buffer.Column,Buffer.Line));
305 |
306 | Rect CursorRect = new Rect(PositionCursor.x, !InterpreterView ? PositionCursor.y : Bottom, 1, FontSizeXY.y);
307 |
308 | GUI.Box(CursorRect, GUIContent.none, Style.Cursor);
309 |
310 | }
311 | }
312 |
313 | ///
314 | /// Highlight line clicked
315 | ///
316 | private void HighlighLine()
317 | {
318 | if(Event.current.type == EventType.MouseDown)
319 | {
320 |
321 | if(!InterpreterView) {
322 | //Mouse Position X Y
323 | float PointerX = Event.current.mousePosition.x;
324 | float PointerY = Event.current.mousePosition.y;
325 |
326 | Vector2 VectorXY = ToNumberLine(PointerX, PointerY);
327 |
328 | Buffer.Initialize((int)VectorXY.y, (int)VectorXY.x);
329 |
330 | isSelection = false;
331 |
332 | Repaint();
333 | }
334 | }
335 |
336 | if(InterpreterView)
337 | return;
338 |
339 | float LinePixel = ToPixelLine(new Vector2(Buffer.Column,Buffer.Line)).y;
340 | HighLine = new Rect(0, LinePixel, Screen.width, FontSizeXY.y);
341 |
342 | HighLine.width = Screen.width + PositionScroll.x;
343 |
344 | if(!isSelection)
345 | GUI.Box(HighLine, GUIContent.none, Style.HighLine);
346 |
347 | }
348 |
349 | ///
350 | /// Highlighs the selected.
351 | ///
352 | private void HighlighSelected()
353 | {
354 | //Double Cliked (select a single word)
355 | if(Event.current.type == EventType.MouseDown && Event.current.clickCount == 2)
356 | {
357 | isSelection = true;
358 |
359 | string LineSpace = TabToSpace(Buffer.CurrentLine);
360 |
361 | //Selected Word
362 | int begin = 0, index = 0;
363 | float width = 0;
364 | //Extract single word
365 | foreach(Match word in Regex.Matches(LineSpace,MatchCode)) {
366 | if(width == 0)
367 | for(int i = 0; i < word.Length; i++) {
368 |
369 | //Begin of word
370 | begin = i == 0 ? index : begin;
371 | //word width
372 | width = index == Buffer.Column ? word.Length : 0;
373 |
374 | index = width == 0 ? index+1 : index;
375 | }
376 | }
377 |
378 | Vector2 Pixels = ToPixelLine(new Vector2(begin,Buffer.Line));
379 | width *= FontSizeXY.x;
380 |
381 | HighLightSelection = new Rect(Pixels.x,Pixels.y,width,FontSizeXY.y);
382 |
383 | }
384 | //TODO
385 | if(Event.current.type == EventType.dragUpdated) { }
386 |
387 | //Draw Selection
388 | if(isSelection)
389 | GUI.Box(HighLightSelection, GUIContent.none, Style.HighLine);
390 | }
391 |
392 | ///
393 | /// Focus of Code Editor
394 | ///
395 | private void FocusControl()
396 | {
397 | //TODO: FIX!
398 | GUIUtility.keyboardControl = FocusID;
399 |
400 | FocusID = GUIUtility.GetControlID(Math.Abs(GetHashCode()), FocusType.Keyboard);
401 |
402 | GUIUtility.keyboardControl = Focused ? FocusID : GUIUtility.keyboardControl;
403 |
404 | Focused = (FocusID > 0) ?
405 | (GUIUtility.keyboardControl == FocusID) : false;
406 |
407 | }
408 |
409 | ///
410 | /// Keies the board controller.
411 | ///
412 | public void KeyBoardController()
413 | {
414 | Event e = Event.current;
415 |
416 | if(e.type == EventType.keyDown)
417 | {
418 |
419 | switch(e.keyCode)
420 | {
421 | case KeyCode.Backspace:
422 |
423 | if(!isSelection)
424 | Buffer.RemoveText();
425 | else
426 | Buffer.RemoveRange(GetRangeText(HighLightSelection,Buffer.CurrentLine));
427 |
428 |
429 | SetChanges();
430 |
431 | isSelection = false;
432 | break;
433 |
434 | case KeyCode.Return:
435 | case KeyCode.KeypadEnter:
436 |
437 | if(InterpreterView) {
438 | ExecuteInterpreter();
439 | return;
440 | }
441 | break;
442 |
443 | case KeyCode.UpArrow:
444 |
445 | Buffer.GoUp();
446 |
447 | break;
448 |
449 | case KeyCode.DownArrow:
450 | Buffer.GoDown();
451 | break;
452 |
453 | case KeyCode.LeftArrow:
454 | Buffer.GoLeft();
455 | break;
456 |
457 | case KeyCode.RightArrow:
458 | Buffer.GoRight();
459 | break;
460 |
461 | //Get any Key.
462 | case KeyCode.None:
463 | char c = Convert.ToChar(e.character.ToString());
464 | c = e.shift ? char.ToUpper(c) : c;
465 | //Remove Text if has selection text.
466 | if(isSelection)
467 | {
468 | Buffer.RemoveRange(GetRangeText(HighLightSelection,Buffer.CurrentLine));
469 | isSelection = false;
470 | }
471 | if(!InterpreterView)
472 | Buffer.InsertText(c);
473 |
474 | else if(c != '\n')
475 | Buffer.InsertTextInterpreter(c);
476 |
477 | SetChanges();
478 | break;
479 |
480 | }
481 |
482 | e.Use();
483 | }
484 | }
485 |
486 | ///
487 | /// Executes the interpreter.
488 | ///
489 | private void ExecuteInterpreter()
490 | {
491 | string line = Buffer.CurrentLine.TrimEnd();
492 | // Append and return if is a block code
493 | if(!String.IsNullOrEmpty(line) &&
494 | line.Substring(line.Length-1, 1) == ":" && !Buffer.BlockInspector) {
495 | Buffer.InterpreterBlock = line;
496 | Buffer.AppendInterpreter("");
497 | Buffer.BlockInspector = true;
498 | return;
499 | }
500 | if(!Buffer.BlockInspector) {
501 | //Executes a single line
502 | string output = PythonMachine.Compile(Buffer.CurrentLine);
503 | Buffer.AppendInterpreter(output);
504 |
505 | }else {
506 | //Block Code (eg.: if 5 < 10: )
507 | if(string.IsNullOrEmpty(line)) {
508 | //Execute block when enter a blank line
509 | string output = PythonMachine.Compile(Buffer.InterpreterBlock);
510 | Buffer.AppendInterpreter(output);
511 | //Empties current block
512 | Buffer.InterpreterBlock = string.Empty;
513 | Buffer.BlockInspector = false;
514 | }else {
515 | //stores current block code.
516 | Buffer.InterpreterBlock += "\n" + line;
517 | Buffer.AppendInterpreter("");
518 | }
519 | }
520 | }
521 |
522 | ///
523 | /// Sets the changes.
524 | ///
525 | private void SetChanges()
526 | {
527 | if(!InterpreterView) {
528 | CurrentTarget.Saved = false;
529 | CurrentTarget.HasChanges = true;
530 | Buffer.SaveCodeToBuffer();
531 | }
532 | }
533 | ///
534 | /// Gets the range text selected
535 | ///
536 | /// Array int X Y
537 | /// Range of Selection
538 | /// Text
539 | private int[] GetRangeText(Rect range, string text)
540 | {
541 | //Transform selection rect to coordenadies column number
542 | Vector2 RangeMin = ToNumberLine(range.xMin, range.y);
543 | Vector2 RangeMax = ToNumberLine(range.xMax, range.y);
544 |
545 | int begin = Buffer.GetIndexColumn((int)RangeMin.x,text);
546 | int end = Buffer.GetIndexColumn((int)RangeMax.x,text);
547 |
548 | return new int[]{ begin, end };
549 | }
550 |
551 | ///
552 | /// Convert mouse position to line number
553 | ///
554 | /// Return PositionXY with Column Line Number (X) and Number Line (y)
555 | public Vector2 ToNumberLine(float column, float line)
556 | {
557 | line = Math.Min((line - LayoutRect.y + Padding.y) / FontSizeXY.y,Buffer.TotalLines-1);
558 |
559 | column = (column - Padding.x) / FontSizeXY.x;
560 |
561 | line = line == 0 ? 1 : line;
562 |
563 | return new Vector2(column,line);
564 | }
565 |
566 | ///
567 | /// Convert Line Number to Pixel for Inspector.
568 | ///
569 | /// The pixel line.
570 | /// Column.
571 | public Vector2 ToPixelLine(Vector2 PositionLine)
572 | {
573 | //Calculate the column position times the font size plus padding spacing;
574 | int Column = (int)((FontSizeXY.x * PositionLine.x) + Padding.x);
575 | int Line = (int)((FontSizeXY.y * PositionLine.y+1) + LayoutRect.y - Padding.y);
576 |
577 | //Limit the column position to padding spacing;
578 | Column = (int)(Column < Padding.x ? Padding.x : Column);
579 |
580 | //Limit begin of line
581 | Line = (int)(Line < LayoutRect.yMin ? LayoutRect.yMin+5 : Line);
582 |
583 | return new Vector2(Column,Line);
584 | }
585 |
586 | ///
587 | /// Replace Tabs to whitespaces
588 | ///
589 | /// Value.
590 | private string TabToSpace(string value)
591 | {
592 | return value.Replace("\t", " ");
593 | }
594 |
595 | ///
596 | /// Repaint inspector
597 | ///
598 | private void Repaint()
599 | {
600 | if(RepaintAction != null)
601 | RepaintAction();
602 | }
603 |
604 | }
605 |
--------------------------------------------------------------------------------
/Assets/scenes/Scene.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | SceneSettings:
5 | m_ObjectHideFlags: 0
6 | m_PVSData:
7 | m_PVSObjectsArray: []
8 | m_PVSPortalsArray: []
9 | m_OcclusionBakeSettings:
10 | smallestOccluder: 5
11 | smallestHole: 0.25
12 | backfaceThreshold: 100
13 | --- !u!104 &2
14 | RenderSettings:
15 | m_ObjectHideFlags: 0
16 | serializedVersion: 6
17 | m_Fog: 0
18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19 | m_FogMode: 3
20 | m_FogDensity: 0.01
21 | m_LinearFogStart: 0
22 | m_LinearFogEnd: 300
23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26 | m_AmbientIntensity: 1
27 | m_AmbientMode: 0
28 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
29 | m_HaloStrength: 0.5
30 | m_FlareStrength: 1
31 | m_FlareFadeSpeed: 3
32 | m_HaloTexture: {fileID: 0}
33 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
34 | m_DefaultReflectionMode: 0
35 | m_DefaultReflectionResolution: 128
36 | m_ReflectionBounces: 1
37 | m_ReflectionIntensity: 1
38 | m_CustomReflection: {fileID: 0}
39 | m_Sun: {fileID: 0}
40 | --- !u!157 &4
41 | LightmapSettings:
42 | m_ObjectHideFlags: 0
43 | serializedVersion: 6
44 | m_GIWorkflowMode: 0
45 | m_LightmapsMode: 1
46 | m_GISettings:
47 | serializedVersion: 2
48 | m_BounceScale: 1
49 | m_IndirectOutputScale: 1
50 | m_AlbedoBoost: 1
51 | m_TemporalCoherenceThreshold: 1
52 | m_EnvironmentLightingMode: 0
53 | m_EnableBakedLightmaps: 1
54 | m_EnableRealtimeLightmaps: 1
55 | m_LightmapEditorSettings:
56 | serializedVersion: 3
57 | m_Resolution: 2
58 | m_BakeResolution: 40
59 | m_TextureWidth: 1024
60 | m_TextureHeight: 1024
61 | m_AOMaxDistance: 1
62 | m_Padding: 2
63 | m_CompAOExponent: 0
64 | m_LightmapParameters: {fileID: 0}
65 | m_TextureCompression: 1
66 | m_FinalGather: 0
67 | m_FinalGatherRayCount: 1024
68 | m_ReflectionCompression: 2
69 | m_LightingDataAsset: {fileID: 0}
70 | m_RuntimeCPUUsage: 25
71 | --- !u!196 &5
72 | NavMeshSettings:
73 | serializedVersion: 2
74 | m_ObjectHideFlags: 0
75 | m_BuildSettings:
76 | serializedVersion: 2
77 | agentRadius: 0.5
78 | agentHeight: 2
79 | agentSlope: 45
80 | agentClimb: 0.4
81 | ledgeDropHeight: 0
82 | maxJumpAcrossDistance: 0
83 | accuratePlacement: 0
84 | minRegionArea: 2
85 | cellSize: 0.16666667
86 | manualCellSize: 0
87 | m_NavMeshData: {fileID: 0}
88 | --- !u!1 &608803929
89 | GameObject:
90 | m_ObjectHideFlags: 0
91 | m_PrefabParentObject: {fileID: 0}
92 | m_PrefabInternal: {fileID: 0}
93 | serializedVersion: 4
94 | m_Component:
95 | - 4: {fileID: 608803931}
96 | - 108: {fileID: 608803930}
97 | m_Layer: 0
98 | m_Name: Directional Light
99 | m_TagString: Untagged
100 | m_Icon: {fileID: 0}
101 | m_NavMeshLayer: 0
102 | m_StaticEditorFlags: 0
103 | m_IsActive: 1
104 | --- !u!108 &608803930
105 | Light:
106 | m_ObjectHideFlags: 0
107 | m_PrefabParentObject: {fileID: 0}
108 | m_PrefabInternal: {fileID: 0}
109 | m_GameObject: {fileID: 608803929}
110 | m_Enabled: 1
111 | serializedVersion: 6
112 | m_Type: 1
113 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
114 | m_Intensity: 1
115 | m_Range: 10
116 | m_SpotAngle: 30
117 | m_CookieSize: 10
118 | m_Shadows:
119 | m_Type: 2
120 | m_Resolution: -1
121 | m_Strength: 1
122 | m_Bias: 0.05
123 | m_NormalBias: 0.4
124 | m_NearPlane: 0.2
125 | m_Cookie: {fileID: 0}
126 | m_DrawHalo: 0
127 | m_Flare: {fileID: 0}
128 | m_RenderMode: 0
129 | m_CullingMask:
130 | serializedVersion: 2
131 | m_Bits: 4294967295
132 | m_Lightmapping: 4
133 | m_BounceIntensity: 1
134 | m_ShadowRadius: 0
135 | m_ShadowAngle: 0
136 | m_AreaSize: {x: 1, y: 1}
137 | --- !u!4 &608803931
138 | Transform:
139 | m_ObjectHideFlags: 0
140 | m_PrefabParentObject: {fileID: 0}
141 | m_PrefabInternal: {fileID: 0}
142 | m_GameObject: {fileID: 608803929}
143 | m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.109381676, w: 0.87542605}
144 | m_LocalPosition: {x: 0, y: 3, z: 0}
145 | m_LocalScale: {x: 1, y: 1, z: 1}
146 | m_Children: []
147 | m_Father: {fileID: 0}
148 | m_RootOrder: 1
149 | --- !u!1 &826631434
150 | GameObject:
151 | m_ObjectHideFlags: 0
152 | m_PrefabParentObject: {fileID: 0}
153 | m_PrefabInternal: {fileID: 0}
154 | serializedVersion: 4
155 | m_Component:
156 | - 4: {fileID: 826631439}
157 | - 33: {fileID: 826631438}
158 | - 65: {fileID: 826631437}
159 | - 23: {fileID: 826631436}
160 | - 54: {fileID: 826631441}
161 | - 114: {fileID: 826631440}
162 | - 114: {fileID: 826631435}
163 | m_Layer: 0
164 | m_Name: Cube
165 | m_TagString: Untagged
166 | m_Icon: {fileID: 0}
167 | m_NavMeshLayer: 0
168 | m_StaticEditorFlags: 0
169 | m_IsActive: 1
170 | --- !u!114 &826631435
171 | MonoBehaviour:
172 | m_ObjectHideFlags: 0
173 | m_PrefabParentObject: {fileID: 0}
174 | m_PrefabInternal: {fileID: 0}
175 | m_GameObject: {fileID: 826631434}
176 | m_Enabled: 1
177 | m_EditorHideFlags: 0
178 | m_Script: {fileID: 11500000, guid: 509eb13ca42d9477799821e030eacdf0, type: 3}
179 | m_Name:
180 | m_EditorClassIdentifier:
181 | FilePath: Assets/src/python/CubeClass.py
182 | FileName: CubeClass.py
183 | FileCreated: 1
184 | Saved: 1
185 | InMemory: 0
186 | HasChanges: 0
187 | CurrentView: 0
188 | --- !u!23 &826631436
189 | MeshRenderer:
190 | m_ObjectHideFlags: 0
191 | m_PrefabParentObject: {fileID: 0}
192 | m_PrefabInternal: {fileID: 0}
193 | m_GameObject: {fileID: 826631434}
194 | m_Enabled: 1
195 | m_CastShadows: 1
196 | m_ReceiveShadows: 1
197 | m_Materials:
198 | - {fileID: 2100000, guid: 646412dd1c6e54eb4bcb78333940ece2, type: 2}
199 | m_SubsetIndices:
200 | m_StaticBatchRoot: {fileID: 0}
201 | m_UseLightProbes: 1
202 | m_ReflectionProbeUsage: 1
203 | m_ProbeAnchor: {fileID: 0}
204 | m_ScaleInLightmap: 1
205 | m_PreserveUVs: 1
206 | m_IgnoreNormalsForChartDetection: 0
207 | m_ImportantGI: 0
208 | m_MinimumChartSize: 4
209 | m_AutoUVMaxDistance: 0.5
210 | m_AutoUVMaxAngle: 89
211 | m_LightmapParameters: {fileID: 0}
212 | m_SortingLayerID: 0
213 | m_SortingOrder: 0
214 | --- !u!65 &826631437
215 | BoxCollider:
216 | m_ObjectHideFlags: 0
217 | m_PrefabParentObject: {fileID: 0}
218 | m_PrefabInternal: {fileID: 0}
219 | m_GameObject: {fileID: 826631434}
220 | m_Material: {fileID: 0}
221 | m_IsTrigger: 0
222 | m_Enabled: 1
223 | serializedVersion: 2
224 | m_Size: {x: 1, y: 1, z: 1}
225 | m_Center: {x: 0, y: 0, z: 0}
226 | --- !u!33 &826631438
227 | MeshFilter:
228 | m_ObjectHideFlags: 0
229 | m_PrefabParentObject: {fileID: 0}
230 | m_PrefabInternal: {fileID: 0}
231 | m_GameObject: {fileID: 826631434}
232 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
233 | --- !u!4 &826631439
234 | Transform:
235 | m_ObjectHideFlags: 0
236 | m_PrefabParentObject: {fileID: 0}
237 | m_PrefabInternal: {fileID: 0}
238 | m_GameObject: {fileID: 826631434}
239 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
240 | m_LocalPosition: {x: -0.64, y: 3.23, z: 2.79}
241 | m_LocalScale: {x: 0.88, y: 0.88, z: 0.88}
242 | m_Children: []
243 | m_Father: {fileID: 0}
244 | m_RootOrder: 3
245 | --- !u!114 &826631440
246 | MonoBehaviour:
247 | m_ObjectHideFlags: 0
248 | m_PrefabParentObject: {fileID: 0}
249 | m_PrefabInternal: {fileID: 0}
250 | m_GameObject: {fileID: 826631434}
251 | m_Enabled: 1
252 | m_EditorHideFlags: 0
253 | m_Script: {fileID: 11500000, guid: 7249c3327730e488783a627898d03e42, type: 3}
254 | m_Name:
255 | m_EditorClassIdentifier:
256 | --- !u!54 &826631441
257 | Rigidbody:
258 | m_ObjectHideFlags: 0
259 | m_PrefabParentObject: {fileID: 0}
260 | m_PrefabInternal: {fileID: 0}
261 | m_GameObject: {fileID: 826631434}
262 | serializedVersion: 2
263 | m_Mass: 1
264 | m_Drag: 0
265 | m_AngularDrag: 0.05
266 | m_UseGravity: 1
267 | m_IsKinematic: 0
268 | m_Interpolate: 0
269 | m_Constraints: 0
270 | m_CollisionDetection: 0
271 | --- !u!1 &953321506
272 | GameObject:
273 | m_ObjectHideFlags: 0
274 | m_PrefabParentObject: {fileID: 0}
275 | m_PrefabInternal: {fileID: 0}
276 | serializedVersion: 4
277 | m_Component:
278 | - 4: {fileID: 953321511}
279 | - 33: {fileID: 953321510}
280 | - 65: {fileID: 953321509}
281 | - 23: {fileID: 953321508}
282 | - 114: {fileID: 953321507}
283 | - 114: {fileID: 953321512}
284 | m_Layer: 0
285 | m_Name: Cube 1
286 | m_TagString: Untagged
287 | m_Icon: {fileID: 0}
288 | m_NavMeshLayer: 0
289 | m_StaticEditorFlags: 0
290 | m_IsActive: 1
291 | --- !u!114 &953321507
292 | MonoBehaviour:
293 | m_ObjectHideFlags: 0
294 | m_PrefabParentObject: {fileID: 0}
295 | m_PrefabInternal: {fileID: 0}
296 | m_GameObject: {fileID: 953321506}
297 | m_Enabled: 1
298 | m_EditorHideFlags: 0
299 | m_Script: {fileID: 11500000, guid: 509eb13ca42d9477799821e030eacdf0, type: 3}
300 | m_Name:
301 | m_EditorClassIdentifier:
302 | FilePath: Assets/src/python/Player.py
303 | FileName: Player.py
304 | FileCreated: 1
305 | Saved: 1
306 | InMemory: 0
307 | HasChanges: 0
308 | CurrentView: 0
309 | --- !u!23 &953321508
310 | MeshRenderer:
311 | m_ObjectHideFlags: 0
312 | m_PrefabParentObject: {fileID: 0}
313 | m_PrefabInternal: {fileID: 0}
314 | m_GameObject: {fileID: 953321506}
315 | m_Enabled: 1
316 | m_CastShadows: 1
317 | m_ReceiveShadows: 1
318 | m_Materials:
319 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
320 | m_SubsetIndices:
321 | m_StaticBatchRoot: {fileID: 0}
322 | m_UseLightProbes: 1
323 | m_ReflectionProbeUsage: 1
324 | m_ProbeAnchor: {fileID: 0}
325 | m_ScaleInLightmap: 1
326 | m_PreserveUVs: 1
327 | m_IgnoreNormalsForChartDetection: 0
328 | m_ImportantGI: 0
329 | m_MinimumChartSize: 4
330 | m_AutoUVMaxDistance: 0.5
331 | m_AutoUVMaxAngle: 89
332 | m_LightmapParameters: {fileID: 0}
333 | m_SortingLayerID: 0
334 | m_SortingOrder: 0
335 | --- !u!65 &953321509
336 | BoxCollider:
337 | m_ObjectHideFlags: 0
338 | m_PrefabParentObject: {fileID: 0}
339 | m_PrefabInternal: {fileID: 0}
340 | m_GameObject: {fileID: 953321506}
341 | m_Material: {fileID: 0}
342 | m_IsTrigger: 0
343 | m_Enabled: 1
344 | serializedVersion: 2
345 | m_Size: {x: 1, y: 1, z: 1}
346 | m_Center: {x: 0, y: 0, z: 0}
347 | --- !u!33 &953321510
348 | MeshFilter:
349 | m_ObjectHideFlags: 0
350 | m_PrefabParentObject: {fileID: 0}
351 | m_PrefabInternal: {fileID: 0}
352 | m_GameObject: {fileID: 953321506}
353 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
354 | --- !u!4 &953321511
355 | Transform:
356 | m_ObjectHideFlags: 0
357 | m_PrefabParentObject: {fileID: 0}
358 | m_PrefabInternal: {fileID: 0}
359 | m_GameObject: {fileID: 953321506}
360 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
361 | m_LocalPosition: {x: 2.09, y: 0, z: 2.21}
362 | m_LocalScale: {x: 0.4890206, y: 0.4890206, z: 0.4890206}
363 | m_Children: []
364 | m_Father: {fileID: 0}
365 | m_RootOrder: 4
366 | --- !u!114 &953321512
367 | MonoBehaviour:
368 | m_ObjectHideFlags: 0
369 | m_PrefabParentObject: {fileID: 0}
370 | m_PrefabInternal: {fileID: 0}
371 | m_GameObject: {fileID: 953321506}
372 | m_Enabled: 1
373 | m_EditorHideFlags: 0
374 | m_Script: {fileID: 11500000, guid: 7249c3327730e488783a627898d03e42, type: 3}
375 | m_Name:
376 | m_EditorClassIdentifier:
377 | --- !u!1 &1286279391
378 | GameObject:
379 | m_ObjectHideFlags: 0
380 | m_PrefabParentObject: {fileID: 0}
381 | m_PrefabInternal: {fileID: 0}
382 | serializedVersion: 4
383 | m_Component:
384 | - 4: {fileID: 1286279396}
385 | - 20: {fileID: 1286279395}
386 | - 92: {fileID: 1286279394}
387 | - 124: {fileID: 1286279393}
388 | - 81: {fileID: 1286279392}
389 | m_Layer: 0
390 | m_Name: Main Camera
391 | m_TagString: MainCamera
392 | m_Icon: {fileID: 0}
393 | m_NavMeshLayer: 0
394 | m_StaticEditorFlags: 0
395 | m_IsActive: 1
396 | --- !u!81 &1286279392
397 | AudioListener:
398 | m_ObjectHideFlags: 0
399 | m_PrefabParentObject: {fileID: 0}
400 | m_PrefabInternal: {fileID: 0}
401 | m_GameObject: {fileID: 1286279391}
402 | m_Enabled: 1
403 | --- !u!124 &1286279393
404 | Behaviour:
405 | m_ObjectHideFlags: 0
406 | m_PrefabParentObject: {fileID: 0}
407 | m_PrefabInternal: {fileID: 0}
408 | m_GameObject: {fileID: 1286279391}
409 | m_Enabled: 1
410 | --- !u!92 &1286279394
411 | Behaviour:
412 | m_ObjectHideFlags: 0
413 | m_PrefabParentObject: {fileID: 0}
414 | m_PrefabInternal: {fileID: 0}
415 | m_GameObject: {fileID: 1286279391}
416 | m_Enabled: 1
417 | --- !u!20 &1286279395
418 | Camera:
419 | m_ObjectHideFlags: 0
420 | m_PrefabParentObject: {fileID: 0}
421 | m_PrefabInternal: {fileID: 0}
422 | m_GameObject: {fileID: 1286279391}
423 | m_Enabled: 1
424 | serializedVersion: 2
425 | m_ClearFlags: 1
426 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844}
427 | m_NormalizedViewPortRect:
428 | serializedVersion: 2
429 | x: 0
430 | y: 0
431 | width: 1
432 | height: 1
433 | near clip plane: 0.3
434 | far clip plane: 1000
435 | field of view: 70.9
436 | orthographic: 0
437 | orthographic size: 5
438 | m_Depth: -1
439 | m_CullingMask:
440 | serializedVersion: 2
441 | m_Bits: 4294967295
442 | m_RenderingPath: -1
443 | m_TargetTexture: {fileID: 0}
444 | m_TargetDisplay: 0
445 | m_TargetEye: 3
446 | m_HDR: 0
447 | m_OcclusionCulling: 1
448 | m_StereoConvergence: 10
449 | m_StereoSeparation: 0.022
450 | m_StereoMirrorMode: 0
451 | --- !u!4 &1286279396
452 | Transform:
453 | m_ObjectHideFlags: 0
454 | m_PrefabParentObject: {fileID: 0}
455 | m_PrefabInternal: {fileID: 0}
456 | m_GameObject: {fileID: 1286279391}
457 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
458 | m_LocalPosition: {x: 0, y: 0, z: -3.28}
459 | m_LocalScale: {x: 1, y: 1, z: 1}
460 | m_Children: []
461 | m_Father: {fileID: 0}
462 | m_RootOrder: 0
463 | --- !u!1 &1297972986
464 | GameObject:
465 | m_ObjectHideFlags: 0
466 | m_PrefabParentObject: {fileID: 0}
467 | m_PrefabInternal: {fileID: 0}
468 | serializedVersion: 4
469 | m_Component:
470 | - 4: {fileID: 1297972992}
471 | - 33: {fileID: 1297972991}
472 | - 135: {fileID: 1297972990}
473 | - 23: {fileID: 1297972989}
474 | - 114: {fileID: 1297972988}
475 | - 54: {fileID: 1297972987}
476 | - 114: {fileID: 1297972993}
477 | m_Layer: 0
478 | m_Name: Sphere
479 | m_TagString: Untagged
480 | m_Icon: {fileID: 0}
481 | m_NavMeshLayer: 0
482 | m_StaticEditorFlags: 0
483 | m_IsActive: 1
484 | --- !u!54 &1297972987
485 | Rigidbody:
486 | m_ObjectHideFlags: 0
487 | m_PrefabParentObject: {fileID: 0}
488 | m_PrefabInternal: {fileID: 0}
489 | m_GameObject: {fileID: 1297972986}
490 | serializedVersion: 2
491 | m_Mass: 1
492 | m_Drag: 0
493 | m_AngularDrag: 0.05
494 | m_UseGravity: 1
495 | m_IsKinematic: 0
496 | m_Interpolate: 0
497 | m_Constraints: 0
498 | m_CollisionDetection: 0
499 | --- !u!114 &1297972988
500 | MonoBehaviour:
501 | m_ObjectHideFlags: 0
502 | m_PrefabParentObject: {fileID: 0}
503 | m_PrefabInternal: {fileID: 0}
504 | m_GameObject: {fileID: 1297972986}
505 | m_Enabled: 1
506 | m_EditorHideFlags: 0
507 | m_Script: {fileID: 11500000, guid: 509eb13ca42d9477799821e030eacdf0, type: 3}
508 | m_Name:
509 | m_EditorClassIdentifier:
510 | FilePath: Assets/src/python/RigidbodyExample.py
511 | FileName: RigidbodyExample.py
512 | FileCreated: 1
513 | Saved: 1
514 | InMemory: 0
515 | HasChanges: 0
516 | CurrentView: 0
517 | --- !u!23 &1297972989
518 | MeshRenderer:
519 | m_ObjectHideFlags: 0
520 | m_PrefabParentObject: {fileID: 0}
521 | m_PrefabInternal: {fileID: 0}
522 | m_GameObject: {fileID: 1297972986}
523 | m_Enabled: 1
524 | m_CastShadows: 1
525 | m_ReceiveShadows: 1
526 | m_Materials:
527 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
528 | m_SubsetIndices:
529 | m_StaticBatchRoot: {fileID: 0}
530 | m_UseLightProbes: 1
531 | m_ReflectionProbeUsage: 1
532 | m_ProbeAnchor: {fileID: 0}
533 | m_ScaleInLightmap: 1
534 | m_PreserveUVs: 1
535 | m_IgnoreNormalsForChartDetection: 0
536 | m_ImportantGI: 0
537 | m_MinimumChartSize: 4
538 | m_AutoUVMaxDistance: 0.5
539 | m_AutoUVMaxAngle: 89
540 | m_LightmapParameters: {fileID: 0}
541 | m_SortingLayerID: 0
542 | m_SortingOrder: 0
543 | --- !u!135 &1297972990
544 | SphereCollider:
545 | m_ObjectHideFlags: 0
546 | m_PrefabParentObject: {fileID: 0}
547 | m_PrefabInternal: {fileID: 0}
548 | m_GameObject: {fileID: 1297972986}
549 | m_Material: {fileID: 0}
550 | m_IsTrigger: 0
551 | m_Enabled: 1
552 | serializedVersion: 2
553 | m_Radius: 0.5
554 | m_Center: {x: 0, y: 0, z: 0}
555 | --- !u!33 &1297972991
556 | MeshFilter:
557 | m_ObjectHideFlags: 0
558 | m_PrefabParentObject: {fileID: 0}
559 | m_PrefabInternal: {fileID: 0}
560 | m_GameObject: {fileID: 1297972986}
561 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
562 | --- !u!4 &1297972992
563 | Transform:
564 | m_ObjectHideFlags: 0
565 | m_PrefabParentObject: {fileID: 0}
566 | m_PrefabInternal: {fileID: 0}
567 | m_GameObject: {fileID: 1297972986}
568 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
569 | m_LocalPosition: {x: 0.84, y: 0.43, z: 3.61}
570 | m_LocalScale: {x: 1, y: 1, z: 1}
571 | m_Children: []
572 | m_Father: {fileID: 0}
573 | m_RootOrder: 5
574 | --- !u!114 &1297972993
575 | MonoBehaviour:
576 | m_ObjectHideFlags: 0
577 | m_PrefabParentObject: {fileID: 0}
578 | m_PrefabInternal: {fileID: 0}
579 | m_GameObject: {fileID: 1297972986}
580 | m_Enabled: 1
581 | m_EditorHideFlags: 0
582 | m_Script: {fileID: 11500000, guid: 7249c3327730e488783a627898d03e42, type: 3}
583 | m_Name:
584 | m_EditorClassIdentifier:
585 | --- !u!1 &1683626623
586 | GameObject:
587 | m_ObjectHideFlags: 0
588 | m_PrefabParentObject: {fileID: 0}
589 | m_PrefabInternal: {fileID: 0}
590 | serializedVersion: 4
591 | m_Component:
592 | - 4: {fileID: 1683626627}
593 | - 33: {fileID: 1683626626}
594 | - 64: {fileID: 1683626625}
595 | - 23: {fileID: 1683626624}
596 | m_Layer: 0
597 | m_Name: Plane
598 | m_TagString: Untagged
599 | m_Icon: {fileID: 0}
600 | m_NavMeshLayer: 0
601 | m_StaticEditorFlags: 0
602 | m_IsActive: 1
603 | --- !u!23 &1683626624
604 | MeshRenderer:
605 | m_ObjectHideFlags: 0
606 | m_PrefabParentObject: {fileID: 0}
607 | m_PrefabInternal: {fileID: 0}
608 | m_GameObject: {fileID: 1683626623}
609 | m_Enabled: 1
610 | m_CastShadows: 1
611 | m_ReceiveShadows: 1
612 | m_Materials:
613 | - {fileID: 2100000, guid: 7cfa8eaf6d5f54bd0a179b39eb03eb95, type: 2}
614 | m_SubsetIndices:
615 | m_StaticBatchRoot: {fileID: 0}
616 | m_UseLightProbes: 1
617 | m_ReflectionProbeUsage: 1
618 | m_ProbeAnchor: {fileID: 0}
619 | m_ScaleInLightmap: 1
620 | m_PreserveUVs: 1
621 | m_IgnoreNormalsForChartDetection: 0
622 | m_ImportantGI: 0
623 | m_MinimumChartSize: 4
624 | m_AutoUVMaxDistance: 0.5
625 | m_AutoUVMaxAngle: 89
626 | m_LightmapParameters: {fileID: 0}
627 | m_SortingLayerID: 0
628 | m_SortingOrder: 0
629 | --- !u!64 &1683626625
630 | MeshCollider:
631 | m_ObjectHideFlags: 0
632 | m_PrefabParentObject: {fileID: 0}
633 | m_PrefabInternal: {fileID: 0}
634 | m_GameObject: {fileID: 1683626623}
635 | m_Material: {fileID: 0}
636 | m_IsTrigger: 0
637 | m_Enabled: 1
638 | serializedVersion: 2
639 | m_Convex: 0
640 | m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
641 | --- !u!33 &1683626626
642 | MeshFilter:
643 | m_ObjectHideFlags: 0
644 | m_PrefabParentObject: {fileID: 0}
645 | m_PrefabInternal: {fileID: 0}
646 | m_GameObject: {fileID: 1683626623}
647 | m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
648 | --- !u!4 &1683626627
649 | Transform:
650 | m_ObjectHideFlags: 0
651 | m_PrefabParentObject: {fileID: 0}
652 | m_PrefabInternal: {fileID: 0}
653 | m_GameObject: {fileID: 1683626623}
654 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
655 | m_LocalPosition: {x: -0.25, y: -1, z: 2.64}
656 | m_LocalScale: {x: 1.8023655, y: 1.8023651, z: 1.8023651}
657 | m_Children: []
658 | m_Father: {fileID: 0}
659 | m_RootOrder: 2
660 |
--------------------------------------------------------------------------------