Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Birb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gadig
Birb
Commits
d984067e
Commit
d984067e
authored
Apr 11, 2017
by
Luke A Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'EditorImprovements' into 'master'
Editor improvements See merge request
!54
parents
0a52735a
1755175b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
567 additions
and
31 deletions
+567
-31
Assets/Prefabs/Player.prefab
Assets/Prefabs/Player.prefab
+17
-0
Assets/Prefabs/Tiles/Hazards/Thorns.prefab
Assets/Prefabs/Tiles/Hazards/Thorns.prefab
+91
-0
Assets/Prefabs/Tiles/Hazards/Thorns.prefab.meta
Assets/Prefabs/Tiles/Hazards/Thorns.prefab.meta
+8
-0
Assets/Scenes/LargeLevelTest.unity
Assets/Scenes/LargeLevelTest.unity
+0
-0
Assets/Scenes/LargeLevelTest.unity.meta
Assets/Scenes/LargeLevelTest.unity.meta
+0
-0
Assets/Scenes/_BASE_LEVEL_.unity
Assets/Scenes/_BASE_LEVEL_.unity
+106
-0
Assets/Scripts/MapEditor/DragPlaceInfo.cs
Assets/Scripts/MapEditor/DragPlaceInfo.cs
+9
-0
Assets/Scripts/MapEditor/DragPlaceInfo.cs.meta
Assets/Scripts/MapEditor/DragPlaceInfo.cs.meta
+12
-0
Assets/Scripts/MapEditor/DragPlacement.cs
Assets/Scripts/MapEditor/DragPlacement.cs
+229
-0
Assets/Scripts/MapEditor/DragPlacement.cs.meta
Assets/Scripts/MapEditor/DragPlacement.cs.meta
+17
-0
Assets/Scripts/MapEditor/MapEditor.cs
Assets/Scripts/MapEditor/MapEditor.cs
+66
-19
Assets/Scripts/MapEditor/World.cs
Assets/Scripts/MapEditor/World.cs
+9
-9
Assets/Scripts/Player/CameraFollow.cs
Assets/Scripts/Player/CameraFollow.cs
+3
-3
No files found.
Assets/Prefabs/Player.prefab
View file @
d984067e
...
...
@@ -296,6 +296,7 @@ GameObject:
-
component
:
{
fileID
:
114296284101528218
}
-
component
:
{
fileID
:
114496983445290320
}
-
component
:
{
fileID
:
114468523229820794
}
-
component
:
{
fileID
:
114201504414302498
}
m_Layer
:
8
m_Name
:
Player
m_TagString
:
Player
...
...
@@ -943,6 +944,22 @@ MonoBehaviour:
buttons
:
5
condition
:
0
inputState
:
{
fileID
:
114343537035820548
}
---
!u!114
&114201504414302498
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1784255690954616
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
0cad1638cf0899c4584bad64f0af5112
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
smoothSpeed
:
1
UpBuffer
:
5
DownBuffer
:
5
RightBuffer
:
5
LeftBuffer
:
5
---
!u!114
&114296284101528218
MonoBehaviour
:
m_ObjectHideFlags
:
1
...
...
Assets/Prefabs/Tiles/Hazards/Thorns.prefab
0 → 100644
View file @
d984067e
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!1001
&100100000
Prefab
:
m_ObjectHideFlags
:
1
serializedVersion
:
2
m_Modification
:
m_TransformParent
:
{
fileID
:
0
}
m_Modifications
:
[]
m_RemovedComponents
:
[]
m_ParentPrefab
:
{
fileID
:
0
}
m_RootGameObject
:
{
fileID
:
1813104308667434
}
m_IsPrefabParent
:
1
---
!u!1
&1813104308667434
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4564406416464228
}
-
component
:
{
fileID
:
212266651003183348
}
-
component
:
{
fileID
:
114415704360927376
}
m_Layer
:
0
m_Name
:
Thorns
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&4564406416464228
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1813104308667434
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
7.864797
,
y
:
2.9603853
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!114
&114415704360927376
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1813104308667434
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
970b431072fe5634784b9b17fb23c868
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
cap
:
{
fileID
:
1377815954954446
,
guid
:
86f22dcaff0608e47a1358b04e30bc16
,
type
:
2
}
mid
:
{
fileID
:
1571230098110790
,
guid
:
d416bcc245ee5024fb9496336aa10eec
,
type
:
2
}
---
!u!212
&212266651003183348
SpriteRenderer
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1813104308667434
}
m_Enabled
:
1
m_CastShadows
:
0
m_ReceiveShadows
:
0
m_MotionVectors
:
1
m_LightProbeUsage
:
0
m_ReflectionProbeUsage
:
0
m_Materials
:
-
{
fileID
:
10754
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
m_StaticBatchInfo
:
firstSubMesh
:
0
subMeshCount
:
0
m_StaticBatchRoot
:
{
fileID
:
0
}
m_ProbeAnchor
:
{
fileID
:
0
}
m_LightProbeVolumeOverride
:
{
fileID
:
0
}
m_ScaleInLightmap
:
1
m_PreserveUVs
:
0
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_SelectedEditorRenderState
:
0
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingOrder
:
0
m_Sprite
:
{
fileID
:
21300000
,
guid
:
4a1f3689072928c45a56412b16325f14
,
type
:
3
}
m_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_FlipX
:
0
m_FlipY
:
0
Assets/Prefabs/Tiles/Hazards/Thorns.prefab.meta
0 → 100644
View file @
d984067e
fileFormatVersion: 2
guid: 542fefc006c5d4b43be9ea95fea05e02
timeCreated: 1491773148
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Assets/LargeLevelTest.unity
→
Assets/
Scenes/
LargeLevelTest.unity
View file @
d984067e
File moved
Assets/LargeLevelTest.unity.meta
→
Assets/
Scenes/
LargeLevelTest.unity.meta
View file @
d984067e
File moved
Assets/Scenes/_BASE_LEVEL_.unity
View file @
d984067e
...
...
@@ -196,6 +196,112 @@ Prefab:
m_RemovedComponents
:
[]
m_ParentPrefab
:
{
fileID
:
100100000
,
guid
:
8c5d1c74f70f3894abe80d24323d2df5
,
type
:
2
}
m_IsPrefabParent
:
0
---
!u!1
&763200278
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
763200279
}
m_Layer
:
0
m_Name
:
Tiles
m_TagString
:
Tiles Parent
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&763200279
Transform
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
763200278
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
3
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1
&1040622841
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
1040622844
}
-
component
:
{
fileID
:
1040622843
}
-
component
:
{
fileID
:
1040622842
}
m_Layer
:
0
m_Name
:
New Sprite
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!114
&1040622842
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1040622841
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
970b431072fe5634784b9b17fb23c868
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
cap
:
{
fileID
:
1377815954954446
,
guid
:
86f22dcaff0608e47a1358b04e30bc16
,
type
:
2
}
mid
:
{
fileID
:
1571230098110790
,
guid
:
d416bcc245ee5024fb9496336aa10eec
,
type
:
2
}
---
!u!212
&1040622843
SpriteRenderer
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1040622841
}
m_Enabled
:
1
m_CastShadows
:
0
m_ReceiveShadows
:
0
m_MotionVectors
:
1
m_LightProbeUsage
:
0
m_ReflectionProbeUsage
:
0
m_Materials
:
-
{
fileID
:
10754
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
m_StaticBatchInfo
:
firstSubMesh
:
0
subMeshCount
:
0
m_StaticBatchRoot
:
{
fileID
:
0
}
m_ProbeAnchor
:
{
fileID
:
0
}
m_LightProbeVolumeOverride
:
{
fileID
:
0
}
m_ScaleInLightmap
:
1
m_PreserveUVs
:
0
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_SelectedEditorRenderState
:
0
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingOrder
:
0
m_Sprite
:
{
fileID
:
21300000
,
guid
:
4a1f3689072928c45a56412b16325f14
,
type
:
3
}
m_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_FlipX
:
0
m_FlipY
:
0
---
!u!4
&1040622844
Transform
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1040622841
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
7.864797
,
y
:
2.9603853
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
4
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1
&1100797466
GameObject
:
m_ObjectHideFlags
:
0
...
...
Assets/Scripts/MapEditor/DragPlaceInfo.cs
0 → 100644
View file @
d984067e
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
DragPlaceInfo
:
MonoBehaviour
{
public
GameObject
cap
;
public
GameObject
mid
;
}
Assets/Scripts/MapEditor/DragPlaceInfo.cs.meta
0 → 100644
View file @
d984067e
fileFormatVersion: 2
guid: 970b431072fe5634784b9b17fb23c868
timeCreated: 1491770342
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/MapEditor/DragPlacement.cs
0 → 100644
View file @
d984067e
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
/*<<<<<<< HEAD
// This script should be attached the the prefab of the left side cap.
// Set mid to the prefab that should be placed between the caps.
// The right cap will be the flipped version of the left cap.
public class DragPlacement : MonoBehaviour
{
public GameObject cap;
public GameObject mid;
public static GameObject instance; // Current instance of this script
public void endDrag(Vector3 pos)
{
Vector2 dir = pos - transform.position;
// Moved further left/right
if(Mathf.Abs(dir.x) > Mathf.Abs(dir.y))
{
placeX((int)pos.x);
}
// Moved further up/down
else
{
placeY((int)pos.y);
}
}
private void placeX(int x)
{
// Placeing left
if(x < transform.position.x)
{
// Place start cap and flip
GameObject go = World.set(transform.position, cap);
go.transform.localScale = new Vector3(go.transform.localScale.x * -1,
go.transform.localScale.y,
go.transform.localScale.z);
// Place mid
for(int i = (int)transform.position.x; i > x; i--)
{
World.set(i, transform.position.y, transform.position.z, mid);
}
// Place cap
World.set(x, transform.position.y, transform.position.z, cap);
}
// Placing right
else
{
// Place start cap
World.set(transform.position, cap);
// Place mid
for(int i = (int)transform.position.x; i < x; i++)
{
World.set(i, transform.position.y, transform.position.z, mid);
}
// Place cap
GameObject go = World.set(x, transform.position.y, transform.position.z, cap);
go.transform.localScale = new Vector3(go.transform.localScale.x * -1,
go.transform.localScale.y,
go.transform.localScale.z);
}
}
private void placeY(int y)
{
// Placeing down
if(y < transform.position.y)
{
// Place start cap and flip
GameObject go = World.set(transform.position, cap);
go.transform.localScale = new Vector3(go.transform.localScale.x,
go.transform.localScale.y * -1,
go.transform.localScale.z);
go.transform.Rotate(new Vector3(0, 0, -90));
// Place mid
for(int i = (int)transform.position.y; i > y; i--)
{
go = World.set(transform.position.x, i, transform.position.z, mid);
go.transform.Rotate(new Vector3(0, 0, -90));
}
// Place cap
go = World.set(y, transform.position.y, transform.position.z, cap);
go.transform.Rotate(new Vector3(0, 0, -90));
}
// Placing up
else
{
// Place start cap and flip
GameObject go = World.set(transform.position, cap);
go.transform.Rotate(new Vector3(0, 0, 90));
// Place mid
for(int i = (int)transform.position.y; i < y; i++)
{
go = World.set(transform.position.x, i, transform.position.z, mid);
go.transform.Rotate(new Vector3(0, 0, 90));
}
// Place cap
go = World.set(y, transform.position.y, transform.position.z, cap);
go.transform.localScale = new Vector3(go.transform.localScale.x,
go.transform.localScale.y * -1,
go.transform.localScale.z);
go.transform.Rotate(new Vector3(0, 0, 90));
}
}
=======
*/
public
static
class
DragPlacement
{
private
static
Vector2
start
=
new
Vector2
(
float
.
MinValue
,
float
.
MinValue
);
public
static
DragPlaceInfo
info
;
public
static
bool
running
()
{
return
World
.
posInBounds
(
start
);
}
public
static
void
startDrag
(
Vector2
s
,
DragPlaceInfo
i
)
{
Debug
.
Log
(
string
.
Format
(
"startDrag({0},)"
,
s
));
if
(
World
.
posInBounds
(
s
))
{
start
=
s
;
info
=
i
;
}
}
public
static
void
endDrag
()
{
Vector2
s
=
startPos
();
start
=
new
Vector2
(
float
.
MinValue
,
float
.
MinValue
);
Vector2
e
=
endPos
(
s
,
MapEditor
.
MousePosition
);
if
(!
World
.
posInBounds
(
e
))
{
e
.
x
=
World
.
Width
;
e
.
y
=
s
.
y
;
}
//Debug.DrawLine(s, e, Color.blue, 1f);
if
(
e
.
x
>
s
.
x
)
{
place
(
s
,
e
,
Quaternion
.
Euler
(
0
,
0
,
0
),
new
Vector3
(
1
,
1
,
1
));
}
else
if
(
s
.
x
>
e
.
x
)
{
place
(
e
,
s
,
Quaternion
.
Euler
(
0
,
0
,
180
),
new
Vector3
(-
1
,
1
,
1
));
}
else
if
(
e
.
y
>
s
.
y
)
{
place
(
s
,
e
,
Quaternion
.
Euler
(
0
,
0
,
90
),
new
Vector3
(
1
,
1
,
1
));
}
else
if
(
s
.
y
>
e
.
y
)
{
place
(
e
,
s
,
Quaternion
.
Euler
(
0
,
0
,
-
90
),
new
Vector3
(-
1
,
1
,
1
));
}
}
private
static
Vector3
startPos
()
{
return
start
;
}
private
static
Vector2
endPos
(
Vector2
start
,
Vector2
end
)
{
if
(
Mathf
.
Abs
(
end
.
x
-
start
.
x
)
>
Mathf
.
Abs
(
end
.
y
-
start
.
y
))
{
// X distance is larger
return
new
Vector2
(
end
.
x
,
start
.
y
);
}
else
{
// Y distance is larger
return
new
Vector2
(
start
.
x
,
end
.
y
);
}
}
private
static
void
place
(
Vector2
start
,
Vector2
end
,
Quaternion
rot
,
Vector3
scale
)
{
if
(
World
.
posInBounds
(
start
)
&&
World
.
posInBounds
(
end
))
{
GameObject
go
;
for
(
int
i
=
(
int
)
start
.
x
;
i
<=
(
int
)
end
.
x
;
i
++)
{
for
(
int
j
=
(
int
)
start
.
y
;
j
<=
(
int
)
end
.
y
;
j
++)
{
Vector2
pos
=
new
Vector2
(
i
,
j
);
// First tile
if
(
pos
==
start
)
{
go
=
MapEditor
.
createTileAt
(
start
,
info
.
cap
);
go
.
transform
.
localScale
=
multComp
(
go
.
transform
.
localScale
,
scale
);
go
.
transform
.
rotation
=
rot
;
}
// Last tile
else
if
(
pos
==
end
)
{
go
=
MapEditor
.
createTileAt
(
end
,
info
.
cap
);
go
.
transform
.
localScale
=
multComp
(
multComp
(
go
.
transform
.
localScale
,
scale
),
new
Vector3
(-
1
,
1
,
1
));
go
.
transform
.
rotation
=
rot
;
}
// Mid tiles
else
{
go
=
MapEditor
.
createTileAt
(
pos
,
info
.
mid
);
go
.
transform
.
localScale
=
multComp
(
go
.
transform
.
localScale
,
scale
);
go
.
transform
.
rotation
=
rot
;
}
}
}
}
}
private
static
Vector3
multComp
(
Vector3
v1
,
Vector3
v2
)
{
return
new
Vector3
(
v1
.
x
*
v2
.
x
,
v1
.
y
*
v2
.
y
,
v1
.
z
*
v2
.
z
);
}
}
Assets/Scripts/MapEditor/DragPlacement.cs.meta
0 → 100644
View file @
d984067e
fileFormatVersion: 2
<<<<<<< HEAD
guid: be7c22139863987409d6e6524b6170de
timeCreated: 1491601785
=======
guid: f0357ea37f582024092a790df0762968
timeCreated: 1491766856
>>>>>>> 1fafa54d4c72d4b458d733243c83b8185152ebed
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/MapEditor/MapEditor.cs
View file @
d984067e
...
...
@@ -9,6 +9,7 @@ public class MapEditor : MonoBehaviour
private
static
GameObject
tile
;
private
static
int
layer
=
0
;
private
static
Transform
tiles
;
private
static
Vector3
mousePosition
;
public
static
bool
On
{
...
...
@@ -33,6 +34,11 @@ public class MapEditor : MonoBehaviour
get
{
return
tiles
;
}
set
{
tiles
=
value
;
}
}
public
static
Vector3
MousePosition
{
get
{
return
mousePosition
;
}
}
#
endregion
public
static
bool
toggle
()
{
return
(
on
=
!
on
);
}
...
...
@@ -59,17 +65,40 @@ public class MapEditor : MonoBehaviour
{
if
(
MapEditor
.
On
)
{
if
(
Event
.
current
.
button
==
0
&&
(
Event
.
current
.
type
==
EventType
.
MouseDown
||
Event
.
current
.
type
==
EventType
.
MouseDrag
)
)
if
(
Event
.
current
.
button
==
0
)
{
Vector3
mouse
=
Event
.
current
.
mousePosition
;
mouse
.
y
=
-
mouse
.
y
;
Vector2
pos
=
Camera
.
current
.
ScreenToWorldPoint
(
mouse
);
createTileAt
(
mousePosCorrection
(
pos
));
Event
.
current
.
Use
();
if
((
Event
.
current
.
type
==
EventType
.
MouseDown
||
Event
.
current
.
type
==
EventType
.
MouseDrag
)
&&
(
Event
.
current
.
button
==
0
))
{
Vector3
mouse
=
Event
.
current
.
mousePosition
;
mouse
.
y
=
-
mouse
.
y
;
Vector2
pos
=
Camera
.
current
.
ScreenToWorldPoint
(
mouse
);
mousePosition
=
vector3From2
(
mousePosCorrection
(
pos
),
layer
);
createTileAt
(
mousePosCorrection
(
pos
));
Event
.
current
.
Use
();
//Debug.Log("MouseDown " + mousePosCorrection(pos));
}
if
((
Event
.
current
.
type
==
EventType
.
MouseUp
)
&&
(
Event
.
current
.
button
==
0
))
{
if
(
DragPlacement
.
running
())
{
DragPlacement
.
endDrag
();
}
Event
.
current
.
Use
();
//Debug.Log("MouseUp");
}
}
}
}
private
static
Vector3
vector3From2
(
Vector2
v
,
float
z
)
{
return
new
Vector3
(
v
.
x
,
v
.
y
,
z
);
}
static
Vector2
mousePosCorrection
(
Vector2
pos
)
{
pos
.
x
=
Mathf
.
Floor
(
pos
.
x
+
.
5f
);
...
...
@@ -77,26 +106,38 @@ public class MapEditor : MonoBehaviour
return
pos
;
}
public
static
void
createTileAt
(
Vector2
pos
)
public
static
GameObject
createTileAt
(
Vector2
pos
,
GameObject
t
=
null
)
{
if
(
t
==
null
)
{
t
=
Tile
;
}
if
(!
World
.
Ready
())
{
Debug
.
LogError
(
"World not initialized! Please set a width, height, and depth in the inspector and click \"Set\"."
);
return
;
Debug
.
LogError
(
"World not initialized!\n"
+
"Please set a width, height, and depth in the inspector and click \"Set\"."
);