From b39c2889e4e7d3e48dc243448b689cdd0f7f78c7 Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 11:16:12 +0900 Subject: [PATCH 1/8] Scale System Add --- .../Assets/HelloCube/1. ForEach/ForEach.unity | 617 +++++++++++++++++- .../RotationSpeedAuthoring_ForEach.cs | 4 + .../1. ForEach/ScaleSpeedAuthoring_ForEach.cs | 16 + .../ScaleSpeedAuthoring_ForEach.cs.meta | 11 + .../1. ForEach/ScaleSpeedSystem_ForEach.cs | 27 + .../ScaleSpeedSystem_ForEach.cs.meta | 11 + .../1. ForEach/ScaleSpeed_ForEach.cs | 10 + .../1. ForEach/ScaleSpeed_ForEach.cs.meta | 11 + ECSSamples/Logs/Packages-Update.log | 17 + ECSSamples/Packages/manifest.json | 12 +- ECSSamples/ProjectSettings/ProjectVersion.txt | 4 +- 11 files changed, 734 insertions(+), 6 deletions(-) create mode 100644 ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs create mode 100644 ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs create mode 100644 ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs create mode 100644 ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs.meta create mode 100644 ECSSamples/Logs/Packages-Update.log diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ForEach.unity b/ECSSamples/Assets/HelloCube/1. ForEach/ForEach.unity index 9239fc23c..75278f99a 100644 --- a/ECSSamples/Assets/HelloCube/1. ForEach/ForEach.unity +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ForEach.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 170076734} - m_IndirectSpecularColor: {r: 0.18028374, g: 0.22571413, b: 0.3069228, a: 1} + m_IndirectSpecularColor: {r: 0.18028334, g: 0.2257134, b: 0.30692226, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -94,8 +94,8 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -211,6 +211,127 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &306447991 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 306447997} + - component: {fileID: 306447996} + - component: {fileID: 306447995} + - component: {fileID: 306447994} + - component: {fileID: 306447993} + - component: {fileID: 306447992} + m_Layer: 0 + m_Name: RotatingCube (3) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &306447992 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 306447991} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4616e9667aee8cd4d887a57c18210756, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 0.3 +--- !u!114 &306447993 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 306447991} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea7d7495833204790ba1d3a8755397f8, type: 3} + m_Name: + m_EditorClassIdentifier: + ConversionMode: 0 +--- !u!114 &306447994 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 306447991} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 54465263367634774b7309152e1b4aed, type: 3} + m_Name: + m_EditorClassIdentifier: + DegreesPerSecond: 180 +--- !u!23 &306447995 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 306447991} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!33 &306447996 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 306447991} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &306447997 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 306447991} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3.67, y: 0, z: -0.4} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 605229711} + m_Father: {fileID: 0} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &534669902 GameObject: m_ObjectHideFlags: 0 @@ -294,6 +415,361 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &605229710 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 605229711} + - component: {fileID: 605229713} + - component: {fileID: 605229712} + m_Layer: 0 + m_Name: ChildCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &605229711 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 605229710} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.54, z: 0} + m_LocalScale: {x: 0.52272, y: 0.52272, z: 0.52272} + m_Children: [] + m_Father: {fileID: 306447997} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &605229712 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 605229710} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!33 &605229713 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 605229710} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &634635385 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 634635386} + - component: {fileID: 634635388} + - component: {fileID: 634635387} + m_Layer: 0 + m_Name: ChildCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &634635386 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 634635385} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.54, z: 0} + m_LocalScale: {x: 0.52272, y: 0.52272, z: 0.52272} + m_Children: [] + m_Father: {fileID: 1743080028} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &634635387 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 634635385} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!33 &634635388 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 634635385} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &957430664 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 957430670} + - component: {fileID: 957430669} + - component: {fileID: 957430668} + - component: {fileID: 957430667} + - component: {fileID: 957430666} + - component: {fileID: 957430665} + m_Layer: 0 + m_Name: RotatingCube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &957430665 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 957430664} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4616e9667aee8cd4d887a57c18210756, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 0.1 +--- !u!114 &957430666 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 957430664} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea7d7495833204790ba1d3a8755397f8, type: 3} + m_Name: + m_EditorClassIdentifier: + ConversionMode: 0 +--- !u!114 &957430667 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 957430664} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 54465263367634774b7309152e1b4aed, type: 3} + m_Name: + m_EditorClassIdentifier: + DegreesPerSecond: 180 +--- !u!23 &957430668 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 957430664} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!33 &957430669 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 957430664} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &957430670 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 957430664} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 3.05} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1526715316} + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1526715315 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1526715316} + - component: {fileID: 1526715318} + - component: {fileID: 1526715317} + m_Layer: 0 + m_Name: ChildCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1526715316 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1526715315} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.54, z: 0} + m_LocalScale: {x: 0.52272, y: 0.52272, z: 0.52272} + m_Children: [] + m_Father: {fileID: 957430670} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1526715317 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1526715315} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!33 &1526715318 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1526715315} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1594399724 GameObject: m_ObjectHideFlags: 0 @@ -351,6 +827,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 0 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -371,6 +848,127 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1594399724} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1743080022 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1743080028} + - component: {fileID: 1743080027} + - component: {fileID: 1743080026} + - component: {fileID: 1743080025} + - component: {fileID: 1743080024} + - component: {fileID: 1743080023} + m_Layer: 0 + m_Name: RotatingCube (2) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1743080023 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1743080022} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4616e9667aee8cd4d887a57c18210756, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 0.2 +--- !u!114 &1743080024 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1743080022} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea7d7495833204790ba1d3a8755397f8, type: 3} + m_Name: + m_EditorClassIdentifier: + ConversionMode: 0 +--- !u!114 &1743080025 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1743080022} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 54465263367634774b7309152e1b4aed, type: 3} + m_Name: + m_EditorClassIdentifier: + DegreesPerSecond: 180 +--- !u!23 &1743080026 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1743080022} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!33 &1743080027 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1743080022} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1743080028 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1743080022} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -4.09} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 634635386} + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1993849073 GameObject: m_ObjectHideFlags: 0 @@ -384,6 +982,7 @@ GameObject: - component: {fileID: 1993849076} - component: {fileID: 1993849074} - component: {fileID: 1993849077} + - component: {fileID: 1993849078} m_Layer: 0 m_Name: RotatingCube m_TagString: Untagged @@ -437,6 +1036,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 0 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -462,6 +1062,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: ConversionMode: 0 +--- !u!114 &1993849078 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1993849073} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4616e9667aee8cd4d887a57c18210756, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 1 --- !u!4 &1993849080 Transform: m_ObjectHideFlags: 0 diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/RotationSpeedAuthoring_ForEach.cs b/ECSSamples/Assets/HelloCube/1. ForEach/RotationSpeedAuthoring_ForEach.cs index c67927d45..bfc5c9596 100644 --- a/ECSSamples/Assets/HelloCube/1. ForEach/RotationSpeedAuthoring_ForEach.cs +++ b/ECSSamples/Assets/HelloCube/1. ForEach/RotationSpeedAuthoring_ForEach.cs @@ -1,6 +1,7 @@ using System; using Unity.Entities; using Unity.Mathematics; +using Unity.Transforms; using UnityEngine; // ReSharper disable once InconsistentNaming @@ -15,6 +16,9 @@ public class RotationSpeedAuthoring_ForEach : MonoBehaviour, IConvertGameObjectT public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var data = new RotationSpeed_ForEach { RadiansPerSecond = math.radians(DegreesPerSecond) }; + var scale = new NonUniformScale {Value = new float3(1, 1, 1)}; + dstManager.AddComponentData(entity, data); + dstManager.AddComponentData(entity, scale); } } diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs new file mode 100644 index 000000000..b1886a490 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs @@ -0,0 +1,16 @@ +using Unity.Entities; +using UnityEngine; + +// ReSharper disable once InconsistentNaming +[RequiresEntityConversion] +public class ScaleSpeedAuthoring_ForEach : MonoBehaviour, IConvertGameObjectToEntity +{ + public float ScalePerSecond; + + // 모노비헤비어 데이터는 엔티티의 컴포넌트 데이터로 변형된다. + public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) + { + var data = new ScaleSpeed_ForEach { ScalePerSecond = ScalePerSecond }; + dstManager.AddComponentData(entity, data); + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs.meta b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs.meta new file mode 100644 index 000000000..8e3bb407b --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedAuthoring_ForEach.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4616e9667aee8cd4d887a57c18210756 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs new file mode 100644 index 000000000..bea46edb4 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs @@ -0,0 +1,27 @@ +using Unity.Entities; +using Unity.Transforms; +using UnityEngine; + +// 이 시스템은 장면의 모든 요소를 ScaleSpeedSystem_ForEach 및 Rotation 구성 요소로 모두 업데이트합니다. + +// ReSharper disable once InconsistentNaming +public class ScaleSpeedSystem_ForEach : ComponentSystem +{ + protected override void OnUpdate() + { + // EEntities.ForEach는 기본 스레드에서 각 ComponentData 세트를 처리합니다. 권장하지 않습니다 + // 최상의 성능을위한 방법. 그러나 여기서는 더 명확한 분리를 보여주기 위해 여기에서 시작합니다. + // ComponentSystem 업데이트 (logic)와 ComponentData (데이터) 간. + // 개별 ComponentData에는 업데이트 로직이 없습니다. + Entities.ForEach((ref ScaleSpeed_ForEach scaleSpeed, ref NonUniformScale uniformScale) => + { + var deltaTime = Time.deltaTime; + + var scale = uniformScale.Value; + scale.x += scaleSpeed.ScalePerSecond * deltaTime; + scale.y += scaleSpeed.ScalePerSecond * deltaTime; + scale.z += scaleSpeed.ScalePerSecond * deltaTime; + uniformScale.Value = scale; + }); + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs.meta b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs.meta new file mode 100644 index 000000000..349497b00 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63d0ad56229e7534cb2e8a6d9fb14770 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs new file mode 100644 index 000000000..974f251f3 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs @@ -0,0 +1,10 @@ +using System; +using Unity.Entities; + +// Serializable attribute is for editor support. +// ReSharper disable once InconsistentNaming +[Serializable] +public struct ScaleSpeed_ForEach : IComponentData +{ + public float ScalePerSecond; +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs.meta b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs.meta new file mode 100644 index 000000000..f5a83f489 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeed_ForEach.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 969f20e4a49b49c4c807b5f4502a9efb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Logs/Packages-Update.log b/ECSSamples/Logs/Packages-Update.log new file mode 100644 index 000000000..4d719e421 --- /dev/null +++ b/ECSSamples/Logs/Packages-Update.log @@ -0,0 +1,17 @@ + +=== Tue Oct 15 10:17:44 2019 + +Packages were changed. +Update Mode: updateDependencies + +The following packages were added: + com.unity.2d.tilemap@1.0.0 + com.unity.ext.nunit@1.0.0 + com.unity.test-framework@1.0.13 + com.unity.2d.sprite@1.0.0 + com.unity.ide.vscode@1.1.0 + com.unity.ide.rider@1.1.0 + com.unity.ugui@1.0.0 + com.unity.modules.androidjni@1.0.0 +The following packages were updated: + com.unity.package-manager-ui from version 2.1.2 to 2.2.0 diff --git a/ECSSamples/Packages/manifest.json b/ECSSamples/Packages/manifest.json index b6804ff76..f70fe77d2 100644 --- a/ECSSamples/Packages/manifest.json +++ b/ECSSamples/Packages/manifest.json @@ -1,9 +1,17 @@ { "dependencies": { - "com.unity.rendering.hybrid": "0.1.1-preview", - "com.unity.package-manager-ui": "2.1.2", + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.ext.nunit": "1.0.0", + "com.unity.ide.rider": "1.1.0", + "com.unity.ide.vscode": "1.1.0", + "com.unity.package-manager-ui": "2.2.0", "com.unity.performance.profile-analyzer": "0.4.0-preview.5", + "com.unity.rendering.hybrid": "0.1.1-preview", + "com.unity.test-framework": "1.0.13", + "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", diff --git a/ECSSamples/ProjectSettings/ProjectVersion.txt b/ECSSamples/ProjectSettings/ProjectVersion.txt index d4db6f806..dbb16041b 100755 --- a/ECSSamples/ProjectSettings/ProjectVersion.txt +++ b/ECSSamples/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.1.0f1 -m_EditorVersionWithRevision: 2019.1.0f1 (5c52223b18d4) +m_EditorVersion: 2019.2.4f1 +m_EditorVersionWithRevision: 2019.2.4f1 (c63b2af89a85) From 234ee2a8e9f45fea18d205a0e49aee9a3ee5464d Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 11:33:31 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=EC=98=A4=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs index bea46edb4..9fdc2ecc2 100644 --- a/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs +++ b/ECSSamples/Assets/HelloCube/1. ForEach/ScaleSpeedSystem_ForEach.cs @@ -9,7 +9,7 @@ public class ScaleSpeedSystem_ForEach : ComponentSystem { protected override void OnUpdate() { - // EEntities.ForEach는 기본 스레드에서 각 ComponentData 세트를 처리합니다. 권장하지 않습니다 + // Entities.ForEach는 기본 스레드에서 각 ComponentData 세트를 처리합니다. 권장하지 않습니다 // 최상의 성능을위한 방법. 그러나 여기서는 더 명확한 분리를 보여주기 위해 여기에서 시작합니다. // ComponentSystem 업데이트 (logic)와 ComponentData (데이터) 간. // 개별 ComponentData에는 업데이트 로직이 없습니다. From f60ecfb6ff552d811b3720a0cd7a9443a4cb7563 Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 12:17:19 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=BC=20=EC=97=85=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1c. ForEachWithEntityChanges.meta | 8 + .../1c. ForEachWithEntityChanges/Cube.prefab | 94 +++++++ .../Cube.prefab.meta | 7 + .../1c. ForEachWithEntityChanges/CubeMat.mat | 77 ++++++ .../CubeMat.mat.meta | 8 + .../ForEachWithEntityChanges.unity | 251 ++++++++++++++++++ .../ForEachWithEntityChanges.unity.meta | 7 + .../1c. ForEachWithEntityChanges/README.md | 23 ++ .../README.md.meta | 7 + .../ScaleSystem_ForEachWithEntityChanges.cs | 42 +++ ...aleSystem_ForEachWithEntityChanges.cs.meta | 11 + .../ScaleUp_ForEachWithEntityChanges.cs | 13 + .../ScaleUp_ForEachWithEntityChanges.cs.meta | 11 + .../ScalingCube_ForEachWithEntityChanges.cs | 14 + ...alingCube_ForEachWithEntityChanges.cs.meta | 11 + .../Spawner_ForEachWithEntityChanges.cs | 37 +++ .../Spawner_ForEachWithEntityChanges.cs.meta | 11 + 17 files changed, 632 insertions(+) create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs create mode 100644 ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs.meta diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges.meta new file mode 100644 index 000000000..e0b9044de --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ec554c8f735775f47b268cdf48fa5123 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab new file mode 100644 index 000000000..e06ecdc3d --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab @@ -0,0 +1,94 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6569687701493165383 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7115010737409291896} + - component: {fileID: 2488643566923045792} + - component: {fileID: 969718961144326305} + - component: {fileID: 798989487309328685} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7115010737409291896 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6569687701493165383} + 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: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &2488643566923045792 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6569687701493165383} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &969718961144326305 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6569687701493165383} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 5189b50d95253084b86e54a6ade65490, type: 2} + 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 +--- !u!65 &798989487309328685 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6569687701493165383} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab.meta new file mode 100644 index 000000000..4d39b6ccc --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Cube.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e14d19916d98eff428ddb245e6b78976 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat new file mode 100644 index 000000000..d99a9d0cc --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CubeMat + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + m_LightmapFlags: 4 + m_EnableInstancingVariants: 1 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 1 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat.meta new file mode 100644 index 000000000..adf9b0f07 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/CubeMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5189b50d95253084b86e54a6ade65490 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity new file mode 100644 index 000000000..a828c5069 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity @@ -0,0 +1,251 @@ +%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: 1 + m_FogColor: {r: 0, g: 0, b: 0, a: 1} + m_FogMode: 3 + m_FogDensity: 0.2 + m_LinearFogStart: 0 + m_LinearFogEnd: 10 + m_AmbientSkyColor: {r: 1, g: 1, b: 1, 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: 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.1273174, g: 0.13414761, b: 0.12107885, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + 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: 10 + m_AtlasSize: 512 + 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: 256 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + 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_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !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 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &534669902 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 534669905} + - component: {fileID: 534669904} + - component: {fileID: 534669903} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &534669903 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_Enabled: 1 +--- !u!20 &534669904 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + 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 &534669905 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_LocalRotation: {x: 0.3066503, y: -0, z: -0, w: 0.9518223} + m_LocalPosition: {x: 0, y: 7.4, z: -9.03} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 35.715, y: 0, z: 0} +--- !u!1 &1947066106 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1947066108} + - component: {fileID: 1947066107} + m_Layer: 0 + m_Name: Spawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1947066107 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1947066106} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 21298e972f707cf429de451cbbd7a5e7, type: 3} + m_Name: + m_EditorClassIdentifier: + Prefab: {fileID: 6569687701493165383, guid: e14d19916d98eff428ddb245e6b78976, type: 3} + CountX: 10 + CountY: 10 +--- !u!4 &1947066108 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1947066106} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.5216708, y: 0.8254516, z: 0.7600517} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity.meta new file mode 100644 index 000000000..0a479ce21 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ForEachWithEntityChanges.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 60253ebc745e0e4478c801c52fd707e6 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md new file mode 100644 index 000000000..b7d265072 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md @@ -0,0 +1,23 @@ +WORK IN PROGRESS! + +this sample is going to be merged into ForEach + +# HelloCube_1b_ForEachWithEntityChanges + +This sample demonstrates a simple ECS System that uses queries to select the correct set of entities to update. It then modifies these entities inside of the ForEach lambda function. + +The example defines two tag components, named MovingCube_ForEachWithEntityChanges and MoveUp_ForEachWithEntityChanges. One query in the system selects all entities that have both a MoveUp_ForEachWithEntityChanges component and a Translation component. The ForEach lambda function associated with this query moves each selected entity upwards until it reaches a certain height. At that point, the function removes the MoveUp_ForEachWithEntityChanges component so the next time the system updates, the entity will not be selected and thus it will not be moved upwards any farther. + +A second query selects all entities that have a Translation component, but do not have a MoveUp_ForEachWithEntityChanges component. The ForEach function associated with the second query moves the entity down to its starting location and adds a new MoveUp_ForEachWithEntityChanges component. Since the entity has a MoveUp_ForEachWithEntityChanges component once again, the next time the system updates, the entity is moved upward by the first ForEach function and skipped by the second query. + +The MovingCube_ForEachWithEntityChanges is a tag component used to ensure that the system only works on components marked for this sample. Both queries in the sample require a MovingCube_ForEachWithEntityChanges component. + +## What does it show? + +This sample demonstrates a simple ECS System that uses queries to select a set of entities to move upwards. When they reach a certain height, the system removes a component and uses another query to respawn them at a lower height. It also demonstrates the use of "tag" components to provide a means of selecting specific sets of entites with marker components to be processed. Finally, this sample demonstrates how entities can be modified inside of a ForEach lambda function. + +## Component Systems and Entities.ForEach + +MovementSystem_ForEachWithEntityChanges is a ComponentSystem and uses an Entities.ForEach lambda function to iterate through the Entities. This example uses the WithAll and WithNone constraints to select specific sets of entities to work on. + +Note: Component Systems using Entities.ForEach run on the main thread. To take advantage of multiple cores, you can use a JobComponentSystem (as shown in other HelloCube examples). This also allows for changes to entities inside of the ForEach lambda function. diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md.meta new file mode 100644 index 000000000..163d7acaf --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4c63af9b5b0a6f04592005fc4554c12c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs new file mode 100644 index 000000000..b5217e087 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs @@ -0,0 +1,42 @@ +using Unity.Entities; +using Unity.Mathematics; +using Unity.Transforms; +using UnityEngine; + +namespace Samples.HelloCube_1c +{ + // 이 시스템은 장면의 모든 엔티티를 NonUniformScale 컴포넌트로 업데이트합니다. + // ScaleUp 컴포넌트가 있는지 여부에 따라 엔티티를 다르게 처리합니다. + public class ScaleSystem_ForEachWithEntityChanges : ComponentSystem + { + protected override void OnUpdate() + { + // ScaleUp 컴포넌트가 있으면 시스템은 NonUniformScale 컴포넌트를 업데이트하여 엔터티의 크기를 키웁니다. + // 엔티티가 미리 정해진 크기에 도달하면이 함수는 ScaleUp 컴포넌트를 제거합니다. + Entities.WithAllReadOnly().ForEach( + (Entity id, ref NonUniformScale uniformScale) => + { + var deltaTime = Time.deltaTime; + uniformScale = new NonUniformScale() + { + Value = new float3(uniformScale.Value.x + deltaTime, uniformScale.Value.y + deltaTime, uniformScale.Value.z + deltaTime) + }; + + if (uniformScale.Value.x > 5.0f && uniformScale.Value.y > 5.0f && uniformScale.Value.z > 5.0f) + EntityManager.RemoveComponent(id); + } + ); + + // 엔터티에 ScaleUp 컴포넌트가 없지만 NonUniformScale 컴포넌트가 있는 경우 + // 그런 다음 시스템은 엔티티를 기본 크기로 되돌리고 ScaleUp 컴포넌트를 추가합니다. + Entities.WithAllReadOnly().WithNone().ForEach( + (Entity id, ref NonUniformScale uniformScale) => + { + uniformScale.Value = new float3(1.0f, 1.0f, 1.0f); + + EntityManager.AddComponentData(id, new ScaleUp_ForEachWithEntityChanges()); + } + ); + } + } +} diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs.meta new file mode 100644 index 000000000..9176b14db --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleSystem_ForEachWithEntityChanges.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0926d38f0f79f4c4bb98e41d3c4a363a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs new file mode 100644 index 000000000..4b9886c62 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs @@ -0,0 +1,13 @@ +using System; +using Unity.Entities; + +namespace Samples.HelloCube_1c +{ + // Serializable attribute is for editor support. + [Serializable] + public struct ScaleUp_ForEachWithEntityChanges : IComponentData + { + // ScaleUp은 "태그"구성 요소이며 데이터를 포함하지 않습니다. 태그 구성 요소는 시스템이 처리해야하는 엔티티를 표시하는 데 사용될 수 있습니다. + } +} + diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs.meta new file mode 100644 index 000000000..4aa62c273 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScaleUp_ForEachWithEntityChanges.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2fc2a59223d25334a92b6737dc62de49 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs new file mode 100644 index 000000000..6eb823eea --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs @@ -0,0 +1,14 @@ +using System; +using Unity.Entities; + +namespace Samples.HelloCube_1c +{ + // Serializable attribute is for editor support. + [Serializable] + public struct ScalingCube_ForEachWithEntityChanges : IComponentData + { + // ScalingCube_ForEachWithEntityChanges는 "태그"구성 요소이며 데이터를 포함하지 않습니다. + // 태그 구성 요소는 시스템이 처리해야하는 엔티티를 표시하는 데 사용될 수 있습니다. + } +} + diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs.meta new file mode 100644 index 000000000..b1c2cff7a --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/ScalingCube_ForEachWithEntityChanges.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 887066754cc79a44389d2a5bb2b6007c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs new file mode 100644 index 000000000..9dc049ccf --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs @@ -0,0 +1,37 @@ +using Unity.Entities; +using Unity.Mathematics; +using Unity.Transforms; +using UnityEngine; + +namespace Samples.HelloCube_1c +{ + public class Spawner_ForEachWithEntityChanges : MonoBehaviour + { + public GameObject Prefab; + public int CountX = 100; + public int CountY = 100; + + void Start() + { + // 게임 오브젝트 계층에서 엔티티 프리 팹을 한 번 생성 + var prefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(Prefab, World.Active); + var entityManager = World.Active.EntityManager; + + for (int x = 0; x < CountX; x++) + { + for (int y = 0; y < CountX; y++) + { + // 이미 변환 된 엔타티 프리팹에서 여러 엔티티를 효율적으로 인스턴스화 + var instance = entityManager.Instantiate(prefab); + + // 노이즈가있는 그리드에 인스턴스화 된 엔터티를 배치합니다 + var position = transform.TransformPoint(new float3(x - CountX / 2, noise.cnoise(new float2(x, y) * 0.21F) * 10, y - CountY / 2)); + entityManager.SetComponentData(instance, new Translation() {Value = position}); + entityManager.AddComponentData(instance, new NonUniformScale {Value = new float3(1.0f, 1.0f, 1.0f)}); + entityManager.AddComponentData(instance, new ScaleUp_ForEachWithEntityChanges()); + entityManager.AddComponentData(instance, new ScalingCube_ForEachWithEntityChanges()); + } + } + } + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs.meta b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs.meta new file mode 100644 index 000000000..c46f01d5c --- /dev/null +++ b/ECSSamples/Assets/HelloCube/1c. ForEachWithEntityChanges/Spawner_ForEachWithEntityChanges.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 21298e972f707cf429de451cbbd7a5e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 760bf882e174e0f5b5511b1c4bd1310953edf577 Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 14:23:34 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=BC=20=EC=97=85=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2. IJobForEach/IJobForEach.unity | 20 +++++++++- .../ScaleSpeedAuthoring_IJobForEach.cs | 21 ++++++++++ .../ScaleSpeedAuthoring_IJobForEach.cs.meta | 11 ++++++ .../ScaleSpeedSystem_IJobForEach.cs | 39 +++++++++++++++++++ .../ScaleSpeedSystem_IJobForEach.cs.meta | 11 ++++++ .../2. IJobForEach/ScaleSpeed_IJobForEach.cs | 8 ++++ .../ScaleSpeed_IJobForEach.cs.meta | 11 ++++++ 7 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs create mode 100644 ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs create mode 100644 ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs create mode 100644 ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs.meta diff --git a/ECSSamples/Assets/HelloCube/2. IJobForEach/IJobForEach.unity b/ECSSamples/Assets/HelloCube/2. IJobForEach/IJobForEach.unity index 0b95aea58..793935107 100644 --- a/ECSSamples/Assets/HelloCube/2. IJobForEach/IJobForEach.unity +++ b/ECSSamples/Assets/HelloCube/2. IJobForEach/IJobForEach.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 170076734} - m_IndirectSpecularColor: {r: 0.18028374, g: 0.22571413, b: 0.3069228, a: 1} + m_IndirectSpecularColor: {r: 0.18028334, g: 0.2257134, b: 0.30692226, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -94,8 +94,8 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -177,6 +177,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 0 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -384,6 +385,7 @@ GameObject: - component: {fileID: 867917758} - component: {fileID: 867917757} - component: {fileID: 867917756} + - component: {fileID: 867917761} m_Layer: 0 m_Name: RotatingCube m_TagString: Untagged @@ -442,6 +444,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 0 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -477,3 +480,16 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &867917761 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 867917755} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5b24ebbee0226b34c984dd61146dbe61, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 1 diff --git a/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs new file mode 100644 index 000000000..2c688ffc2 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.Entities; +using Unity.Mathematics; +using Unity.Transforms; +using UnityEngine; + +[RequiresEntityConversion] +public class ScaleSpeedAuthoring_IJobForEach : MonoBehaviour, IConvertGameObjectToEntity +{ + public float ScalePerSecond = 1; + + // MonoBehaviour 데이터는 엔티티에서 ComponentData로 변환됩니다. + public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) + { + var data = new ScaleSpeed_IJobForEach {ScalePerSecond = ScalePerSecond}; + + dstManager.AddComponentData(entity, new NonUniformScale { Value = new float3(1.0f, 1.0f, 1.0f)}); + dstManager.AddComponentData(entity, data); + } +} diff --git a/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs.meta b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs.meta new file mode 100644 index 000000000..7ae3f3031 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedAuthoring_IJobForEach.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5b24ebbee0226b34c984dd61146dbe61 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs new file mode 100644 index 000000000..faed63bcf --- /dev/null +++ b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs @@ -0,0 +1,39 @@ +using Unity.Collections; +using Unity.Entities; +using Unity.Jobs; +using Unity.Transforms; +using UnityEngine; + +// 이 시스템은 장면의 모든 엔티티를 ScaleSpeedSystem_IJobForEach 및 NonUniformScale 컴포넌트로 업데이트합니다. + +public class ScaleSpeedSystem_IJobForEach : JobComponentSystem +{ + // 버스트를 사용하여 작업을 컴파일하려면 [BurstCompile] 속성을 사용하십시오. 상당한 속도 향상을 볼 수 있으므로 시도하십시오! + struct ScaleSpeedJob : IJobForEach + { + public float DeltaTime; + + // [ReadOnly] 속성은이 작업이 sclSpeedIJobForEach 쓰지 않을 것이라고 작업 스케줄러에 알려줍니다. + public void Execute(ref NonUniformScale uniformScale, [ReadOnly] ref ScaleSpeed_IJobForEach sclSpeedIJobForEach) + { + // ScaleSpeed_IJobForEach 제공 한 속도로 크기를 증가시킵니다. + var scale = uniformScale.Value; + scale.x += sclSpeedIJobForEach.ScalePerSecond * DeltaTime; + scale.y += sclSpeedIJobForEach.ScalePerSecond * DeltaTime; + scale.z += sclSpeedIJobForEach.ScalePerSecond * DeltaTime; + + uniformScale.Value = scale; + } + } + + // OnUpdate는 메인 스레드에서 실행됩니다. + protected override JobHandle OnUpdate(JobHandle inputDependencies) + { + var job = new ScaleSpeedJob + { + DeltaTime = Time.deltaTime + }; + + return job.Schedule(this, inputDependencies); + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs.meta b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs.meta new file mode 100644 index 000000000..38338d3a6 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeedSystem_IJobForEach.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d9ab70ae42bfbde4e9f9492268d5d878 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs new file mode 100644 index 000000000..cbbe43ad4 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs @@ -0,0 +1,8 @@ +using System; +using Unity.Entities; + +[Serializable] +public struct ScaleSpeed_IJobForEach : IComponentData +{ + public float ScalePerSecond; +} diff --git a/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs.meta b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs.meta new file mode 100644 index 000000000..51cd0dbff --- /dev/null +++ b/ECSSamples/Assets/HelloCube/2. IJobForEach/ScaleSpeed_IJobForEach.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0e7227d72481eac43a214a212375fc22 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 3f95bcdbab0aa54e02beea1414ee819edd9a138e Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 15:10:37 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=BC=20=EC=97=85=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=953=E3=85=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HelloCube/3. IJobChunk/IJobChunk.unity | 20 +++++- .../ScaleSpeedAuthoring_IJobChunk.cs | 17 +++++ .../ScaleSpeedAuthoring_IJobChunk.cs.meta | 11 ++++ .../ScaleSpeedSystem_IJobChunk.cs | 62 +++++++++++++++++++ .../ScaleSpeedSystem_IJobChunk.cs.meta | 11 ++++ .../3. IJobChunk/ScaleSpeed_IJobChunk.cs | 8 +++ .../3. IJobChunk/ScaleSpeed_IJobChunk.cs.meta | 11 ++++ 7 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs create mode 100644 ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs create mode 100644 ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs create mode 100644 ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs.meta diff --git a/ECSSamples/Assets/HelloCube/3. IJobChunk/IJobChunk.unity b/ECSSamples/Assets/HelloCube/3. IJobChunk/IJobChunk.unity index 1c796e4cf..0cf6c369a 100644 --- a/ECSSamples/Assets/HelloCube/3. IJobChunk/IJobChunk.unity +++ b/ECSSamples/Assets/HelloCube/3. IJobChunk/IJobChunk.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 170076734} - m_IndirectSpecularColor: {r: 0.18028374, g: 0.22571413, b: 0.3069228, a: 1} + m_IndirectSpecularColor: {r: 0.18028334, g: 0.2257134, b: 0.30692226, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -94,8 +94,8 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -307,6 +307,7 @@ GameObject: - component: {fileID: 1339553380} - component: {fileID: 1339553379} - component: {fileID: 1339553378} + - component: {fileID: 1339553383} m_Layer: 0 m_Name: RotatingCube m_TagString: Untagged @@ -365,6 +366,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 0 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -400,6 +402,19 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1339553383 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1339553377} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c51f367ff778bf74292adef652f1c526, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 1 --- !u!1 &1355816237 GameObject: m_ObjectHideFlags: 0 @@ -457,6 +472,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 0 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 diff --git a/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs new file mode 100644 index 000000000..061cb3736 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs @@ -0,0 +1,17 @@ +using Unity.Entities; +using Unity.Mathematics; +using Unity.Transforms; +using UnityEngine; + +[RequiresEntityConversion] +public class ScaleSpeedAuthoring_IJobChunk : MonoBehaviour, IConvertGameObjectToEntity +{ + public float ScalePerSecond = 1; + + public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) + { + var data = new ScaleSpeed_IJobChunk() {ScalePerSecond = ScalePerSecond}; + dstManager.AddComponentData(entity, new NonUniformScale { Value = new float3(1.0f, 1.0f, 1.0f)}); + dstManager.AddComponentData(entity, data); + } +} diff --git a/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs.meta b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs.meta new file mode 100644 index 000000000..c736a2496 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedAuthoring_IJobChunk.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c51f367ff778bf74292adef652f1c526 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs new file mode 100644 index 000000000..26dc77fd5 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.Burst; +using Unity.Collections; +using Unity.Entities; +using Unity.Jobs; +using Unity.Mathematics; +using Unity.Transforms; +using UnityEngine; + +public class ScaleSpeedSystem_IJobChunk : JobComponentSystem +{ + EntityQuery m_Group; + + protected override void OnCreate() + { + // 특정 쿼리를 기반으로 한 ComponentData 세트에 대한 캐시 된 액세스 + m_Group = GetEntityQuery(typeof(NonUniformScale), ComponentType.ReadOnly()); + } + + [BurstCompile] + struct ScaleSpeedJob : IJobChunk + { + public float DeltaTime; + public ArchetypeChunkComponentType ScaleType; + [ReadOnly] public ArchetypeChunkComponentType ScaleSpeedType; + + public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) + { + var chunkScales = chunk.GetNativeArray(ScaleType); + var chunkScalesSpeeds = chunk.GetNativeArray(ScaleSpeedType); + for (int i = 0; i < chunk.Count; i++) + { + var scale = chunkScales[i]; + var scaleSpeed = chunkScalesSpeeds[i]; + + // ScaleSpeed_IJobChunk가 제공 한 속도로 크기를 증가시킵니다. + chunkScales[i] = new NonUniformScale + { + Value = new float3(scale.Value.x + scale.Value.x * scaleSpeed.ScalePerSecond * DeltaTime, + scale.Value.y + scale.Value.y * scaleSpeed.ScalePerSecond * DeltaTime, + scale.Value.z + scale.Value.z * scaleSpeed.ScalePerSecond * DeltaTime) + }; + } + } + } + + protected override JobHandle OnUpdate(JobHandle inputDependencies) + { + var scaleType = GetArchetypeChunkComponentType(); + var scaleSpeedType = GetArchetypeChunkComponentType(true); + + var job = new ScaleSpeedJob() + { + ScaleType = scaleType, + ScaleSpeedType = scaleSpeedType, + DeltaTime = Time.deltaTime + }; + + return job.Schedule(m_Group, inputDependencies); + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs.meta b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs.meta new file mode 100644 index 000000000..de51a7363 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeedSystem_IJobChunk.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b74b59c2ec14ba46b99db9eb6f558ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs new file mode 100644 index 000000000..7f6f35474 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs @@ -0,0 +1,8 @@ +using System; +using Unity.Entities; + +[Serializable] +public struct ScaleSpeed_IJobChunk : IComponentData +{ + public float ScalePerSecond; +} diff --git a/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs.meta b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs.meta new file mode 100644 index 000000000..4de3831cd --- /dev/null +++ b/ECSSamples/Assets/HelloCube/3. IJobChunk/ScaleSpeed_IJobChunk.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a04e53abf5a5dda408c6be57c8c80694 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 59d741874500b5400c58e842afa3e865c78565d7 Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 15:28:37 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=BC=20=EC=97=85=20S?= =?UTF-8?q?ubScene=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HelloCube/4. SubScene/SubScene.unity | 53 ++- .../4. SubScene/SubScenes/ScalingCube.unity | 307 ++++++++++++++++++ .../SubScenes/ScalingCube.unity.meta | 7 + 3 files changed, 364 insertions(+), 3 deletions(-) create mode 100644 ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity create mode 100644 ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity.meta diff --git a/ECSSamples/Assets/HelloCube/4. SubScene/SubScene.unity b/ECSSamples/Assets/HelloCube/4. SubScene/SubScene.unity index 4afb969f2..4035727d4 100644 --- a/ECSSamples/Assets/HelloCube/4. SubScene/SubScene.unity +++ b/ECSSamples/Assets/HelloCube/4. SubScene/SubScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 170076734} - m_IndirectSpecularColor: {r: 0.18028374, g: 0.22571413, b: 0.3069228, a: 1} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -94,8 +94,8 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -294,6 +294,53 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &548788737 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 548788739} + - component: {fileID: 548788738} + m_Layer: 0 + m_Name: ScalingCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &548788738 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 548788737} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 45a335734b1572644a6a5d09d87adc65, type: 3} + m_Name: + m_EditorClassIdentifier: + _SceneAsset: {fileID: 102900000, guid: 0e3140c1c561d604ba9828ddb61aa1b8, type: 3} + _HierarchyColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + AutoLoadScene: 1 + m_SubSceneHeader: {fileID: 11400000, guid: 86c2813b1c5dc944080fa4eacd13ca13, type: 2} +--- !u!4 &548788739 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 548788737} + 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 &1968276409 GameObject: m_ObjectHideFlags: 0 @@ -326,7 +373,7 @@ MonoBehaviour: _SceneAsset: {fileID: 102900000, guid: eee6dacb0839c4d348d7a155127cebe7, type: 3} _HierarchyColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} AutoLoadScene: 1 - m_SubSceneHeader: {fileID: 11400000, guid: bd61d4d546fef4384b0348f8e4dc137f, type: 2} + m_SubSceneHeader: {fileID: 11400000, guid: d63606f764ee8f24ea87d4ebeda69c9b, type: 2} --- !u!4 &1968276411 Transform: m_ObjectHideFlags: 0 diff --git a/ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity b/ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity new file mode 100644 index 000000000..4d78d18e0 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity @@ -0,0 +1,307 @@ +%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, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + 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_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !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 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!114 &916393094603800960 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393094603801082} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5b24ebbee0226b34c984dd61146dbe61, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 1 +--- !u!4 &916393094603800961 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393094603801082} + 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: + - {fileID: 916393095369715791} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &916393094603801082 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 916393094603800961} + - component: {fileID: 916393094603801086} + - component: {fileID: 916393094603801087} + - component: {fileID: 916393094603801085} + - component: {fileID: 916393094603800960} + m_Layer: 0 + m_Name: ScalingCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &916393094603801085 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393094603801082} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea7d7495833204790ba1d3a8755397f8, type: 3} + m_Name: + m_EditorClassIdentifier: + ConversionMode: 0 +--- !u!33 &916393094603801086 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393094603801082} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &916393094603801087 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393094603801082} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!1 &916393095369715788 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 916393095369715791} + - component: {fileID: 916393095369715793} + - component: {fileID: 916393095369715790} + m_Layer: 0 + m_Name: ChildCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &916393095369715790 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393095369715788} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!4 &916393095369715791 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393095369715788} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.54, z: 0} + m_LocalScale: {x: 0.52272, y: 0.52272, z: 0.52272} + m_Children: [] + m_Father: {fileID: 916393094603800961} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &916393095369715793 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 916393095369715788} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} diff --git a/ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity.meta b/ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity.meta new file mode 100644 index 000000000..2376eb605 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/4. SubScene/SubScenes/ScalingCube.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0e3140c1c561d604ba9828ddb61aa1b8 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From a783b698ee3c76b7deedcde3f95407be57b09f32 Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 16:10:57 +0900 Subject: [PATCH 7/8] =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=BC=20=EC=8A=A4?= =?UTF-8?q?=ED=8C=90=20=EB=AA=A8=EB=85=B8=EB=B9=84=ED=97=A4=EB=B9=84?= =?UTF-8?q?=EC=96=B4=20=EB=90=98=EA=B2=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HelloCube/5b. SpawnFromMonoBehaviour.meta | 8 + .../5b. SpawnFromMonoBehaviour/Cube.prefab | 173 +++++++++ .../Cube.prefab.meta | 7 + .../SpawnFromMonoBehaviour.unity | 342 ++++++++++++++++++ .../SpawnFromMonoBehaviour.unity.meta | 7 + .../Spawner_FromMonoBehaviour.cs | 35 ++ .../Spawner_FromMonoBehaviour.cs.meta | 11 + 7 files changed, 583 insertions(+) create mode 100644 ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour.meta create mode 100644 ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab create mode 100644 ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab.meta create mode 100644 ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity create mode 100644 ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity.meta create mode 100644 ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs create mode 100644 ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs.meta diff --git a/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour.meta b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour.meta new file mode 100644 index 000000000..f20bef7ae --- /dev/null +++ b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c09d3e9ad61566e4eb5728643d3644d5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab new file mode 100644 index 000000000..44f142d2a --- /dev/null +++ b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab @@ -0,0 +1,173 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5047497807776246613 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4528550977985421767} + - component: {fileID: 2467235709478337695} + - component: {fileID: 3717396922655459554} + m_Layer: 0 + m_Name: child + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4528550977985421767 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5047497807776246613} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.56, z: 0} + m_LocalScale: {x: 0.47, y: 0.47, z: 0.47} + m_Children: [] + m_Father: {fileID: 626558547032780275} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &2467235709478337695 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5047497807776246613} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &3717396922655459554 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5047497807776246613} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!1 &7756226592167583472 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 626558547032780275} + - component: {fileID: 3019978149434536146} + - component: {fileID: 1657421783300073011} + - component: {fileID: -4488005702167584892} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &626558547032780275 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + 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: + - {fileID: 4528550977985421767} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &3019978149434536146 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1657421783300073011 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!114 &-4488005702167584892 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5b24ebbee0226b34c984dd61146dbe61, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 0.1 diff --git a/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab.meta b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab.meta new file mode 100644 index 000000000..e7ea3361d --- /dev/null +++ b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Cube.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6774507d05089e0478db3a168387bd25 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity new file mode 100644 index 000000000..2bcbdbbb2 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity @@ -0,0 +1,342 @@ +%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: 170076734} + m_IndirectSpecularColor: {r: 0.18028334, g: 0.2257134, b: 0.30692226, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + 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: 10 + m_AtlasSize: 512 + 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: 256 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + 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_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !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 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &170076733 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 170076735} + - component: {fileID: 170076734} + 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 &170076734 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 170076733} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.802082 + 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: 1 + 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_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &170076735 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 170076733} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &236904947 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 236904949} + - component: {fileID: 236904948} + m_Layer: 0 + m_Name: Spawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &236904948 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 236904947} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4ead3bb9a731d274e94b4ad9b19ae29a, type: 3} + m_Name: + m_EditorClassIdentifier: + Prefab: {fileID: 7756226592167583472, guid: 6774507d05089e0478db3a168387bd25, type: 3} + CountX: 10 + CountY: 10 +--- !u!4 &236904949 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 236904947} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.5216708, y: 0.8254516, z: 0.7600517} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &534669902 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 534669905} + - component: {fileID: 534669904} + - component: {fileID: 534669903} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &534669903 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_Enabled: 1 +--- !u!20 &534669904 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + 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_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + 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 &534669905 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_LocalRotation: {x: 0.32103908, y: 0.050544277, z: -0.017160676, w: 0.9455606} + m_LocalPosition: {x: 5.13, y: 8.7, z: -5.99} + 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} diff --git a/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity.meta b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity.meta new file mode 100644 index 000000000..12799d499 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/SpawnFromMonoBehaviour.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6b9ddbf22cc9e9e4d8a0dbe0e42a2d7b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs new file mode 100644 index 000000000..da05df2a3 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs @@ -0,0 +1,35 @@ +using Unity.Entities; +using Unity.Mathematics; +using Unity.Transforms; +using UnityEngine; + +namespace Samples.HelloCube_5b +{ +// ReSharper disable once InconsistentNaming + public class Spawner_FromMonoBehaviour : MonoBehaviour + { + public GameObject Prefab; + public int CountX = 100; + public int CountY = 100; + + void Start() + { + // Create entity prefab from the game object hierarchy once + var prefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(Prefab, World.Active); + var entityManager = World.Active.EntityManager; + + for (var x = 0; x < CountX; x++) + { + for (var y = 0; y < CountY; y++) + { + // Efficiently instantiate a bunch of entities from the already converted entity prefab + var instance = entityManager.Instantiate(prefab); + + // Place the instantiated entity in a grid with some noise + var position = transform.TransformPoint(new float3(x * 1.3F, noise.cnoise(new float2(x, y) * 0.21F) * 2, y * 1.3F)); + entityManager.SetComponentData(instance, new Translation {Value = position}); + } + } + } + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs.meta b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs.meta new file mode 100644 index 000000000..cefd8d2bf --- /dev/null +++ b/ECSSamples/Assets/HelloCube/5b. SpawnFromMonoBehaviour/Spawner_FromMonoBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4ead3bb9a731d274e94b4ad9b19ae29a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 51d496918324103b4541c220924a03ca402fd0f0 Mon Sep 17 00:00:00 2001 From: kaya Date: Tue, 15 Oct 2019 18:00:54 +0900 Subject: [PATCH 8/8] =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=BC=20=EC=97=85=20?= =?UTF-8?q?=ED=81=90=EB=B8=8C=20=EC=8A=A4=ED=8C=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/HelloCube/6b. SpawnFromEntity.meta | 8 + .../HelloCube/6b. SpawnFromEntity/README.md | 28 ++ .../6b. SpawnFromEntity/README.md.meta | 7 + .../6b. SpawnFromEntity/ScalingCube.prefab | 173 +++++++++ .../ScalingCube.prefab.meta | 7 + .../6b. SpawnFromEntity/SpawnFromEntity.unity | 356 ++++++++++++++++++ .../SpawnFromEntity.unity.meta | 7 + .../SpawnerAuthoring_FromEntity.cs | 35 ++ .../SpawnerAuthoring_FromEntity.cs.meta | 11 + .../SpawnerSystem_FromEntity.cs | 74 ++++ .../SpawnerSystem_FromEntity.cs.meta | 11 + .../6b. SpawnFromEntity/Spawner_FromEntity.cs | 11 + .../Spawner_FromEntity.cs.meta | 3 + 13 files changed, 731 insertions(+) create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity.meta create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md.meta create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab.meta create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity.meta create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs.meta create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs create mode 100644 ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs.meta diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity.meta b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity.meta new file mode 100644 index 000000000..0d18afb83 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6a1c5ad3a3270924d9fabeab27d41143 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md new file mode 100644 index 000000000..b60a3cf0e --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md @@ -0,0 +1,28 @@ +# HelloCube: SpawnFromEntity + +This sample demonstrates a different way to spawn Entities and Components using a Prefab GameObject. Like the previous example, the scene spawns a "field" of the pairs of spinning cubes. + +## What does it show? + +There are two key differences to the way Entities were spawned in the previous example: + +1. In this example, the Prefab GameObject is converted to an Entity representation by the SpawnerAuthoring_FromEntity MonoBehaviour, in its IConvertGameObjectToEntity.Convert method. + +2. The example uses a JobSystem to spawn the Entities rather than a MonoBehaviour Start() method. + +## Spawning entities + +Component data can have references to other entities. In this case we have a reference to a entity prefab. Similar to GameObjects, when instantiating and destroying a prefab, the whole prefab is cloned or deleted as a group. + +This way you can write all of your runtime code using JobComponentSystem and ComponentData. + +The SpawnerSystem_FromEntity looks for any Spawner_FromEntity Component. +When it finds one, the System instantiates the prefabs in a grid and then destroys the spawner Entity (so that it only spawns a given set of Entities once). + +The SpawnerSystem_FromEntity uses a Job based on IJobForEachWithEntity, which is very similar to the IJobForEach Jobs demonstrated in earlier examples. The difference is that this type of Job provides the Entity object (and the Component array index) to your Execute() function. The Entity object is required so that the System can destroy the Spawner Entity once it has been processed. + +Another important concept that SpawnerSystem_FromEntity illustrates is the use of an EntityCommandBuffer and a EntityCommandBufferSystem. To prevent race conditions, you cannot make _structural changes_ inside a Job. Structural changes include anything that changes the structure of your data, such as creating/destroying Entities or adding/removing Components. To overcome this limitation, ECS provides the EntityCommandBuffer. + +Instead of performing structural changes directly, a Job can add a command to an EntityCommandBuffer to perform such changes on the main thread after the Job has finished. Command buffers allow you to perform any, potentially costly, calculations on a worker thread, while queuing up the actual insertions and deletions for later. + +The EndSimulationBarrier is a standard ECS System that provides an EntityCommandBuffer for any System to use. EndSimulationBarrier automatically executes any commands in this buffer when the System runs at the end of a frame. diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md.meta b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md.meta new file mode 100644 index 000000000..10e57cc14 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a9f30d34f63cb6547ac7159145d70468 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab new file mode 100644 index 000000000..ccf1b2351 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab @@ -0,0 +1,173 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5047497807776246613 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4528550977985421767} + - component: {fileID: 2467235709478337695} + - component: {fileID: 3717396922655459554} + m_Layer: 0 + m_Name: ChildCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4528550977985421767 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5047497807776246613} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.56, z: 0} + m_LocalScale: {x: 0.47, y: 0.47, z: 0.47} + m_Children: [] + m_Father: {fileID: 626558547032780275} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &2467235709478337695 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5047497807776246613} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &3717396922655459554 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5047497807776246613} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!1 &7756226592167583472 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 626558547032780275} + - component: {fileID: 3019978149434536146} + - component: {fileID: 1657421783300073011} + - component: {fileID: 7020941909767269221} + m_Layer: 0 + m_Name: ScalingCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &626558547032780275 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + 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: + - {fileID: 4528550977985421767} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &3019978149434536146 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1657421783300073011 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + 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: 32bf30f90a6a049be8fb2aca13ddebb6, type: 2} + 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 +--- !u!114 &7020941909767269221 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7756226592167583472} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5b24ebbee0226b34c984dd61146dbe61, type: 3} + m_Name: + m_EditorClassIdentifier: + ScalePerSecond: 1 diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab.meta b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab.meta new file mode 100644 index 000000000..bcc8f177a --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/ScalingCube.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c33f0d41c35b43a4b840eddbf1e2f53d +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity new file mode 100644 index 000000000..18e5c45f0 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity @@ -0,0 +1,356 @@ +%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: 170076734} + m_IndirectSpecularColor: {r: 0.18028334, g: 0.2257134, b: 0.30692226, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + 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: 10 + m_AtlasSize: 512 + 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: 256 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + 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_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !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 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &170076733 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 170076735} + - component: {fileID: 170076734} + 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 &170076734 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 170076733} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.802082 + 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: 1 + 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_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &170076735 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 170076733} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &236904947 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 236904949} + - component: {fileID: 236904950} + - component: {fileID: 236904948} + m_Layer: 0 + m_Name: Spawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &236904948 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 236904947} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cc67f13d50ac34831a5bf38845c77593, type: 3} + m_Name: + m_EditorClassIdentifier: + Prefab: {fileID: 7756226592167583472, guid: c33f0d41c35b43a4b840eddbf1e2f53d, type: 3} + CountX: 10 + CountY: 10 +--- !u!4 &236904949 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 236904947} + 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: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &236904950 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 236904947} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea7d7495833204790ba1d3a8755397f8, type: 3} + m_Name: + m_EditorClassIdentifier: + ConversionMode: 0 +--- !u!1 &534669902 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 534669905} + - component: {fileID: 534669904} + - component: {fileID: 534669903} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &534669903 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_Enabled: 1 +--- !u!20 &534669904 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + 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_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + 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 &534669905 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_LocalRotation: {x: 0.31154943, y: 0.23417723, z: -0.07952009, w: 0.9174827} + m_LocalPosition: {x: -0.36, y: 9.33, z: -5.9} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 37.512, y: 28.637001, z: 0} diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity.meta b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity.meta new file mode 100644 index 000000000..601fe4399 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnFromEntity.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c51e9f0b577211a41b358f61090a0e3d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs new file mode 100644 index 000000000..cb55611de --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using Unity.Entities; +using UnityEngine; + +namespace Samples.HelloCube_6b +{ + [RequiresEntityConversion] + public class SpawnerAuthoring_FromEntity : MonoBehaviour, IDeclareReferencedPrefabs, IConvertGameObjectToEntity + { + public GameObject Prefab; + public int CountX; + public int CountY; + + // 변환 시스템이 사전에 미리 알 수 있도록 참조 된 프리 팹을 선언해야합니다. + public void DeclareReferencedPrefabs(List referencedPrefabs) + { + referencedPrefabs.Add(Prefab); + } + + // 편집기 데이터 표현을 엔티티 최적 런타임 표현으로 변환 할 수 있습니다 + public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) + { + var spawnerData = new Spawner_FromEntity + { + // 참조된 프리 팹은 DeclareReferencedPrefabs로 인해 변환됩니다. + // 여기서는 게임 오브젝트를 해당 프리 팹에 대한 엔티티 참조에 매핑합니다. + Prefab = conversionSystem.GetPrimaryEntity(Prefab), + CountX = CountX, + CountY = CountY + }; + dstManager.AddComponentData(entity, spawnerData); + } + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs.meta b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs.meta new file mode 100644 index 000000000..79287285c --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65489dad738c29f4bb54e6a7c0d9cff2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs new file mode 100644 index 000000000..2b8e8b233 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs @@ -0,0 +1,74 @@ +using Unity.Collections; +using Unity.Entities; +using Unity.Jobs; +using Unity.Mathematics; +using Unity.Transforms; + +namespace Samples.HelloCube_6b +{ + // JobComponentSystems는 worker 스레드에서 실행될 수 있습니다. + // 그러나 엔터티 생성 및 제거는 race condition을 조건을 방지하기 위해 메인 스레드에서만 수행 할 수 있습니다. + // 시스템은 EntityCommandBuffer를 사용하여 작업 내에서 수행 할 수없는 작업을 연기합니다. + [UpdateInGroup(typeof(SimulationSystemGroup))] + public class SpawnerSystem_FromEntity : JobComponentSystem + { + // BeginInitializationEntityCommandBufferSystem은 명령 버퍼를 작성하는 데 사용됩니다. + // 그 장벽 시스템이 실행될 때. + // 인스턴스화 명령은 SpawnJob에 기록되지만 실제로 처리되지는 않습니다 (또는 "재생 됨"). + // 해당 EntityCommandBufferSystem이 업데이트 될 때까지 변환 시스템이 기회를 갖도록 + // 새로 생성 된 엔티티를 처음 렌더링하기 전에 SpawnerSystem_FromEntity에서 실행 + // BeginSimulationEntityCommandBufferSystem을 사용하여 해당 명령을 재생합니다. 이것은 한 프레임 지연을 소개합니다 + // 명령을 기록하고 엔티티를 인스턴스화하는 것 사이에서 실제로는 눈에 띄지 않습니다. + BeginInitializationEntityCommandBufferSystem m_EntityCommandBufferSystem; + + protected override void OnCreate() + { + // 필드에서 BeginInitializationEntityCommandBufferSystem을 캐시하므로 매 프레임마다 시스템을 작성할 필요가 없습니다. + m_EntityCommandBufferSystem = World.GetOrCreateSystem(); + } + + struct SpawnJob : IJobForEachWithEntity + { + public EntityCommandBuffer.Concurrent CommandBuffer; + + public void Execute(Entity entity, int index, [ReadOnly] ref Spawner_FromEntity spawnerFromEntity, + [ReadOnly] ref LocalToWorld location) + { + for (var x = 0; x < spawnerFromEntity.CountX; x++) + { + for (var y = 0; y < spawnerFromEntity.CountY; y++) + { + var instance = CommandBuffer.Instantiate(index, spawnerFromEntity.Prefab); + + // 노이즈가있는 그리드에 인스턴스를 배치하십시오 + var position = math.transform(location.Value, + new float3(x * 1.3F, noise.cnoise(new float2(x, y) * 0.21F) * 2, y * 1.3F)); + CommandBuffer.SetComponent(index, instance, new Translation {Value = position}); + } + } + + CommandBuffer.DestroyEntity(index, entity); + } + } + + protected override JobHandle OnUpdate(JobHandle inputDeps) + { + // 작업은 구조적 변경을 직접 수행하는 대신 EntityCommandBuffer에 명령을 추가하여 작업이 완료된 후 기본 스레드에서 이러한 변경을 수행 할 수 있습니다. + // 명령 버퍼를 사용하면 작업자 스레드에서 잠재적으로 비용이 많이 드는 계산을 수행하는 동시에 나중에 실제 삽입 및 삭제를 대기시킬 수 있습니다. + + // EntityCommandBuffer에 Instantiate 명령을 추가 할 작업을 예약하십시오. + var job = new SpawnJob + { + CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent() + }.Schedule(this, inputDeps); + + + // SpawnJob은 장벽 시스템이 실행될 때까지 동기화 지점없이 병렬로 실행됩니다. + // 장벽 시스템이 실행되면 SpawnJob을 완료 한 다음 명령을 재생합니다 (엔티티 생성 및 배치). + // 명령을 재생하기 전에 어떤 작업을 완료해야하는지 장벽 시스템에 알려야합니다. + m_EntityCommandBufferSystem.AddJobHandleForProducer(job); + + return job; + } + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs.meta b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs.meta new file mode 100644 index 000000000..e0648da6c --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/SpawnerSystem_FromEntity.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d052660787049864c9b2f120fb325703 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs new file mode 100644 index 000000000..6d398c751 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs @@ -0,0 +1,11 @@ +using Unity.Entities; + +namespace Samples.HelloCube_5b +{ + public struct Spawner_FromEntity : IComponentData + { + public int CountX; + public int CountY; + public Entity Prefab; + } +} \ No newline at end of file diff --git a/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs.meta b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs.meta new file mode 100644 index 000000000..2d3bbc0d8 --- /dev/null +++ b/ECSSamples/Assets/HelloCube/6b. SpawnFromEntity/Spawner_FromEntity.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 446eb7585004dab4b91f8e18d3c3bcb2 +timeCreated: 1550696345 \ No newline at end of file