Skip to content

Commit 2622109

Browse files
author
Unity Technologies
committed
Unity 2017.1.0a3 C# reference source code
0 parents  commit 2622109

File tree

1,494 files changed

+396334
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,494 files changed

+396334
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using UnityEngine;
6+
7+
namespace UnityEditor.U2D.Interface
8+
{
9+
internal interface IAssetDatabase
10+
{
11+
string GetAssetPath(Object o);
12+
ITextureImporter GetAssetImporterFromPath(string path);
13+
}
14+
15+
internal class AssetDatabaseSystem : IAssetDatabase
16+
{
17+
public string GetAssetPath(Object o)
18+
{
19+
return UnityEditor.AssetDatabase.GetAssetPath(o);
20+
}
21+
22+
public ITextureImporter GetAssetImporterFromPath(string path)
23+
{
24+
UnityEditor.AssetImporter ai = UnityEditor.AssetImporter.GetAtPath(path) as UnityEditor.TextureImporter;
25+
return ai == null ? null : new TextureImporter((UnityEditor.TextureImporter)ai);
26+
}
27+
}
28+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using UnityEngine;
6+
using UnityEditor;
7+
using System;
8+
using UnityAssetImporter = UnityEditor.AssetImporter;
9+
using UnityTextureImporter = UnityEditor.TextureImporter;
10+
11+
namespace UnityEditor.U2D.Interface
12+
{
13+
internal abstract class ITextureImporter
14+
{
15+
public abstract void GetWidthAndHeight(ref int width, ref int height);
16+
public abstract SpriteImportMode spriteImportMode { get; }
17+
public abstract Vector4 spriteBorder { get; }
18+
public abstract Vector2 spritePivot { get; }
19+
20+
public abstract string assetPath { get; }
21+
22+
public static bool operator==(ITextureImporter t1, ITextureImporter t2)
23+
{
24+
if (object.ReferenceEquals(t1, null))
25+
{
26+
return object.ReferenceEquals(t2, null) || t2 == null;
27+
}
28+
29+
return t1.Equals(t2);
30+
}
31+
32+
public static bool operator!=(ITextureImporter t1, ITextureImporter t2)
33+
{
34+
if (object.ReferenceEquals(t1, null))
35+
{
36+
return !object.ReferenceEquals(t2, null) && t2 != null;
37+
}
38+
39+
return !t1.Equals(t2);
40+
}
41+
42+
public override bool Equals(object other)
43+
{
44+
throw new NotImplementedException();
45+
}
46+
47+
public override int GetHashCode()
48+
{
49+
throw new NotImplementedException();
50+
}
51+
}
52+
53+
internal class TextureImporter : ITextureImporter
54+
{
55+
protected UnityAssetImporter m_AssetImporter;
56+
57+
public TextureImporter(UnityTextureImporter textureImporter)
58+
{
59+
m_AssetImporter = textureImporter;
60+
}
61+
62+
public override string assetPath
63+
{
64+
get { return m_AssetImporter.assetPath; }
65+
}
66+
67+
public override bool Equals(object other)
68+
{
69+
TextureImporter t = other as TextureImporter;
70+
if (object.ReferenceEquals(t, null))
71+
return m_AssetImporter == null;
72+
return m_AssetImporter == t.m_AssetImporter;
73+
}
74+
75+
public override int GetHashCode()
76+
{
77+
return m_AssetImporter.GetHashCode();
78+
}
79+
80+
public override void GetWidthAndHeight(ref int width, ref int height)
81+
{
82+
((UnityTextureImporter)m_AssetImporter).GetWidthAndHeight(ref width, ref height);
83+
}
84+
85+
public override SpriteImportMode spriteImportMode
86+
{
87+
get { return ((UnityTextureImporter)m_AssetImporter).spriteImportMode; }
88+
}
89+
90+
public override Vector4 spriteBorder
91+
{
92+
get { return ((UnityTextureImporter)m_AssetImporter).spriteBorder; }
93+
}
94+
95+
public override Vector2 spritePivot
96+
{
97+
get { return ((UnityTextureImporter)m_AssetImporter).spritePivot; }
98+
}
99+
}
100+
}

Editor/Mono/2D/Interface/IEvent.cs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using System;
6+
using UnityEngine;
7+
using UnityEvent = UnityEngine.Event;
8+
9+
// We are putting this in the Editor folder for now since on SpriteEditorWindow et al. are using it
10+
namespace UnityEngine.U2D.Interface
11+
{
12+
internal interface IEvent
13+
{
14+
EventType type { get; }
15+
string commandName { get; }
16+
bool control { get; }
17+
bool alt { get; }
18+
bool shift { get; }
19+
KeyCode keyCode { get; }
20+
Vector2 mousePosition { get; }
21+
int button { get; }
22+
EventModifiers modifiers { get; }
23+
EventType GetTypeForControl(int id);
24+
25+
void Use();
26+
}
27+
28+
internal class Event : IEvent
29+
{
30+
UnityEvent m_Event;
31+
32+
public Event()
33+
{
34+
m_Event = UnityEvent.current;
35+
}
36+
37+
public EventType type
38+
{
39+
get { return m_Event.type; }
40+
}
41+
42+
public string commandName
43+
{
44+
get { return m_Event.commandName; }
45+
}
46+
47+
public bool control
48+
{
49+
get { return m_Event.control; }
50+
}
51+
52+
public bool alt
53+
{
54+
get { return m_Event.alt; }
55+
}
56+
57+
public bool shift
58+
{
59+
get { return m_Event.shift; }
60+
}
61+
62+
public KeyCode keyCode
63+
{
64+
get { return m_Event.keyCode; }
65+
}
66+
67+
public Vector2 mousePosition
68+
{
69+
get { return m_Event.mousePosition; }
70+
}
71+
72+
public int button
73+
{
74+
get { return m_Event.button; }
75+
}
76+
77+
public void Use()
78+
{
79+
m_Event.Use();
80+
}
81+
82+
public EventModifiers modifiers
83+
{
84+
get { return m_Event.modifiers; }
85+
}
86+
87+
public EventType GetTypeForControl(int id)
88+
{
89+
return m_Event.GetTypeForControl(id);
90+
}
91+
}
92+
93+
internal interface IEventSystem
94+
{
95+
IEvent current { get; }
96+
}
97+
98+
internal class EventSystem : IEventSystem
99+
{
100+
public IEvent current
101+
{
102+
get { return new Event(); }
103+
}
104+
}
105+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
namespace UnityEngine
6+
{
7+
internal interface IGUIUtility
8+
{
9+
int GetPermanentControlID();
10+
int hotControl { get; set; }
11+
int keyboardControl { get; set; }
12+
int GetControlID(int hint, FocusType focus);
13+
}
14+
15+
internal class GUIUtilitySystem : IGUIUtility
16+
{
17+
public int GetPermanentControlID()
18+
{
19+
return GUIUtility.GetPermanentControlID();
20+
}
21+
22+
public int hotControl
23+
{
24+
get
25+
{
26+
return GUIUtility.hotControl;
27+
}
28+
set
29+
{
30+
GUIUtility.hotControl = value;
31+
}
32+
}
33+
34+
public int keyboardControl
35+
{
36+
get
37+
{
38+
return GUIUtility.keyboardControl;
39+
}
40+
set
41+
{
42+
GUIUtility.keyboardControl = value;
43+
}
44+
}
45+
46+
public int GetControlID(int hint, FocusType focus)
47+
{
48+
return GUIUtility.GetControlID(hint, focus);
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)