This commit is contained in:
j.mei7
2022-03-07 18:41:03 +01:00
parent e884e44c54
commit 7c0586867b
6 changed files with 371 additions and 0 deletions

View File

@@ -1,2 +1,240 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &334969309
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877744, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877900, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_Name
value: Main Camera
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877903, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_BackGroundColor.b
value: 0.16981131
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877903, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_BackGroundColor.g
value: 0.13604428
objectReference: {fileID: 0}
- target: {fileID: 7365408954618877903, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
propertyPath: m_BackGroundColor.r
value: 0.12415449
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
--- !u!1 &1006363046
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1006363048}
- component: {fileID: 1006363047}
m_Layer: 0
m_Name: TestGrid
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1006363047
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1006363046}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 29730cb0d1ffeb247be75654297759f2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1006363048
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1006363046}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

8
Assets/Scripts/Grid.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 899c6b51f58f4da42b8110dbab2ea916
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Grid
{
int width, height;
float cellSize;
Vector3 originPosition;
int[,] gridArray;
public Grid(int _width, int _height, float _cellSize, Vector3 _originPosition)
{
width = _width;
height = _height;
cellSize = _cellSize;
originPosition = _originPosition;
gridArray = new int[width, height];
for(int x = 0; x < gridArray.GetLength(0); x++)
{
for (int y = 0; y < gridArray.GetLength(1); y++)
{
Debug.DrawLine(GetWorldPosition(x, y), GetWorldPosition(x, y+1), Color.white, 100f);
Debug.DrawLine(GetWorldPosition(x, y), GetWorldPosition(x+1,y), Color.white, 100f);
}
}
Debug.DrawLine(GetWorldPosition(0, height), GetWorldPosition(width, height), Color.white, 100f);
Debug.DrawLine(GetWorldPosition(width, 0), GetWorldPosition(width, height), Color.white, 100f);
}
Vector3 GetWorldPosition(int x, int y)
{
return new Vector3(x, y) * cellSize + originPosition;
}
void GetXY(Vector3 worldPosition, out int x, out int y)
{
x = Mathf.FloorToInt((worldPosition - originPosition).x / cellSize);
y = Mathf.FloorToInt((worldPosition - originPosition).y / cellSize);
}
public void SetValue(int x, int y, int value)
{
if(x >= 0 && y >= 0 && x < width && y < height)
{
gridArray[x, y] = value;
Debug.Log(x.ToString() + " " + y.ToString() + " -> " + value.ToString());
}
}
public void SetValue(Vector3 worldPosition, int value)
{
int x, y;
GetXY(worldPosition, out x, out y);
SetValue(x, y, value);
}
public int GetValue(int x, int y)
{
if (x >= 0 && y >= 0 && x < width && y < height)
{
return gridArray[x, y];
}
else
{
return 0;
}
}
public int GetValue(Vector3 worldPosition)
{
int x, y;
GetXY(worldPosition, out x, out y);
return GetValue(x, y);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 410bfb52f88e7434a93933b875d268bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestGrid : MonoBehaviour
{
Grid grid;
void Start()
{
grid = new Grid(100, 100, 1, new Vector3(0, 0));
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
grid.SetValue(Camera.main.ScreenToWorldPoint(Input.mousePosition), 44);
}
if (Input.GetMouseButtonDown(1))
{
Debug.Log(grid.GetValue(Camera.main.ScreenToWorldPoint(Input.mousePosition)));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29730cb0d1ffeb247be75654297759f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: