Ken Schaefer
1 year ago
9 changed files with 871 additions and 0 deletions
@ -0,0 +1,113 @@ |
|||||||
|
/*Original Code: http://wiki.unity3d.com/index.php?title=MouseOrbitZoom*/ |
||||||
|
/*Modified by Penny de Byl on 8 Aug 2017. |
||||||
|
to Zoom with scroll, orbit with ALT and Pan with Q |
||||||
|
*/ |
||||||
|
|
||||||
|
using UnityEngine; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
public class CameraController : MonoBehaviour |
||||||
|
{ |
||||||
|
public Transform target; |
||||||
|
public Vector3 targetOffset; |
||||||
|
public float distance = 5.0f; |
||||||
|
public float maxDistance = 100; |
||||||
|
public float minDistance = .6f; |
||||||
|
public float xSpeed = 200.0f; |
||||||
|
public float ySpeed = 200.0f; |
||||||
|
public int yMinLimit = -80; |
||||||
|
public int yMaxLimit = 80; |
||||||
|
public int zoomRate = 40; |
||||||
|
public float panSpeed = 0.3f; |
||||||
|
public float zoomDampening = 5.0f; |
||||||
|
|
||||||
|
private float xDeg = 0.0f; |
||||||
|
private float yDeg = 0.0f; |
||||||
|
private float currentDistance; |
||||||
|
private float desiredDistance; |
||||||
|
private Quaternion currentRotation; |
||||||
|
private Quaternion desiredRotation; |
||||||
|
private Quaternion rotation; |
||||||
|
private Vector3 position; |
||||||
|
|
||||||
|
void Start() { Init(); } |
||||||
|
|
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
GameObject go = new GameObject("Fake Cam Target"); |
||||||
|
go.transform.position = transform.position + (transform.forward * distance); |
||||||
|
target = go.transform; |
||||||
|
|
||||||
|
distance = Vector3.Distance(transform.position, target.position); |
||||||
|
currentDistance = distance; |
||||||
|
desiredDistance = distance; |
||||||
|
|
||||||
|
//be sure to grab the current rotations as starting points. |
||||||
|
position = transform.position; |
||||||
|
rotation = transform.rotation; |
||||||
|
currentRotation = transform.rotation; |
||||||
|
desiredRotation = transform.rotation; |
||||||
|
|
||||||
|
xDeg = Vector3.Angle(Vector3.right, transform.right ); |
||||||
|
yDeg = Vector3.Angle(Vector3.up, transform.up ); |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* Camera logic on LateUpdate to only update after all character movement logic has been handled. |
||||||
|
*/ |
||||||
|
void LateUpdate() |
||||||
|
{ |
||||||
|
// If Control and Alt and Middle button? ZOOM! |
||||||
|
if (Input.GetMouseButton(0) && Input.GetKey(KeyCode.LeftAlt) && Input.GetKey(KeyCode.LeftControl)) |
||||||
|
{ |
||||||
|
desiredDistance -= Input.GetAxis("Mouse Y") * Time.deltaTime * zoomRate*0.125f * Mathf.Abs(desiredDistance); |
||||||
|
} |
||||||
|
// If middle mouse and left alt are selected? ORBIT |
||||||
|
else if (Input.GetMouseButton(0) && Input.GetKey(KeyCode.LeftAlt)) |
||||||
|
{ |
||||||
|
xDeg += Input.GetAxis("Mouse X") * xSpeed * 0.02f; |
||||||
|
yDeg -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f; |
||||||
|
|
||||||
|
////////OrbitAngle |
||||||
|
|
||||||
|
//Clamp the vertical axis for the orbit |
||||||
|
yDeg = ClampAngle(yDeg, yMinLimit, yMaxLimit); |
||||||
|
// set camera rotation |
||||||
|
desiredRotation = Quaternion.Euler(yDeg, xDeg, 0); |
||||||
|
currentRotation = transform.rotation; |
||||||
|
|
||||||
|
rotation = Quaternion.Lerp(currentRotation, desiredRotation, Time.deltaTime * zoomDampening); |
||||||
|
transform.rotation = rotation; |
||||||
|
} |
||||||
|
// left mouse button and Q key, we pan by way of transforming the target in screenspace |
||||||
|
else if (Input.GetMouseButton(0) && Input.GetKey(KeyCode.Q)) |
||||||
|
{ |
||||||
|
//grab the rotation of the camera so we can move in a psuedo local XY space |
||||||
|
target.rotation = transform.rotation; |
||||||
|
target.Translate(Vector3.right * -Input.GetAxis("Mouse X") * panSpeed); |
||||||
|
target.Translate(transform.up * -Input.GetAxis("Mouse Y") * panSpeed, Space.World); |
||||||
|
} |
||||||
|
|
||||||
|
////////Orbit Position |
||||||
|
|
||||||
|
// affect the desired Zoom distance if we roll the scrollwheel |
||||||
|
desiredDistance -= Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * zoomRate * Mathf.Abs(desiredDistance); |
||||||
|
//clamp the zoom min/max |
||||||
|
desiredDistance = Mathf.Clamp(desiredDistance, minDistance, maxDistance); |
||||||
|
// For smoothing of the zoom, lerp distance |
||||||
|
currentDistance = Mathf.Lerp(currentDistance, desiredDistance, Time.deltaTime * zoomDampening); |
||||||
|
|
||||||
|
// calculate position based on the new currentDistance |
||||||
|
position = target.position - (rotation * Vector3.forward * currentDistance + targetOffset); |
||||||
|
transform.position = position; |
||||||
|
} |
||||||
|
|
||||||
|
private static float ClampAngle(float angle, float min, float max) |
||||||
|
{ |
||||||
|
if (angle < -360) |
||||||
|
angle += 360; |
||||||
|
if (angle > 360) |
||||||
|
angle -= 360; |
||||||
|
return Mathf.Clamp(angle, min, max); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: d85e13f9b7bea8b4ba6ffc1a8a6580af |
||||||
|
MonoImporter: |
||||||
|
externalObjects: {} |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,107 @@ |
|||||||
|
%YAML 1.1 |
||||||
|
%TAG !u! tag:unity3d.com,2011: |
||||||
|
--- !u!1 &5475930449491509175 |
||||||
|
GameObject: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
serializedVersion: 6 |
||||||
|
m_Component: |
||||||
|
- component: {fileID: 4469321960055167392} |
||||||
|
- component: {fileID: 5025310876491027969} |
||||||
|
- component: {fileID: 9208751553981482026} |
||||||
|
- component: {fileID: 425290531723459899} |
||||||
|
m_Layer: 0 |
||||||
|
m_Name: Cube |
||||||
|
m_TagString: Untagged |
||||||
|
m_Icon: {fileID: 0} |
||||||
|
m_NavMeshLayer: 0 |
||||||
|
m_StaticEditorFlags: 0 |
||||||
|
m_IsActive: 1 |
||||||
|
--- !u!4 &4469321960055167392 |
||||||
|
Transform: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 5475930449491509175} |
||||||
|
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: 3 |
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||||
|
--- !u!33 &5025310876491027969 |
||||||
|
MeshFilter: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 5475930449491509175} |
||||||
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} |
||||||
|
--- !u!23 &9208751553981482026 |
||||||
|
MeshRenderer: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 5475930449491509175} |
||||||
|
m_Enabled: 1 |
||||||
|
m_CastShadows: 1 |
||||||
|
m_ReceiveShadows: 1 |
||||||
|
m_DynamicOccludee: 1 |
||||||
|
m_StaticShadowCaster: 0 |
||||||
|
m_MotionVectors: 1 |
||||||
|
m_LightProbeUsage: 1 |
||||||
|
m_ReflectionProbeUsage: 1 |
||||||
|
m_RayTracingMode: 2 |
||||||
|
m_RayTraceProcedural: 0 |
||||||
|
m_RenderingLayerMask: 1 |
||||||
|
m_RendererPriority: 0 |
||||||
|
m_Materials: |
||||||
|
- {fileID: 10303, 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_ReceiveGI: 1 |
||||||
|
m_PreserveUVs: 0 |
||||||
|
m_IgnoreNormalsForChartDetection: 0 |
||||||
|
m_ImportantGI: 0 |
||||||
|
m_StitchLightmapSeams: 1 |
||||||
|
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 |
||||||
|
m_AdditionalVertexStreams: {fileID: 0} |
||||||
|
--- !u!65 &425290531723459899 |
||||||
|
BoxCollider: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 5475930449491509175} |
||||||
|
m_Material: {fileID: 0} |
||||||
|
m_IncludeLayers: |
||||||
|
serializedVersion: 2 |
||||||
|
m_Bits: 0 |
||||||
|
m_ExcludeLayers: |
||||||
|
serializedVersion: 2 |
||||||
|
m_Bits: 0 |
||||||
|
m_LayerOverridePriority: 0 |
||||||
|
m_IsTrigger: 0 |
||||||
|
m_ProvidesContacts: 0 |
||||||
|
m_Enabled: 1 |
||||||
|
serializedVersion: 3 |
||||||
|
m_Size: {x: 1, y: 1, z: 1} |
||||||
|
m_Center: {x: 0, y: 0, z: 0} |
@ -0,0 +1,7 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 2d42cfb30644ee64fb30446b8727104a |
||||||
|
PrefabImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,385 @@ |
|||||||
|
%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: 0 |
||||||
|
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} |
||||||
|
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 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.44657874, g: 0.49641275, b: 0.5748171, 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: 1 |
||||||
|
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: 3 |
||||||
|
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 |
||||||
|
buildHeightMesh: 0 |
||||||
|
maxJobWorkers: 0 |
||||||
|
preserveTilesOutsideBounds: 0 |
||||||
|
debug: |
||||||
|
m_Flags: 0 |
||||||
|
m_NavMeshData: {fileID: 0} |
||||||
|
--- !u!1 &501027937 |
||||||
|
GameObject: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
serializedVersion: 6 |
||||||
|
m_Component: |
||||||
|
- component: {fileID: 501027939} |
||||||
|
- component: {fileID: 501027938} |
||||||
|
m_Layer: 0 |
||||||
|
m_Name: Directional Light |
||||||
|
m_TagString: Untagged |
||||||
|
m_Icon: {fileID: 0} |
||||||
|
m_NavMeshLayer: 0 |
||||||
|
m_StaticEditorFlags: 0 |
||||||
|
m_IsActive: 1 |
||||||
|
--- !u!108 &501027938 |
||||||
|
Light: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 501027937} |
||||||
|
m_Enabled: 1 |
||||||
|
serializedVersion: 10 |
||||||
|
m_Type: 1 |
||||||
|
m_Shape: 0 |
||||||
|
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} |
||||||
|
m_Intensity: 1 |
||||||
|
m_Range: 10 |
||||||
|
m_SpotAngle: 30 |
||||||
|
m_InnerSpotAngle: 21.80208 |
||||||
|
m_CookieSize: 10 |
||||||
|
m_Shadows: |
||||||
|
m_Type: 2 |
||||||
|
m_Resolution: -1 |
||||||
|
m_CustomResolution: -1 |
||||||
|
m_Strength: 1 |
||||||
|
m_Bias: 0.05 |
||||||
|
m_NormalBias: 0.4 |
||||||
|
m_NearPlane: 0.2 |
||||||
|
m_CullingMatrixOverride: |
||||||
|
e00: 1 |
||||||
|
e01: 0 |
||||||
|
e02: 0 |
||||||
|
e03: 0 |
||||||
|
e10: 0 |
||||||
|
e11: 1 |
||||||
|
e12: 0 |
||||||
|
e13: 0 |
||||||
|
e20: 0 |
||||||
|
e21: 0 |
||||||
|
e22: 1 |
||||||
|
e23: 0 |
||||||
|
e30: 0 |
||||||
|
e31: 0 |
||||||
|
e32: 0 |
||||||
|
e33: 1 |
||||||
|
m_UseCullingMatrixOverride: 0 |
||||||
|
m_Cookie: {fileID: 0} |
||||||
|
m_DrawHalo: 0 |
||||||
|
m_Flare: {fileID: 0} |
||||||
|
m_RenderMode: 0 |
||||||
|
m_CullingMask: |
||||||
|
serializedVersion: 2 |
||||||
|
m_Bits: 4294967295 |
||||||
|
m_RenderingLayerMask: 1 |
||||||
|
m_Lightmapping: 4 |
||||||
|
m_LightShadowCasterMode: 0 |
||||||
|
m_AreaSize: {x: 1, y: 1} |
||||||
|
m_BounceIntensity: 1 |
||||||
|
m_ColorTemperature: 6570 |
||||||
|
m_UseColorTemperature: 0 |
||||||
|
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} |
||||||
|
m_UseBoundingSphereOverride: 0 |
||||||
|
m_UseViewFrustumForShadowCasterCull: 1 |
||||||
|
m_ShadowRadius: 0 |
||||||
|
m_ShadowAngle: 0 |
||||||
|
--- !u!4 &501027939 |
||||||
|
Transform: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 501027937} |
||||||
|
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} |
||||||
|
m_LocalPosition: {x: 0, y: 3, 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: 50, y: -30, z: 0} |
||||||
|
--- !u!1 &678003657 |
||||||
|
GameObject: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
serializedVersion: 6 |
||||||
|
m_Component: |
||||||
|
- component: {fileID: 678003659} |
||||||
|
- component: {fileID: 678003658} |
||||||
|
m_Layer: 0 |
||||||
|
m_Name: World |
||||||
|
m_TagString: Untagged |
||||||
|
m_Icon: {fileID: 0} |
||||||
|
m_NavMeshLayer: 0 |
||||||
|
m_StaticEditorFlags: 0 |
||||||
|
m_IsActive: 1 |
||||||
|
--- !u!114 &678003658 |
||||||
|
MonoBehaviour: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 678003657} |
||||||
|
m_Enabled: 1 |
||||||
|
m_EditorHideFlags: 0 |
||||||
|
m_Script: {fileID: 11500000, guid: 5dc30db358c1c60469932cd4982e3684, type: 3} |
||||||
|
m_Name: |
||||||
|
m_EditorClassIdentifier: |
||||||
|
block: {fileID: 5475930449491509175, guid: 2d42cfb30644ee64fb30446b8727104a, type: 3} |
||||||
|
worldSize: 2 |
||||||
|
worldHeight: 3 |
||||||
|
worldWidth: 10 |
||||||
|
worldDepth: 10 |
||||||
|
--- !u!4 &678003659 |
||||||
|
Transform: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 678003657} |
||||||
|
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: 2 |
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||||
|
--- !u!1 &1166274740 |
||||||
|
GameObject: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
serializedVersion: 6 |
||||||
|
m_Component: |
||||||
|
- component: {fileID: 1166274744} |
||||||
|
- component: {fileID: 1166274743} |
||||||
|
- component: {fileID: 1166274742} |
||||||
|
- component: {fileID: 1166274741} |
||||||
|
m_Layer: 0 |
||||||
|
m_Name: Main Camera |
||||||
|
m_TagString: MainCamera |
||||||
|
m_Icon: {fileID: 0} |
||||||
|
m_NavMeshLayer: 0 |
||||||
|
m_StaticEditorFlags: 0 |
||||||
|
m_IsActive: 1 |
||||||
|
--- !u!114 &1166274741 |
||||||
|
MonoBehaviour: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 1166274740} |
||||||
|
m_Enabled: 1 |
||||||
|
m_EditorHideFlags: 0 |
||||||
|
m_Script: {fileID: 11500000, guid: d85e13f9b7bea8b4ba6ffc1a8a6580af, type: 3} |
||||||
|
m_Name: |
||||||
|
m_EditorClassIdentifier: |
||||||
|
target: {fileID: 0} |
||||||
|
targetOffset: {x: 0, y: 0, z: 0} |
||||||
|
distance: 5 |
||||||
|
maxDistance: 100 |
||||||
|
minDistance: 0.6 |
||||||
|
xSpeed: 200 |
||||||
|
ySpeed: 200 |
||||||
|
yMinLimit: -80 |
||||||
|
yMaxLimit: 80 |
||||||
|
zoomRate: 40 |
||||||
|
panSpeed: 0.3 |
||||||
|
zoomDampening: 5 |
||||||
|
--- !u!81 &1166274742 |
||||||
|
AudioListener: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 1166274740} |
||||||
|
m_Enabled: 1 |
||||||
|
--- !u!20 &1166274743 |
||||||
|
Camera: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 1166274740} |
||||||
|
m_Enabled: 1 |
||||||
|
serializedVersion: 2 |
||||||
|
m_ClearFlags: 1 |
||||||
|
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} |
||||||
|
m_projectionMatrixMode: 1 |
||||||
|
m_GateFitMode: 2 |
||||||
|
m_FOVAxisMode: 0 |
||||||
|
m_Iso: 200 |
||||||
|
m_ShutterSpeed: 0.005 |
||||||
|
m_Aperture: 16 |
||||||
|
m_FocusDistance: 10 |
||||||
|
m_FocalLength: 50 |
||||||
|
m_BladeCount: 5 |
||||||
|
m_Curvature: {x: 2, y: 11} |
||||||
|
m_BarrelClipping: 0.25 |
||||||
|
m_Anamorphism: 0 |
||||||
|
m_SensorSize: {x: 36, y: 24} |
||||||
|
m_LensShift: {x: 0, y: 0} |
||||||
|
m_NormalizedViewPortRect: |
||||||
|
serializedVersion: 2 |
||||||
|
x: 0 |
||||||
|
y: 0 |
||||||
|
width: 1 |
||||||
|
height: 1 |
||||||
|
near clip plane: 0.3 |
||||||
|
far clip plane: 1000 |
||||||
|
field of view: 60 |
||||||
|
orthographic: 0 |
||||||
|
orthographic size: 5 |
||||||
|
m_Depth: -1 |
||||||
|
m_CullingMask: |
||||||
|
serializedVersion: 2 |
||||||
|
m_Bits: 4294967295 |
||||||
|
m_RenderingPath: -1 |
||||||
|
m_TargetTexture: {fileID: 0} |
||||||
|
m_TargetDisplay: 0 |
||||||
|
m_TargetEye: 3 |
||||||
|
m_HDR: 1 |
||||||
|
m_AllowMSAA: 1 |
||||||
|
m_AllowDynamicResolution: 0 |
||||||
|
m_ForceIntoRT: 0 |
||||||
|
m_OcclusionCulling: 1 |
||||||
|
m_StereoConvergence: 10 |
||||||
|
m_StereoSeparation: 0.022 |
||||||
|
--- !u!4 &1166274744 |
||||||
|
Transform: |
||||||
|
m_ObjectHideFlags: 0 |
||||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||||
|
m_PrefabInstance: {fileID: 0} |
||||||
|
m_PrefabAsset: {fileID: 0} |
||||||
|
m_GameObject: {fileID: 1166274740} |
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||||
|
m_LocalPosition: {x: 0, y: 1, z: -10} |
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1} |
||||||
|
m_ConstrainProportionsScale: 0 |
||||||
|
m_Children: [] |
||||||
|
m_Father: {fileID: 0} |
||||||
|
m_RootOrder: 0 |
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
@ -0,0 +1,7 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: e595882482e80d84895bdb22018b57b8 |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,63 @@ |
|||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
using UnityEngine; |
||||||
|
|
||||||
|
public class WorldController : MonoBehaviour |
||||||
|
{ |
||||||
|
public GameObject block; |
||||||
|
public int worldSize = 2; |
||||||
|
public int worldHeight = 2; // y |
||||||
|
public int worldWidth = 2; // x |
||||||
|
public int worldDepth = 2; // z |
||||||
|
|
||||||
|
public IEnumerator BuildWorld() |
||||||
|
{ |
||||||
|
for(int z = 0; z < worldDepth; z++) |
||||||
|
for(int y = 0; y < worldHeight; y++) |
||||||
|
{ |
||||||
|
for(int x = 0; x < worldWidth; x++) |
||||||
|
{ |
||||||
|
// randomizes only the top layer |
||||||
|
if (y == worldHeight - 1 && Random.Range(0, 100) < 50) continue; |
||||||
|
|
||||||
|
// randomizes the top two layers |
||||||
|
if (y >= worldHeight - 2 && Random.Range(0, 100) < 50) continue; |
||||||
|
|
||||||
|
|
||||||
|
Vector3 pos = new Vector3(x, y, z); |
||||||
|
GameObject cube = GameObject.Instantiate(block, pos, Quaternion.identity); |
||||||
|
cube.name = x + "_" + y + "_" + z; |
||||||
|
|
||||||
|
/* My solution |
||||||
|
if(y == 0) |
||||||
|
{ |
||||||
|
Vector3 pos = new Vector3(x, y, z); |
||||||
|
GameObject cube = GameObject.Instantiate(block, pos, Quaternion.identity); |
||||||
|
cube.name = x + "_" + y + "_" + z; |
||||||
|
} |
||||||
|
else if(Random.Range(0, 2) == 1 && y > 0) |
||||||
|
{ |
||||||
|
Vector3 pos = new Vector3(x, y, z); |
||||||
|
GameObject cube = GameObject.Instantiate(block, pos, Quaternion.identity); |
||||||
|
cube.name = x + "_" + y + "_" + z; |
||||||
|
} |
||||||
|
*/ |
||||||
|
|
||||||
|
} |
||||||
|
yield return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Start is called before the first frame update |
||||||
|
void Start() |
||||||
|
{ |
||||||
|
StartCoroutine(BuildWorld()); |
||||||
|
} |
||||||
|
|
||||||
|
// Update is called once per frame |
||||||
|
void Update() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 5dc30db358c1c60469932cd4982e3684 |
||||||
|
MonoImporter: |
||||||
|
externalObjects: {} |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,167 @@ |
|||||||
|
{ |
||||||
|
"templatePinStates": [], |
||||||
|
"dependencyTypeInfos": [ |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.AnimationClip", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEditor.Animations.AnimatorController", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.AnimatorOverrideController", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEditor.Audio.AudioMixerController", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.ComputeShader", |
||||||
|
"ignore": true, |
||||||
|
"defaultInstantiationMode": 1, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Cubemap", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.GameObject", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEditor.LightingDataAsset", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": false |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.LightingSettings", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Material", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEditor.MonoScript", |
||||||
|
"ignore": true, |
||||||
|
"defaultInstantiationMode": 1, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.PhysicMaterial", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.PhysicsMaterial2D", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Rendering.VolumeProfile", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEditor.SceneAsset", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 1, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Shader", |
||||||
|
"ignore": true, |
||||||
|
"defaultInstantiationMode": 1, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.ShaderVariantCollection", |
||||||
|
"ignore": true, |
||||||
|
"defaultInstantiationMode": 1, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Texture", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Texture2D", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"userAdded": false, |
||||||
|
"type": "UnityEngine.Timeline.TimelineAsset", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 0, |
||||||
|
"supportsModification": true |
||||||
|
} |
||||||
|
], |
||||||
|
"defaultDependencyTypeInfo": { |
||||||
|
"userAdded": false, |
||||||
|
"type": "<default_scene_template_dependencies>", |
||||||
|
"ignore": false, |
||||||
|
"defaultInstantiationMode": 1, |
||||||
|
"supportsModification": true |
||||||
|
}, |
||||||
|
"newSceneOverride": 0 |
||||||
|
} |
Loading…
Reference in new issue