Commit 53b86277 authored by 18손재민's avatar 18손재민

맵 에디터 구상 중, 맵 에디터 상 좌표계 구현

parent bc050b1c
......@@ -41,7 +41,7 @@ GameObject:
- component: {fileID: 630498074781569475}
- component: {fileID: 630498074781569474}
m_Layer: 0
m_Name: TestStage
m_Name: EmptyStage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -75,12 +75,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: aa2c12f6bf26415469ec088e3e4c4dc3, type: 3}
m_Name:
m_EditorClassIdentifier:
testInputSizeX: 10
testInputSizeY: 10
testInputSizeX: 0
testInputSizeY: 0
maxMapSize: 0
floors: {fileID: 630498074586648370}
walls: {fileID: 630498075143909950}
player: {fileID: 0}
startFloor: {fileID: 0}
--- !u!1 &630498075143909950
GameObject:
m_ObjectHideFlags: 0
......
fileFormatVersion: 2
guid: 9b219bb14a482aa4c8460619c90312c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8597978733200129170
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8597978733200416946}
- component: {fileID: 8597978733203316882}
- component: {fileID: 8597978733202317906}
- component: {fileID: 9166241847752342704}
- component: {fileID: 7449840556337937162}
m_Layer: 0
m_Name: MapEditorTile
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8597978733200416946
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8597978733200129170}
m_LocalRotation: {x: 0.000001809995, 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: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &8597978733203316882
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8597978733200129170}
m_Mesh: {fileID: 4300000, guid: 1eb88a64f1ed5e44d99d6eafe7b4cdd7, type: 3}
--- !u!23 &8597978733202317906
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8597978733200129170}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: af605edc8af008346a3f42f355847da6, type: 2}
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_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!65 &9166241847752342704
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8597978733200129170}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.0000005, y: 0.20000361, z: 1.0000007}
m_Center: {x: -0.000000029802322, y: 0, z: 0}
--- !u!114 &7449840556337937162
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8597978733200129170}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8cae5dd6b76966642887959d57d32206, type: 3}
m_Name:
m_EditorClassIdentifier:
fileFormatVersion: 2
guid: 90d0ab9f40a0ddc4c871130319d86cd5
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -9,7 +9,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 6014610519130626206}
- component: {fileID: 6014610519130626207}
- component: {fileID: 1971589825}
m_Layer: 0
m_Name: MapManager
m_TagString: Untagged
......@@ -31,7 +31,7 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &6014610519130626207
--- !u!114 &1971589825
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -40,13 +40,12 @@ MonoBehaviour:
m_GameObject: {fileID: 6014610519130626400}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9c46ee6a780f2c3428a79748eadabea8, type: 3}
m_Script: {fileID: 11500000, guid: 5ad2f39c48d82964f86cd2d6e1e94641, type: 3}
m_Name:
m_EditorClassIdentifier:
floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
wall: {fileID: 3736402816908646744, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, type: 3}
player: {fileID: 0}
currentMap: {fileID: 0}
surface: {fileID: 0}
stage:
- {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b, type: 3}
tile: {fileID: 7449840556337937162, guid: 90d0ab9f40a0ddc4c871130319d86cd5, type: 3}
fileFormatVersion: 2
guid: 188c5bb63fb2a9748b461c34c243dc26
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: d497e786cde06654d95b00ea985c6d2a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -202,10 +202,9 @@ public class Map : MonoBehaviour
{
floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>();
//LoadObjects();
LoadObjects();
maxMapSize = 5 * Mathf.Max(testInputSizeX, testInputSizeY);
CreateFloor(new Vector2Int(0, 0), new Vector2Int(9, 9));
MapManager.inst.surface.BuildNavMesh();
//CreateFloor(new Vector2Int(0, 0), new Vector2Int(9, 9));
}
// Start is called before the first frame update
......
fileFormatVersion: 2
guid: 22cf8a391a41eea42be8e55c25d8d563
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.AI;
public class MapEditor : SingletonBehaviour<MapEditor>
{
public Floor floor;
public Wall wall;
public Map currentMap;
public Map[] stage;
public MapEditorTile tile;
public void LoadMap(Map _newMap)
{
if (currentMap != null)
Destroy(currentMap.gameObject);
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
}
/// <summary>
/// Saves map to Assets folder.
/// </summary>
/// <param name="_newMap"></param>
public void SaveMap(Map _newMap)
{
System.DateTime time = System.DateTime.Now;
string localPath = "Assets/SavedMap_" + time.ToShortDateString() + "-" + time.Hour + "-" + time.Minute + "-" + time.Second + ".prefab";
if (AssetDatabase.LoadAssetAtPath(localPath, typeof(GameObject)))
Debug.Log("Object with same name already exists.");
else
{
PrefabUtility.SaveAsPrefabAsset(_newMap.gameObject, localPath);
Debug.Log("Map saved at " + localPath);
}
}
private void Awake()
{
}
// Start is called before the first frame update
void Start()
{
LoadMap(stage[0]);
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
Instantiate(tile, new Vector3(i, 0, j), Quaternion.identity).GetComponent<MapEditorTile>().mapPos = new Vector2(i, j);
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(mouseRay, out hit))
{
Debug.Log(hit.collider.gameObject.transform.position);
}
}
}
}
fileFormatVersion: 2
guid: 5ad2f39c48d82964f86cd2d6e1e94641
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapEditorCamera : MonoBehaviour
{
void CameraMove()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
transform.position += new Vector3(horizontalInput / 2, 0, verticalInput / 2);
}
void CameraZoom()
{
float mouseWheel = -Input.GetAxis("Mouse ScrollWheel");
transform.position += new Vector3(0, mouseWheel * 5, 0);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
CameraMove();
CameraZoom();
}
}
fileFormatVersion: 2
guid: 33643b4d19b5aba4294f4b5894d3404b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapEditorTile : MonoBehaviour
{
public Vector2 mapPos;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 8cae5dd6b76966642887959d57d32206
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -19,6 +19,7 @@ public class MapManager : SingletonBehaviour<MapManager>
Destroy(currentMap.gameObject);
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
surface.BuildNavMesh();
player.transform.position = currentMap.startFloor.transform.position + new Vector3(0, 1.5f, 0);
}
public IEnumerator Rebaker()
......@@ -26,22 +27,6 @@ public class MapManager : SingletonBehaviour<MapManager>
yield return null;
surface.BuildNavMesh();
}
/// <summary>
/// Saves map to Assets folder.
/// </summary>
/// <param name="_newMap"></param>
public void SaveMap(Map _newMap)
{
System.DateTime time = System.DateTime.Now;
string localPath = "Assets/SavedMap_" + time.ToShortDateString() + "-" + time.Hour + "-" + time.Minute + "-" + time.Second + ".prefab";
if (AssetDatabase.LoadAssetAtPath(localPath, typeof(GameObject)))
Debug.Log("Object with same name already exists.");
else
{
PrefabUtility.SaveAsPrefabAsset(_newMap.gameObject, localPath);
Debug.Log("Map saved at " + localPath);
}
}
private void Awake()
{
......@@ -51,7 +36,7 @@ public class MapManager : SingletonBehaviour<MapManager>
// Start is called before the first frame update
void Start()
{
LoadMap(stage[0]);
//LoadMap(stage[0]);
}
// Update is called once per frame
......
......@@ -32,7 +32,7 @@ public class TestTools : MonoBehaviour
public void SaveMap()
{
MapManager.inst.SaveMap(MapManager.inst.currentMap);
MapEditor.inst.SaveMap(MapManager.inst.currentMap);
}
public void LoadMap()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment