diff --git a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleEventScene.unity b/Assets/FirstVillain/EventManager/Sample/Scenes/SampleEventScene.unity deleted file mode 100644 index bd629df..0000000 --- a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleEventScene.unity +++ /dev/null @@ -1,779 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 3 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 0 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 0 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 500 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 500 - 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_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 2 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - accuratePlacement: 0 - maxJobWorkers: 0 - preserveTilesOutsideBounds: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &462390051 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 462390055} - - component: {fileID: 462390054} - - component: {fileID: 462390053} - - component: {fileID: 462390052} - m_Layer: 5 - m_Name: Canvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &462390052 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 462390051} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &462390053 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 462390051} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} - m_Name: - m_EditorClassIdentifier: - m_UiScaleMode: 0 - m_ReferencePixelsPerUnit: 100 - m_ScaleFactor: 1 - m_ReferenceResolution: {x: 800, y: 600} - m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 - m_PhysicalUnit: 3 - m_FallbackScreenDPI: 96 - m_DefaultSpriteDPI: 96 - m_DynamicPixelsPerUnit: 1 - m_PresetInfoIsWorld: 0 ---- !u!223 &462390054 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 462390051} - m_Enabled: 1 - serializedVersion: 3 - m_RenderMode: 0 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingBucketNormalizedSize: 0 - m_AdditionalShaderChannelsFlag: 25 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!224 &462390055 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 462390051} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1764732231} - m_Father: {fileID: 0} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 0} ---- !u!1 &519420028 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 519420032} - - component: {fileID: 519420031} - - component: {fileID: 519420029} - 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 &519420029 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 519420028} - m_Enabled: 1 ---- !u!20 &519420031 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 519420028} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 2 - 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: 1 - 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: 0 - m_HDR: 1 - m_AllowMSAA: 0 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 0 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &519420032 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 519420028} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &782199217 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 782199220} - - component: {fileID: 782199219} - - component: {fileID: 782199218} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &782199218 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 782199217} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &782199219 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 782199217} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!4 &782199220 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 782199217} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1017676595 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1017676597} - - component: {fileID: 1017676596} - m_Layer: 0 - m_Name: TestPublisher - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1017676596 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1017676595} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cd5bc50399c22b949a535da2d35d8924, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &1017676597 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1017676595} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1374948899 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1374948901} - - component: {fileID: 1374948900} - m_Layer: 0 - m_Name: EventBus - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1374948900 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1374948899} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1156878957, guid: 8c96c7edf3aa4ce4cb713a09ad33e2cc, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &1374948901 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1374948899} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1532598558 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1532598560} - - component: {fileID: 1532598559} - m_Layer: 0 - m_Name: TestListener - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1532598559 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1532598558} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 29bceafc84dbcbc45a445598589a16a3, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &1532598560 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1532598558} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1764732230 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1764732231} - - component: {fileID: 1764732234} - - component: {fileID: 1764732233} - - component: {fileID: 1764732232} - m_Layer: 5 - m_Name: Button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1764732231 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1764732230} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1824310142} - m_Father: {fileID: 462390055} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -367.875, y: -104.24999} - m_SizeDelta: {x: 160, y: 30} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1764732232 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1764732230} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 1764732233} - m_OnClick: - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 1017676596} - m_TargetAssemblyTypeName: Publisher, Assembly-CSharp - m_MethodName: OnClickPublish - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 ---- !u!114 &1764732233 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1764732230} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!222 &1764732234 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1764732230} - m_CullTransparentMesh: 1 ---- !u!1 &1824310141 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1824310142} - - component: {fileID: 1824310144} - - component: {fileID: 1824310143} - m_Layer: 5 - m_Name: Text (TMP) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1824310142 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1824310141} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1764732231} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1824310143 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1824310141} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_text: Button - m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - m_fontSharedMaterials: [] - m_fontMaterial: {fileID: 0} - m_fontMaterials: [] - m_fontColor32: - serializedVersion: 2 - rgba: 4281479730 - m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_enableVertexGradient: 0 - m_colorMode: 3 - m_fontColorGradient: - topLeft: {r: 1, g: 1, b: 1, a: 1} - topRight: {r: 1, g: 1, b: 1, a: 1} - bottomLeft: {r: 1, g: 1, b: 1, a: 1} - bottomRight: {r: 1, g: 1, b: 1, a: 1} - m_fontColorGradientPreset: {fileID: 0} - m_spriteAsset: {fileID: 0} - m_tintAllSprites: 0 - m_StyleSheet: {fileID: 0} - m_TextStyleHashCode: -1183493901 - m_overrideHtmlColors: 0 - m_faceColor: - serializedVersion: 2 - rgba: 4294967295 - m_fontSize: 24 - m_fontSizeBase: 24 - m_fontWeight: 400 - m_enableAutoSizing: 0 - m_fontSizeMin: 0 - m_fontSizeMax: 0 - m_fontStyle: 0 - m_HorizontalAlignment: 2 - m_VerticalAlignment: 512 - m_textAlignment: 65535 - m_characterSpacing: 0 - m_wordSpacing: 0 - m_lineSpacing: 0 - m_lineSpacingMax: 0 - m_paragraphSpacing: 0 - m_charWidthMaxAdj: 0 - m_enableWordWrapping: 0 - m_wordWrappingRatios: 0.4 - m_overflowMode: 0 - m_linkedTextComponent: {fileID: 0} - parentLinkedComponent: {fileID: 0} - m_enableKerning: 0 - m_enableExtraPadding: 0 - checkPaddingRequired: 0 - m_isRichText: 1 - m_parseCtrlCharacters: 1 - m_isOrthographic: 1 - m_isCullingEnabled: 0 - m_horizontalMapping: 0 - m_verticalMapping: 0 - m_uvLineOffset: 0 - m_geometrySortingOrder: 0 - m_IsTextObjectScaleStatic: 0 - m_VertexBufferAutoSizeReduction: 0 - m_useMaxVisibleDescender: 1 - m_pageToDisplay: 1 - m_margin: {x: 0, y: 0, z: 0, w: 0} - m_isUsingLegacyAnimationComponent: 0 - m_isVolumetricText: 0 - m_hasFontAssetChanged: 0 - m_baseMaterial: {fileID: 0} - m_maskOffset: {x: 0, y: 0, z: 0, w: 0} ---- !u!222 &1824310144 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1824310141} - m_CullTransparentMesh: 1 diff --git a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleEventScene.unity.meta b/Assets/FirstVillain/EventManager/Sample/Scenes/SampleEventScene.unity.meta deleted file mode 100644 index c1e3c88..0000000 --- a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleEventScene.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 2cda990e2423bbf4892e6590ba056729 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleEvents.cs b/Assets/FirstVillain/EventManager/Sample/Scripts/SampleEvents.cs deleted file mode 100644 index 4f43fd4..0000000 --- a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleEvents.cs +++ /dev/null @@ -1,13 +0,0 @@ -using FirstVillain.EventBus; - -public class TestEvent : EventBase -{ - public int TestIntValue { get; private set; } - public string TestStringValue { get; private set; } - - public TestEvent(int intValue, string stringValue) - { - TestIntValue = intValue; - TestStringValue = stringValue; - } -} diff --git a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleListener.cs b/Assets/FirstVillain/EventManager/Sample/Scripts/SampleListener.cs deleted file mode 100644 index b2b3737..0000000 --- a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleListener.cs +++ /dev/null @@ -1,23 +0,0 @@ -using FirstVillain.EventBus; -using FirstVillain.ScrollView; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class SampleListener : MonoBehaviour -{ - void Start() - { - EventBus.Instance.Subscribe(OnTestEvent); - } - - private void OnDisable() - { - EventBus.Instance.Unsubscribe(OnTestEvent); - } - - private void OnTestEvent(TestEvent e) - { - Debug.Log($"Test event got message {e.TestIntValue} {e.TestStringValue}"); - } -} diff --git a/Assets/FirstVillain/EventManager/Sample/Scripts/SamplePublisher.cs b/Assets/FirstVillain/EventManager/Sample/Scripts/SamplePublisher.cs deleted file mode 100644 index a067ae7..0000000 --- a/Assets/FirstVillain/EventManager/Sample/Scripts/SamplePublisher.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FirstVillain.EventBus; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.SceneManagement; - -public class SamplePublisher : MonoBehaviour -{ - - public void OnClickPublish() - { - EventBus.Instance.Publish(new TestEvent(100, "times")); - - SceneManager.LoadScene("SampleNextScene"); - } -} diff --git a/Assets/FirstVillain/EventManager/Sample/Scripts.meta b/Assets/FirstVillain/EventManager/Scripts.meta similarity index 77% rename from Assets/FirstVillain/EventManager/Sample/Scripts.meta rename to Assets/FirstVillain/EventManager/Scripts.meta index 101b222..5861535 100644 --- a/Assets/FirstVillain/EventManager/Sample/Scripts.meta +++ b/Assets/FirstVillain/EventManager/Scripts.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a8734ea3ee422854a8491e4ea1703e8f +guid: 55b7d7145426a6442afc947ca54a1dd6 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/FirstVillain/EventManager/Scripts/EventBus.cs b/Assets/FirstVillain/EventManager/Scripts/EventBus.cs new file mode 100644 index 0000000..48afbdf --- /dev/null +++ b/Assets/FirstVillain/EventManager/Scripts/EventBus.cs @@ -0,0 +1,76 @@ +using FirstVillain.Singleton; +using System; +using System.Collections.Generic; +using UnityEngine.Events; + +namespace FirstVillain.EventBus +{ + public class EventBus : UnitySingleton + { + private readonly Dictionary _delegateDict = new Dictionary(); + private readonly Dictionary _delegateLookupDict = new Dictionary(); + + public delegate void EventDelegate(T myEvent) where T : EventBase; + private delegate void EventDelegate(EventBase myEvent); + + public void Subscribe(EventDelegate callback) where T : EventBase + { + EventDelegate newDelegate = e => callback(e as T); + _delegateLookupDict[callback] = newDelegate; + + var type = typeof(T); + if (!_delegateDict.TryGetValue(type, out EventDelegate tempDeletage)) + { + _delegateDict[type] = tempDeletage; + } + + _delegateDict[type] += newDelegate; + } + + public void Unsubscribe(EventDelegate callback) where T : EventBase + { + if (_delegateLookupDict.TryGetValue(callback, out EventDelegate targetDelegate)) + { + var type = typeof(T); + if (_delegateDict.TryGetValue(type, out EventDelegate tempDelegate)) + { + tempDelegate -= targetDelegate; + if (tempDelegate == null) + { + _delegateDict.Remove(type); + } + else + { + _delegateDict[type] = tempDelegate; + } + } + + _delegateLookupDict.Remove(callback); + } + } + + public void Publish(EventBase eventType) + { + if (_delegateDict.TryGetValue(eventType.GetType(), out EventDelegate callback)) + { + callback.Invoke(eventType); + } + } + + public void Clear() + { + _delegateDict.Clear(); + _delegateLookupDict.Clear(); + } + } + + public class EventBase + { + private int _errorCode; + public int ErrorCode + { + get { return _errorCode; } + set { _errorCode = value; } + } + } +} \ No newline at end of file diff --git a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleEvents.cs.meta b/Assets/FirstVillain/EventManager/Scripts/EventBus.cs.meta similarity index 83% rename from Assets/FirstVillain/EventManager/Sample/Scripts/SampleEvents.cs.meta rename to Assets/FirstVillain/EventManager/Scripts/EventBus.cs.meta index 6924e9e..970253d 100644 --- a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleEvents.cs.meta +++ b/Assets/FirstVillain/EventManager/Scripts/EventBus.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 20c6a74d993d2514185dafb53f2b6ee9 +guid: d805fa4bf208bc743a5c594fb7ce5b96 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/FirstVillain/EventManager/Sample.meta b/Assets/FirstVillain/Exceptions.meta similarity index 77% rename from Assets/FirstVillain/EventManager/Sample.meta rename to Assets/FirstVillain/Exceptions.meta index 7f57366..42b052d 100644 --- a/Assets/FirstVillain/EventManager/Sample.meta +++ b/Assets/FirstVillain/Exceptions.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c83704f62c0d8ab479e531a2a580ca7c +guid: df3e1889274209648b49327c0c1a1743 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/FirstVillain/EventManager/Sample/Scenes.meta b/Assets/FirstVillain/Exceptions/Scripts.meta similarity index 77% rename from Assets/FirstVillain/EventManager/Sample/Scenes.meta rename to Assets/FirstVillain/Exceptions/Scripts.meta index 194029e..b95c01e 100644 --- a/Assets/FirstVillain/EventManager/Sample/Scenes.meta +++ b/Assets/FirstVillain/Exceptions/Scripts.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a6939f1ad30bcf34c94706d8c6260649 +guid: 0dc076918be024147877d7f394a956c9 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/FirstVillain/Exceptions/Scripts/CriticalExceptions.cs b/Assets/FirstVillain/Exceptions/Scripts/CriticalExceptions.cs new file mode 100644 index 0000000..d0dcfb2 --- /dev/null +++ b/Assets/FirstVillain/Exceptions/Scripts/CriticalExceptions.cs @@ -0,0 +1,11 @@ +using System; +using UnityEngine; + +public class ResourceCriticalException : UnityException +{ + public ResourceCriticalException(string message) : base(message) + { } + + public ResourceCriticalException(string message, Exception innerException) : base(message, innerException) + { } +} diff --git a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleListener.cs.meta b/Assets/FirstVillain/Exceptions/Scripts/CriticalExceptions.cs.meta similarity index 83% rename from Assets/FirstVillain/EventManager/Sample/Scripts/SampleListener.cs.meta rename to Assets/FirstVillain/Exceptions/Scripts/CriticalExceptions.cs.meta index 0aca5e3..9498c85 100644 --- a/Assets/FirstVillain/EventManager/Sample/Scripts/SampleListener.cs.meta +++ b/Assets/FirstVillain/Exceptions/Scripts/CriticalExceptions.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 29bceafc84dbcbc45a445598589a16a3 +guid: bb2faed0be04aee4ba5c492fc2a97d4b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/FirstVillain/Plugins.meta b/Assets/FirstVillain/Extensions.meta similarity index 77% rename from Assets/FirstVillain/Plugins.meta rename to Assets/FirstVillain/Extensions.meta index 67b6458..46ca321 100644 --- a/Assets/FirstVillain/Plugins.meta +++ b/Assets/FirstVillain/Extensions.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4080c592a876fcd469b85c1e1c7908b2 +guid: 3554d81ff3e375e4b9354b811054c289 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/FirstVillain/Extensions/TransformExtension.cs b/Assets/FirstVillain/Extensions/TransformExtension.cs new file mode 100644 index 0000000..e354a01 --- /dev/null +++ b/Assets/FirstVillain/Extensions/TransformExtension.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +public static class TransformExtension +{ + public static void DetroyChildren(this Transform transform) + { + foreach (var child in transform) + { + GameObject.Destroy(((Transform)child).gameObject); + } + } + + public static Transform Reset(this Transform transform, Transform parent = null) + { + if (parent != null) + { + transform.SetParent(parent); + } + + transform.localPosition = Vector3.zero; + transform.localRotation = Quaternion.identity; + transform.localScale = Vector3.one; + return transform; + } + + public static RectTransform Reset(this RectTransform rectTransform, Transform parent, Vector2 deltaSize = default(Vector2)) + { + if (parent != null) + { + rectTransform.SetParent(parent); + } + + rectTransform.anchoredPosition = Vector2.zero; + + rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, deltaSize.x); + rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, deltaSize.y); + + rectTransform.localScale = Vector3.one; + rectTransform.localRotation = Quaternion.identity; + return rectTransform; + } +} diff --git a/Assets/FirstVillain/EventManager/Sample/Scripts/SamplePublisher.cs.meta b/Assets/FirstVillain/Extensions/TransformExtension.cs.meta similarity index 83% rename from Assets/FirstVillain/EventManager/Sample/Scripts/SamplePublisher.cs.meta rename to Assets/FirstVillain/Extensions/TransformExtension.cs.meta index 6532fbc..ccd5de8 100644 --- a/Assets/FirstVillain/EventManager/Sample/Scripts/SamplePublisher.cs.meta +++ b/Assets/FirstVillain/Extensions/TransformExtension.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cd5bc50399c22b949a535da2d35d8924 +guid: 52962f8621e0ba54faa8682f81bee221 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts.meta b/Assets/FirstVillain/InfinityScrollView/Scripts.meta new file mode 100644 index 0000000..0d7dc44 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aedcacb105fc4ac4d8d326bf517ac934 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalGridInfiniteScrollView.cs b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalGridInfiniteScrollView.cs new file mode 100644 index 0000000..2dff892 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalGridInfiniteScrollView.cs @@ -0,0 +1,122 @@ +using System.Collections; +using UnityEngine; +namespace FirstVillain.ScrollView +{ + public class HorizontalGridInfiniteScrollView : InfiniteScrollView + { + [SerializeField] private int _rowCount = 1; + [SerializeField] private bool _isAtLeft = true; + [SerializeField] private bool _isAtRight = true; + protected override void OnValueChanged(Vector2 normalizedPosition) + { + if (_rowCount <= 0) + { + _rowCount = 1; + } + float viewportInterval = _scrollRect.viewport.rect.width; + float minViewport = -_scrollRect.content.anchoredPosition.x; + Vector2 viewportRange = new Vector2(minViewport - _extendVisibleRange, minViewport + viewportInterval + _extendVisibleRange); + float contentWidth = _padding.x; + for (int i = 0; i < _dataList.Count; i += _rowCount) + { + for (int j = 0; j < _rowCount; j++) + { + int index = i + j; + if (index >= _dataList.Count) + break; + var visibleRange = new Vector2(contentWidth, contentWidth + _dataList[index].CellSize.x); + if (visibleRange.y < viewportRange.x || visibleRange.x > viewportRange.y) + { + RecycleCell(index); + } + } + contentWidth += _dataList[i].CellSize.x + _spacing; + } + contentWidth = _padding.x; + for (int i = 0; i < _dataList.Count; i += _rowCount) + { + for (int j = 0; j < _rowCount; j++) + { + int index = i + j; + if (index >= _dataList.Count) + break; + var visibleRange = new Vector2(contentWidth, contentWidth + _dataList[index].CellSize.x); + if (visibleRange.y >= viewportRange.x && visibleRange.x <= viewportRange.y) + { + SetupCell(index, new Vector2(contentWidth, (_dataList[index].CellSize.y + _spacing) * -j)); + if (visibleRange.y >= viewportRange.x) + _cellList[index].transform.SetAsLastSibling(); + else + _cellList[index].transform.SetAsFirstSibling(); + } + } + contentWidth += _dataList[i].CellSize.x + _spacing; + } + if (_scrollRect.content.sizeDelta.x > viewportInterval) + { + _isAtLeft = viewportRange.x + _extendVisibleRange <= _dataList[0].CellSize.x; + _isAtRight = _scrollRect.content.sizeDelta.x - viewportRange.y + _extendVisibleRange <= _dataList[_dataList.Count - 1].CellSize.x; + } + else + { + _isAtLeft = true; + _isAtRight = true; + } + } + + public sealed override void Refresh() + { + if (!IsInitialized) + { + Initialize(); + } + if (_scrollRect.viewport.rect.width == 0) + StartCoroutine(DelayToRefresh()); + else + DoRefresh(); + } + + private void DoRefresh() + { + float width = _padding.x; + for (int i = 0; i < _dataList.Count; i += _rowCount) + { + width += _dataList[i].CellSize.x + _spacing; + } + for (int i = 0; i < _cellList.Count; i++) + { + RecycleCell(i); + } + width += _padding.y; + _scrollRect.content.sizeDelta = new Vector2(width, _scrollRect.content.sizeDelta.y); + OnValueChanged(_scrollRect.normalizedPosition); + OnRefresh?.Invoke(); + } + + private IEnumerator DelayToRefresh() + { + yield return _waitEndOfFrame; + DoRefresh(); + } + + public override void Snap(int index, float duration) + { + if (!IsInitialized) + return; + if (index >= _dataList.Count) + return; + var columeNumber = index / _rowCount; + var width = _padding.x; + for (int i = 0; i < columeNumber; i++) + { + width += _dataList[i * _rowCount].CellSize.x + _spacing; + } + width = Mathf.Min(_scrollRect.content.rect.width - _scrollRect.viewport.rect.width, width); + if (_scrollRect.content.anchoredPosition.x != width) + { + DoSnapping(new Vector2(-width, 0), duration); + } + } + } +} + diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalGridInfiniteScrollView.cs.meta b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalGridInfiniteScrollView.cs.meta new file mode 100644 index 0000000..7738ecd --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalGridInfiniteScrollView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3ba537b7830dfe8489ec7c89ca26bb4b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalInfiniteScrollView.cs b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalInfiniteScrollView.cs new file mode 100644 index 0000000..42bc58c --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalInfiniteScrollView.cs @@ -0,0 +1,122 @@ +using System.Collections; +using UnityEngine; +namespace FirstVillain.ScrollView +{ + public class HorizontalInfiniteScrollView : InfiniteScrollView + { + [SerializeField] private bool _isAtLeft = true; + [SerializeField] private bool _isAtRight = true; + + public override void Initialize() + { + base.Initialize(); + _isAtLeft = true; + _isAtRight = true; + } + + protected override void OnValueChanged(Vector2 normalizedPosition) + { + if (_dataList.Count == 0) + return; + float viewportInterval = _scrollRect.viewport.rect.width; + float minViewport = -_scrollRect.content.anchoredPosition.x; + Vector2 viewportRange = new Vector2(minViewport - _extendVisibleRange, minViewport + viewportInterval + _extendVisibleRange); + float contentWidth = _padding.x; + for (int i = 0; i < _dataList.Count; i++) + { + var visibleRange = new Vector2(contentWidth, contentWidth + _dataList[i].CellSize.x); + if (visibleRange.y < viewportRange.x || visibleRange.x > viewportRange.y) + { + RecycleCell(i); + } + contentWidth += _dataList[i].CellSize.x + _spacing; + } + contentWidth = _padding.x; + for (int i = 0; i < _dataList.Count; i++) + { + var visibleRange = new Vector2(contentWidth, contentWidth + _dataList[i].CellSize.x); + if (visibleRange.y >= viewportRange.x && visibleRange.x <= viewportRange.y) + { + SetupCell(i, new Vector2(contentWidth, 0)); + if (visibleRange.y >= viewportRange.x) + _cellList[i].transform.SetAsLastSibling(); + else + _cellList[i].transform.SetAsFirstSibling(); + } + contentWidth += _dataList[i].CellSize.x + _spacing; + } + if (_scrollRect.content.sizeDelta.x > viewportInterval) + { + _isAtLeft = viewportRange.x + _extendVisibleRange <= _dataList[0].CellSize.x; + _isAtRight = _scrollRect.content.sizeDelta.x - viewportRange.y + _extendVisibleRange <= _dataList[_dataList.Count - 1].CellSize.x; + } + else + { + _isAtLeft = true; + _isAtRight = true; + } + } + + public sealed override void Refresh() + { + if (!IsInitialized) + { + Initialize(); + } + if (_scrollRect.viewport.rect.width == 0) + StartCoroutine(DelayToRefresh()); + else + DoRefresh(); + } + + private void DoRefresh() + { + float width = _padding.x; + for (int i = 0; i < _dataList.Count; i++) + { + width += _dataList[i].CellSize.x + _spacing; + } + for (int i = 0; i < _cellList.Count; i++) + { + RecycleCell(i); + } + width += _padding.y; + _scrollRect.content.sizeDelta = new Vector2(width, _scrollRect.content.sizeDelta.y); + OnValueChanged(_scrollRect.normalizedPosition); + OnRefresh?.Invoke(); + } + + private IEnumerator DelayToRefresh() + { + yield return _waitEndOfFrame; + DoRefresh(); + } + + public override void Snap(int index, float duration) + { + if (!IsInitialized) + return; + if (index >= _dataList.Count) + return; + if (_scrollRect.content.rect.width < _scrollRect.viewport.rect.width) + return; + float width = _padding.x; + for (int i = 0; i < index; i++) + { + width += _dataList[i].CellSize.x + _spacing; + } + width = Mathf.Min(_scrollRect.content.rect.width - _scrollRect.viewport.rect.width, width); + if (_scrollRect.content.anchoredPosition.x != width) + { + DoSnapping(new Vector2(-width, 0), duration); + } + } + + public override void Remove(int index) + { + var removeCell = _dataList[index]; + base.Remove(index); + _scrollRect.content.anchoredPosition -= new Vector2(removeCell.CellSize.x + _spacing, 0); + } + } +} \ No newline at end of file diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalInfiniteScrollView.cs.meta b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalInfiniteScrollView.cs.meta new file mode 100644 index 0000000..905eef8 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/HorizontalInfiniteScrollView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 98c7305fb419ce4448024fdf3bc3c489 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCell.cs b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCell.cs new file mode 100644 index 0000000..87d4c69 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCell.cs @@ -0,0 +1,43 @@ +using System; +using UnityEngine; +namespace FirstVillain.ScrollView +{ + public class InfiniteCell : MonoBehaviour + { + public event Action OnSelected; + + private RectTransform _rectTransform; + public RectTransform RectTransform + { + get + { + if (_rectTransform == null) + _rectTransform = GetComponent(); + return _rectTransform; + } + } + + private InfiniteCellData cellData; + public InfiniteCellData CellData + { + set + { + cellData = value; + cellData.OnUpdate(this); + } + get + { + return cellData; + } + } + + public virtual void OnUpdate() { } + + public void InvokeSelected() + { + if (OnSelected != null) + OnSelected.Invoke(gameObject); + } + } +} + diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCell.cs.meta b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCell.cs.meta new file mode 100644 index 0000000..56bb99d --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCell.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b184ddbaea802444b9d761cb1f7e1aa9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCellData.cs b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCellData.cs new file mode 100644 index 0000000..fd653e5 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCellData.cs @@ -0,0 +1,35 @@ +using System; +using UnityEngine; +namespace FirstVillain.ScrollView +{ + public class InfiniteCellData + { + public int Index { get; set; } + public Vector2 CellSize { get; private set; } + + private object _data; + + public Action OnUpdated; + + public InfiniteCellData() + { + + } + + public InfiniteCellData(Vector2 cellSize) + { + this.CellSize = cellSize; + } + + public InfiniteCellData(Vector2 cellSize, object data) + { + this.CellSize = cellSize; + this._data = data; + } + + public void OnUpdate(InfiniteCell cell) + { + OnUpdated?.Invoke(cell); + } + } +} \ No newline at end of file diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCellData.cs.meta b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCellData.cs.meta new file mode 100644 index 0000000..785ecb0 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteCellData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7f2374611890d914ca5159dabdbbd5ca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteScrollView.cs b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteScrollView.cs new file mode 100644 index 0000000..489ad88 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteScrollView.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace FirstVillain.ScrollView +{ + [RequireComponent(typeof(ScrollRect))] + public abstract class InfiniteScrollView : UIBehaviour + { + [SerializeField] private int _cellPoolSize = 20; + [SerializeField] protected float _spacing = 0f; + [SerializeField] protected Vector2 _padding; + [SerializeField] protected float _extendVisibleRange; + + [SerializeField] private InfiniteCell _cellPrefab; + [SerializeField] protected ScrollRect _scrollRect; + + protected List _dataList = new List(); + protected List _cellList = new List(); + protected Queue _cellPool = new Queue(); + protected YieldInstruction _waitEndOfFrame = new WaitForEndOfFrame(); + private Coroutine _snappingProcesser; + + public event Action OnRectTransformUpdate; + public event Action OnCellSelected; + public Action OnRefresh; + + public bool IsInitialized + { + get; + private set; + } + + public virtual void Initialize() + { + if (IsInitialized) + return; + _scrollRect = GetComponent(); + _scrollRect.onValueChanged.AddListener(OnValueChanged); + for (int i = 0; i < _cellPoolSize; i++) + { + var newCell = Instantiate(_cellPrefab, _scrollRect.content); + newCell.gameObject.SetActive(false); + _cellPool.Enqueue(newCell); + } + IsInitialized = true; + } + + protected abstract void OnValueChanged(Vector2 normalizedPosition); + + public abstract void Refresh(); + + public virtual void Add(InfiniteCellData data) + { + if (!IsInitialized) + { + Initialize(); + } + data.Index = _dataList.Count; + _dataList.Add(data); + _cellList.Add(null); + } + + public virtual void Remove(int index) + { + if (!IsInitialized) + { + Initialize(); + } + if (_dataList.Count == 0) + return; + _dataList.RemoveAt(index); + Refresh(); + } + + public abstract void Snap(int index, float duration); + + public void SnapLast(float duration) + { + Snap(_dataList.Count - 1, duration); + } + + protected void DoSnapping(Vector2 target, float duration) + { + if (!gameObject.activeInHierarchy) + return; + StopSnapping(); + _snappingProcesser = StartCoroutine(ProcessSnapping(target, duration)); + } + + public void StopSnapping() + { + if (_snappingProcesser != null) + { + StopCoroutine(_snappingProcesser); + _snappingProcesser = null; + } + } + + private IEnumerator ProcessSnapping(Vector2 target, float duration) + { + _scrollRect.velocity = Vector2.zero; + Vector2 startPos = _scrollRect.content.anchoredPosition; + float t = 0; + while (t < 1f) + { + if (duration <= 0) + t = 1; + else + t += Time.deltaTime / duration; + _scrollRect.content.anchoredPosition = Vector2.Lerp(startPos, target, t); + var normalizedPos = _scrollRect.normalizedPosition; + if (normalizedPos.y < 0 || normalizedPos.x > 1) + { + break; + } + yield return null; + } + if (duration <= 0) + OnValueChanged(_scrollRect.normalizedPosition); + _snappingProcesser = null; + } + + protected void SetupCell(int index, Vector2 pos) + { + if (_cellList[index] == null) + { + var cell = _cellPool.Dequeue(); + cell.gameObject.SetActive(true); + cell.CellData = _dataList[index]; + cell.RectTransform.anchoredPosition = pos; + _cellList[index] = cell; + cell.OnSelected += OnCellObjSelected; + } + } + + protected void RecycleCell(int index) + { + if (_cellList[index] != null) + { + var cell = _cellList[index]; + _cellList[index] = null; + _cellPool.Enqueue(cell); + cell.gameObject.SetActive(false); + cell.OnSelected -= OnCellObjSelected; + } + } + + private void OnCellObjSelected(GameObject selectedCell) + { + OnCellSelected?.Invoke(selectedCell); + } + + public virtual void Clear() + { + if (IsInitialized == false) + Initialize(); + _scrollRect.velocity = Vector2.zero; + _scrollRect.content.anchoredPosition = Vector2.zero; + _dataList.Clear(); + for (int i = 0; i < _cellList.Count; i++) + { + RecycleCell(i); + } + _cellList.Clear(); + Refresh(); + } + + protected override void OnRectTransformDimensionsChange() + { + base.OnRectTransformDimensionsChange(); + if (_scrollRect) + { + OnRectTransformUpdate?.Invoke(); + } + } + } +} \ No newline at end of file diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteScrollView.cs.meta b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteScrollView.cs.meta new file mode 100644 index 0000000..1107ed1 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/InfiniteScrollView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cda563cd2d16cff448cfca3e81aed475 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalGridInfiniteScrollView.cs b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalGridInfiniteScrollView.cs new file mode 100644 index 0000000..a7f24a0 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalGridInfiniteScrollView.cs @@ -0,0 +1,123 @@ +using System.Collections; +using UnityEngine; + +namespace FirstVillain.ScrollView +{ + public class VerticalGridInfiniteScrollView : InfiniteScrollView + { + [SerializeField] private bool _isAtTop = true; + [SerializeField] private bool _isAtBottom = true; + [SerializeField] private int _columeCount = 1; + + protected override void OnValueChanged(Vector2 normalizedPosition) + { + if (_columeCount <= 0) + { + _columeCount = 1; + } + float viewportInterval = _scrollRect.viewport.rect.height; + float minViewport = _scrollRect.content.anchoredPosition.y; + Vector2 viewportRange = new Vector2(minViewport, minViewport + viewportInterval); + float contentHeight = _padding.x; + for (int i = 0; i < _dataList.Count; i += _columeCount) + { + for (int j = 0; j < _columeCount; j++) + { + int index = i + j; + if (index >= _dataList.Count) + break; + var visibleRange = new Vector2(contentHeight, contentHeight + _dataList[index].CellSize.y); + if (visibleRange.y < viewportRange.x || visibleRange.x > viewportRange.y) + { + RecycleCell(index); + } + } + contentHeight += _dataList[i].CellSize.y + _spacing; + } + contentHeight = _padding.x; + for (int i = 0; i < _dataList.Count; i += _columeCount) + { + for (int j = 0; j < _columeCount; j++) + { + int index = i + j; + if (index >= _dataList.Count) + break; + var visibleRange = new Vector2(contentHeight, contentHeight + _dataList[index].CellSize.y); + if (visibleRange.y >= viewportRange.x && visibleRange.x <= viewportRange.y) + { + SetupCell(index, new Vector2((_dataList[index].CellSize.x + _spacing) * j, -contentHeight)); + if (visibleRange.y >= viewportRange.x) + _cellList[index].transform.SetAsLastSibling(); + else + _cellList[index].transform.SetAsFirstSibling(); + } + } + contentHeight += _dataList[i].CellSize.y + _spacing; + } + if (_scrollRect.content.sizeDelta.y > viewportInterval) + { + _isAtTop = viewportRange.x + _extendVisibleRange <= _dataList[0].CellSize.y; + _isAtBottom = _scrollRect.content.sizeDelta.y - viewportRange.y + _extendVisibleRange <= _dataList[_dataList.Count - 1].CellSize.y; + } + else + { + _isAtTop = true; + _isAtBottom = true; + } + } + + public sealed override void Refresh() + { + if (!IsInitialized) + { + Initialize(); + } + if (_scrollRect.viewport.rect.height == 0) + StartCoroutine(DelayToRefresh()); + else + DoRefresh(); + } + + private void DoRefresh() + { + float height = _padding.x; + for (int i = 0; i < _dataList.Count; i += _columeCount) + { + height += _dataList[i].CellSize.y + _spacing; + } + for (int i = 0; i < _cellList.Count; i++) + { + RecycleCell(i); + } + height += _padding.y; + _scrollRect.content.sizeDelta = new Vector2(_scrollRect.content.sizeDelta.x, height); + OnValueChanged(_scrollRect.normalizedPosition); + OnRefresh?.Invoke(); + } + + private IEnumerator DelayToRefresh() + { + yield return _waitEndOfFrame; + DoRefresh(); + } + + public override void Snap(int index, float duration) + { + if (!IsInitialized) + return; + if (index >= _dataList.Count) + return; + var rowNumber = index / _columeCount; + var height = _padding.x; + for (int i = 0; i < rowNumber; i++) + { + height += _dataList[i * _columeCount].CellSize.y + _spacing; + } + height = Mathf.Min(_scrollRect.content.rect.height - _scrollRect.viewport.rect.height, height); + if (_scrollRect.content.anchoredPosition.y != height) + { + DoSnapping(new Vector2(0, height), duration); + } + } + } +} \ No newline at end of file diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalGridInfiniteScrollView.cs.meta b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalGridInfiniteScrollView.cs.meta new file mode 100644 index 0000000..ed29450 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalGridInfiniteScrollView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 692efced3d752f5448fc15089d4eadf5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalInfiniteScrollView.cs b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalInfiniteScrollView.cs new file mode 100644 index 0000000..b104445 --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalInfiniteScrollView.cs @@ -0,0 +1,123 @@ +using System.Collections; +using UnityEngine; + +namespace FirstVillain.ScrollView +{ + public class VerticalInfiniteScrollView : InfiniteScrollView + { + [SerializeField] private bool _isAtTop = true; + [SerializeField] private bool _isAtBottom = true; + + public override void Initialize() + { + base.Initialize(); + _isAtTop = true; + _isAtBottom = true; + } + + protected override void OnValueChanged(Vector2 normalizedPosition) + { + if (_dataList.Count == 0) + return; + float viewportInterval = _scrollRect.viewport.rect.height; + float minViewport = _scrollRect.content.anchoredPosition.y; + Vector2 viewportRange = new Vector2(minViewport - _extendVisibleRange, minViewport + viewportInterval + _extendVisibleRange); + float contentHeight = _padding.x; + for (int i = 0; i < _dataList.Count; i++) + { + var visibleRange = new Vector2(contentHeight, contentHeight + _dataList[i].CellSize.y); + if (visibleRange.y < viewportRange.x || visibleRange.x > viewportRange.y) + { + RecycleCell(i); + } + contentHeight += _dataList[i].CellSize.y + _spacing; + } + contentHeight = _padding.x; + for (int i = 0; i < _dataList.Count; i++) + { + var visibleRange = new Vector2(contentHeight, contentHeight + _dataList[i].CellSize.y); + if (visibleRange.y >= viewportRange.x && visibleRange.x <= viewportRange.y) + { + SetupCell(i, new Vector2(0, -contentHeight)); + if (visibleRange.y >= viewportRange.x) + _cellList[i].transform.SetAsLastSibling(); + else + _cellList[i].transform.SetAsFirstSibling(); + } + contentHeight += _dataList[i].CellSize.y + _spacing; + } + if (_scrollRect.content.sizeDelta.y > viewportInterval) + { + _isAtTop = viewportRange.x + _extendVisibleRange <= 0.001f; + _isAtBottom = _scrollRect.content.sizeDelta.y - viewportRange.y + _extendVisibleRange <= 0.001f; + } + else + { + _isAtTop = true; + _isAtBottom = true; + } + } + + public sealed override void Refresh() + { + if (!IsInitialized) + { + Initialize(); + } + if (_scrollRect.viewport.rect.height == 0) + StartCoroutine(DelayToRefresh()); + else + DoRefresh(); + } + + private void DoRefresh() + { + float height = _padding.x; + for (int i = 0; i < _dataList.Count; i++) + { + height += _dataList[i].CellSize.y + _spacing; + } + for (int i = 0; i < _cellList.Count; i++) + { + RecycleCell(i); + } + height += _padding.y; + _scrollRect.content.sizeDelta = new Vector2(_scrollRect.content.sizeDelta.x, height); + OnValueChanged(_scrollRect.normalizedPosition); + OnRefresh?.Invoke(); + } + + private IEnumerator DelayToRefresh() + { + yield return _waitEndOfFrame; + DoRefresh(); + } + + public override void Snap(int index, float duration) + { + if (!IsInitialized) + return; + if (index >= _dataList.Count) + return; + if (_scrollRect.content.rect.height < _scrollRect.viewport.rect.height) + return; + float height = _padding.x; + for (int i = 0; i < index; i++) + { + height += _dataList[i].CellSize.y + _spacing; + } + height = Mathf.Min(_scrollRect.content.rect.height - _scrollRect.viewport.rect.height, height); + if (_scrollRect.content.anchoredPosition.y != height) + { + DoSnapping(new Vector2(0, height), duration); + } + } + + public override void Remove(int index) + { + var removeCell = _dataList[index]; + base.Remove(index); + _scrollRect.content.anchoredPosition -= new Vector2(0, removeCell.CellSize.y + _spacing); + } + } +} \ No newline at end of file diff --git a/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalInfiniteScrollView.cs.meta b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalInfiniteScrollView.cs.meta new file mode 100644 index 0000000..e16591f --- /dev/null +++ b/Assets/FirstVillain/InfinityScrollView/Scripts/VerticalInfiniteScrollView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5add22e6e1ba6e44e92b2bc861b338ef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/ObjectPool.meta b/Assets/FirstVillain/ObjectPool.meta new file mode 100644 index 0000000..3baf628 --- /dev/null +++ b/Assets/FirstVillain/ObjectPool.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1128e5138db06b045ba9419c71b5ad3f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/ObjectPool/PoolManager.cs b/Assets/FirstVillain/ObjectPool/PoolManager.cs new file mode 100644 index 0000000..cdb297b --- /dev/null +++ b/Assets/FirstVillain/ObjectPool/PoolManager.cs @@ -0,0 +1,191 @@ +using FirstVillain.Singleton; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +using UnityEngine.Pool; + +namespace FirstVillain.ObjectPool +{ + //GameObject Pooling + public class PoolManager : UnitySingleton + { + [SerializeField] private int _capacity = 10; + [SerializeField] private int _maxSize = 1000; + [SerializeField] private bool _collectionCheck = true; + + //À½... Ŭ·¡½º ŸÀÔº°·Î Ç®À» ¸¸µå´Â°Ç? + private Dictionary _poolDict = new(); + + public GameObject Spawn(string path, Transform parent = null) + { + string name = Path.GetFileName(path); + if(!_poolDict.ContainsKey(name)) + { + CreatePoolItem(path); + } + + var pooledObj = _poolDict[name].Pool.Get(); + + if (parent != null) + { + pooledObj.transform.Reset(parent); + } + + return pooledObj; + } + + public T Spawn(string path, Transform parent = null) + { + return Spawn(path, parent).GetComponent(); + } + + public void ReleaseGameObject(GameObject obj) + { + if (_poolDict.ContainsKey(obj.name)) + { + try + { + obj.transform.Reset(); + try + { + _poolDict[obj.name].Pool.Release(obj); + } + catch + { + obj.SetActive(false); + } + } + catch (Exception ex) + { + Debug.LogError($"Exception has occured!!! Object : {obj.name} === {ex.Message}"); + } + } + else + { + Debug.LogWarning($"Object[{obj.name}] does not exist in pool dictionary. But it's been destroyed anyway :D"); + Destroy(obj); + } + } + + #region Create Pool + //ÇöÀç Resources.Load ±â¹ÝÀ¸·Î ±¸Çö... + public void CreatePoolItem(string path) + { + string resourceName = Path.GetFileName(path); + if(!_poolDict.ContainsKey(resourceName)) + { + var resource = LoadAssetOnResources(path); + var pool = new PoolItem(path, CreateNewObjectPool(resource, resourceName)); + _poolDict.Add(resourceName, pool); + } + } + + private ObjectPool CreateNewObjectPool(GameObject prefab, string resourceName) + { + return new ObjectPool( + () => + { + GameObject obj = Instantiate(prefab); + obj.name = resourceName; + return obj; + }, + OnGetItem, + OnReleaseItem, + OnDestroyItem, + _collectionCheck /* Collection checks will throw errors if we try to release an item that is already in the pool.*/, + _capacity/*defalut capacity*/, + _maxSize + ); + } + + private void OnGetItem(GameObject obj) + { + obj.SetActive(true); + } + + private void OnReleaseItem(GameObject obj) + { + obj.SetActive(false); + } + + private void OnDestroyItem(GameObject obj) + { + Destroy(obj); + } + + #endregion Create Pool + + #region Resource Load + + //¸®¼Ò½º °ü¸®·Î ÀÌÀü ¿¹Á¤ + public T LoadAssetOnResources(string resourcePath) where T : UnityEngine.Object + { + var resourceObj = Resources.Load(resourcePath); + if (resourceObj == null) + { + throw new ResourceCriticalException($"Cannot Load Resources Object [{resourcePath}]"); + } + + return resourceObj; + } + #endregion Resource Load + + #region AssetBundle Refresh Shader + private void RefreshShader(UnityEngine.Object obj) + { + //AssetBundleÀº custom shader¸¦ Æ÷ÇÔÇÏÁö ¾ÊÀ¸¹Ç·Î ºÒ·¯¿Ã ½ÃÁ¡¿¡ shader¸¦ Àç¼³Á¤ÇØÁØ´Ù. + if (typeof(GameObject) == typeof(T)) + { + GameObject go = obj as GameObject; + if (go.GetComponents() != null) + { + RefreshShader(go.GetComponents()); + } + + if (go.GetComponentsInChildren(true) != null) + { + RefreshShader(go.GetComponentsInChildren(true)); + } + + } + else if (typeof(Material) == typeof(T)) + { + RefreshShader(obj as Material); + } + } + + private void RefreshShader(Material material) + { + Shader shader = Shader.Find(material.shader.name); + if (shader != null) + { + material.shader = shader; + } + else + { + Debug.LogWarning(string.Format("unable to refresh shader: [{0}] in material [{1}]", material.shader.name, material.name)); + } + } + + private void RefreshShader(Renderer[] renderers) + { + if (null == renderers) + { + return; + } + + for (int i = 0; i < renderers.Length; i++) + { + Material[] materials = renderers[i].sharedMaterials; + for (int j = 0; j < materials.Length; j++) + { + if (materials[j] == null) { continue; } + RefreshShader(materials[j]); + } + } + } + #endregion AssetBundle Refresh Shader + } +} \ No newline at end of file diff --git a/Assets/FirstVillain/ObjectPool/PoolManager.cs.meta b/Assets/FirstVillain/ObjectPool/PoolManager.cs.meta new file mode 100644 index 0000000..d416370 --- /dev/null +++ b/Assets/FirstVillain/ObjectPool/PoolManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 885efdebb82f5f14bba737c867e902da +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/ObjectPool/Scripts.meta b/Assets/FirstVillain/ObjectPool/Scripts.meta new file mode 100644 index 0000000..8b56f28 --- /dev/null +++ b/Assets/FirstVillain/ObjectPool/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 74481aa5ac659be4ab8460d20956ed3d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/ObjectPool/Scripts/PoolItem.cs b/Assets/FirstVillain/ObjectPool/Scripts/PoolItem.cs new file mode 100644 index 0000000..5275b35 --- /dev/null +++ b/Assets/FirstVillain/ObjectPool/Scripts/PoolItem.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Pool; + +namespace FirstVillain.ObjectPool +{ + public class PoolItem + { + public string Path { get; private set; } + public IObjectPool Pool { get; private set; } + + public PoolItem(string path, ObjectPool pool) + { + Path = path; + Pool = pool; + } + } + +} diff --git a/Assets/FirstVillain/ObjectPool/Scripts/PoolItem.cs.meta b/Assets/FirstVillain/ObjectPool/Scripts/PoolItem.cs.meta new file mode 100644 index 0000000..6465563 --- /dev/null +++ b/Assets/FirstVillain/ObjectPool/Scripts/PoolItem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b3b33e646436f184dbe0e8a8009734c1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/ObjectPool/Scripts/PoolManager.cs b/Assets/FirstVillain/ObjectPool/Scripts/PoolManager.cs new file mode 100644 index 0000000..9bba959 --- /dev/null +++ b/Assets/FirstVillain/ObjectPool/Scripts/PoolManager.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PoolManager : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/FirstVillain/ObjectPool/Scripts/PoolManager.cs.meta b/Assets/FirstVillain/ObjectPool/Scripts/PoolManager.cs.meta new file mode 100644 index 0000000..b41c59a --- /dev/null +++ b/Assets/FirstVillain/ObjectPool/Scripts/PoolManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 84874bcaa5a0a144dad2b80a4c9545ef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/Plugins/FirstVillainLibrary.dll b/Assets/FirstVillain/Plugins/FirstVillainLibrary.dll deleted file mode 100644 index a374ac7..0000000 Binary files a/Assets/FirstVillain/Plugins/FirstVillainLibrary.dll and /dev/null differ diff --git a/Assets/FirstVillain/Plugins/FirstVillainLibrary.dll.meta b/Assets/FirstVillain/Plugins/FirstVillainLibrary.dll.meta deleted file mode 100644 index 99c137e..0000000 --- a/Assets/FirstVillain/Plugins/FirstVillainLibrary.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 8c96c7edf3aa4ce4cb713a09ad33e2cc -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/FirstVillain/Singleton.meta b/Assets/FirstVillain/Singleton.meta new file mode 100644 index 0000000..f171951 --- /dev/null +++ b/Assets/FirstVillain/Singleton.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf3ca554e89b4d746a2987777273af31 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/Singleton/UnitySingleton.cs b/Assets/FirstVillain/Singleton/UnitySingleton.cs new file mode 100644 index 0000000..b820acf --- /dev/null +++ b/Assets/FirstVillain/Singleton/UnitySingleton.cs @@ -0,0 +1,93 @@ +using UnityEngine; + +namespace FirstVillain.Singleton +{ + public class UnitySingleton : MonoBehaviour where T : UnityEngine.Component + { + private static T _instance = null; + + public static T Instance + { + get + { + if (_instance == null) + { + string name = (typeof(T)).ToString(); + _instance = new GameObject(name).AddComponent(); + } + + return _instance; + } + } + private void Awake() + { + if (_instance != null && _instance != this) + { + Destroy(gameObject); + return; + } + else + { + _instance = this as T; + } + + DontDestroyOnLoad(gameObject); + + AwakeSingleton(); + } + + private void OnDestroy() + { + if (_instance == this) + { + _instance = null; + } + } + + protected virtual void AwakeSingleton() + { } + } + public class UnitySingletonOnce : MonoBehaviour where T : UnityEngine.Component + { + private static T _instance = null; + + public static T Instance + { + get + { + if (_instance == null) + { + string name = (typeof(T)).ToString(); + _instance = new GameObject(name).AddComponent(); + } + + return _instance; + } + } + private void Awake() + { + if (_instance != null && _instance != this) + { + Destroy(gameObject); + return; + } + else + { + _instance = this as T; + } + + AwakeSingleton(); + } + + private void OnDestroy() + { + if (_instance == this) + { + _instance = null; + } + } + + protected virtual void AwakeSingleton() + { } + } +} diff --git a/Assets/FirstVillain/Singleton/UnitySingleton.cs.meta b/Assets/FirstVillain/Singleton/UnitySingleton.cs.meta new file mode 100644 index 0000000..8a28893 --- /dev/null +++ b/Assets/FirstVillain/Singleton/UnitySingleton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ead3c5ad702e604aa2162aecd9baf1b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleNextScene.unity b/Assets/Scenes/Sample.unity similarity index 94% rename from Assets/FirstVillain/EventManager/Sample/Scenes/SampleNextScene.unity rename to Assets/Scenes/Sample.unity index 1aec802..8d0e42b 100644 --- a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleNextScene.unity +++ b/Assets/Scenes/Sample.unity @@ -123,7 +123,7 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &1819587514 +--- !u!1 &449865083 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -131,9 +131,9 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1819587517} - - component: {fileID: 1819587516} - - component: {fileID: 1819587515} + - component: {fileID: 449865086} + - component: {fileID: 449865085} + - component: {fileID: 449865084} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -141,21 +141,21 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!81 &1819587515 +--- !u!81 &449865084 AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1819587514} + m_GameObject: {fileID: 449865083} m_Enabled: 1 ---- !u!20 &1819587516 +--- !u!20 &449865085 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1819587514} + m_GameObject: {fileID: 449865083} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 @@ -192,13 +192,13 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 ---- !u!4 &1819587517 +--- !u!4 &449865086 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1819587514} + m_GameObject: {fileID: 449865083} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} diff --git a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleNextScene.unity.meta b/Assets/Scenes/Sample.unity.meta similarity index 74% rename from Assets/FirstVillain/EventManager/Sample/Scenes/SampleNextScene.unity.meta rename to Assets/Scenes/Sample.unity.meta index 1471b3d..a90cf57 100644 --- a/Assets/FirstVillain/EventManager/Sample/Scenes/SampleNextScene.unity.meta +++ b/Assets/Scenes/Sample.unity.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a4094ca87d4a63a438643822920c39c9 +guid: 2136612acad4b7a43ac7a55ee222ad75 DefaultImporter: externalObjects: {} userData: