Basic saving, currently hardcoded to the one "chest" inventory in HomeBase.

Loads when scene name contains "Homebase" and saves when button pressed.
This commit is contained in:
HelarJ
2022-04-18 08:59:26 +03:00
parent be8b9a987d
commit b1954dd40e
34 changed files with 39886 additions and 306 deletions

View File

@@ -1,272 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &988253026175329073
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 155580, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_Name
value: Axe
objectReference: {fileID: 0}
- target: {fileID: 155580, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_TagString
value: Cutter
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalPosition.x
value: 0.1048176
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalPosition.y
value: 0.032218672
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalPosition.z
value: 0.81958795
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalRotation.w
value: -0.000000115202326
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalRotation.x
value: 0.000000115202326
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalRotation.y
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalRotation.z
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 451388, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3328158, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
propertyPath: m_Mesh
value:
objectReference: {fileID: 4300136, guid: 7374575f12d49ba459e91009f7a9ec62, type: 3}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2ec0a21ef68f64a46864ad388da793c4, type: 3}
--- !u!1 &988253026175220877 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 155580, guid: 2ec0a21ef68f64a46864ad388da793c4,
type: 3}
m_PrefabInstance: {fileID: 988253026175329073}
m_PrefabAsset: {fileID: 0}
--- !u!54 &8447640023250943431
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 988253026175220877}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!136 &8447640023250943427
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 988253026175220877}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.030867163
m_Height: 0.43418774
m_Direction: 1
m_Center: {x: 0.0036834013, y: 0.12670654, z: -0.0013518014}
--- !u!114 &8447640023250943421
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 988253026175220877}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c93cfeee8cd29624bae7c5203dedb433, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &8447640023250943426
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 988253026175220877}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5fea29bb7c508c244a1f805a5fd3fc4d, type: 3}
m_Name:
m_EditorClassIdentifier:
outlineMode: 0
outlineColor: {r: 0.36489165, g: 0.9254902, b: 0.2470588, a: 1}
outlineWidth: 2
precomputeOutline: 0
bakeKeys: []
bakeValues: []
--- !u!114 &8447640023250943429
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 988253026175220877}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ad34abafad169848a38072baa96cdb2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_InteractionManager: {fileID: 0}
m_Colliders: []
m_InteractionLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_InteractionLayers:
m_Bits: 1
m_SelectMode: 0
m_CustomReticle: {fileID: 0}
m_FirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_LastHoverExited:
m_PersistentCalls:
m_Calls: []
m_HoverEntered:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8447640023250943421}
m_TargetAssemblyTypeName: Hover, Assembly-CSharp
m_MethodName: HoverStart
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
m_HoverExited:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8447640023250943421}
m_TargetAssemblyTypeName: Hover, Assembly-CSharp
m_MethodName: HoverEnd
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
m_FirstSelectEntered:
m_PersistentCalls:
m_Calls: []
m_LastSelectExited:
m_PersistentCalls:
m_Calls: []
m_SelectEntered:
m_PersistentCalls:
m_Calls: []
m_SelectExited:
m_PersistentCalls:
m_Calls: []
m_Activated:
m_PersistentCalls:
m_Calls: []
m_Deactivated:
m_PersistentCalls:
m_Calls: []
m_OnFirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnLastHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectEntered:
m_PersistentCalls:
m_Calls: []
m_OnSelectExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectCanceled:
m_PersistentCalls:
m_Calls: []
m_OnActivate:
m_PersistentCalls:
m_Calls: []
m_OnDeactivate:
m_PersistentCalls:
m_Calls: []
m_AttachTransform: {fileID: 0}
m_AttachEaseInTime: 0.15
m_MovementType: 2
m_VelocityDamping: 1
m_VelocityScale: 1
m_AngularVelocityDamping: 1
m_AngularVelocityScale: 1
m_TrackPosition: 1
m_SmoothPosition: 0
m_SmoothPositionAmount: 5
m_TightenPosition: 0.5
m_TrackRotation: 1
m_SmoothRotation: 0
m_SmoothRotationAmount: 5
m_TightenRotation: 0.5
m_ThrowOnDetach: 1
m_ThrowSmoothingDuration: 0.25
m_ThrowSmoothingCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_ThrowVelocityScale: 1.5
m_ThrowAngularVelocityScale: 1
m_ForceGravityOnDetach: 0
m_RetainTransformParent: 1
m_AttachPointCompatibilityMode: 0

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 1931b899d98ae8543a827f11728cabe4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,306 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3057085693074020240
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3057085693074115504}
- component: {fileID: 3057085693074918288}
- component: {fileID: 3057085693076015440}
- component: {fileID: 8478891420560098512}
- component: {fileID: 1868636573106052050}
- component: {fileID: -728432962252772913}
- component: {fileID: 1264022012566418942}
- component: {fileID: 759522315152862422}
- component: {fileID: 7019801789685915322}
m_Layer: 10
m_Name: Log
m_TagString: Throwable
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3057085693074115504
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_LocalRotation: {x: 0, y: -0, z: 0.7071068, w: -0.7071068}
m_LocalPosition: {x: -0.6981036, y: 0.99629545, z: 2.16}
m_LocalScale: {x: 0.2, y: 0.5669, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 270}
--- !u!33 &3057085693074918288
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_Mesh: {fileID: 4300000, guid: 768be665aba8b4e4aae7a973ae9616cf, type: 3}
--- !u!23 &3057085693076015440
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_Enabled: 1
m_CastShadows: 2
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 93caadf4359ae8143aad35b3145d31af, 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: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!54 &8478891420560098512
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!136 &1868636573106052050
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.3296725
m_Height: 0.8131512
m_Direction: 1
m_Center: {x: -0.04072858, y: 0.4065756, z: 0}
--- !u!114 &-728432962252772913
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ad34abafad169848a38072baa96cdb2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_InteractionManager: {fileID: 0}
m_Colliders: []
m_InteractionLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_InteractionLayers:
m_Bits: 1
m_SelectMode: 0
m_CustomReticle: {fileID: 0}
m_FirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_LastHoverExited:
m_PersistentCalls:
m_Calls: []
m_HoverEntered:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1264022012566418942}
m_TargetAssemblyTypeName: Hover, Assembly-CSharp
m_MethodName: HoverStart
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
m_HoverExited:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1264022012566418942}
m_TargetAssemblyTypeName: Hover, Assembly-CSharp
m_MethodName: HoverEnd
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
m_FirstSelectEntered:
m_PersistentCalls:
m_Calls: []
m_LastSelectExited:
m_PersistentCalls:
m_Calls: []
m_SelectEntered:
m_PersistentCalls:
m_Calls: []
m_SelectExited:
m_PersistentCalls:
m_Calls: []
m_Activated:
m_PersistentCalls:
m_Calls: []
m_Deactivated:
m_PersistentCalls:
m_Calls: []
m_OnFirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnLastHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectEntered:
m_PersistentCalls:
m_Calls: []
m_OnSelectExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectCanceled:
m_PersistentCalls:
m_Calls: []
m_OnActivate:
m_PersistentCalls:
m_Calls: []
m_OnDeactivate:
m_PersistentCalls:
m_Calls: []
m_AttachTransform: {fileID: 0}
m_AttachEaseInTime: 0.15
m_MovementType: 2
m_VelocityDamping: 1
m_VelocityScale: 1
m_AngularVelocityDamping: 1
m_AngularVelocityScale: 1
m_TrackPosition: 1
m_SmoothPosition: 0
m_SmoothPositionAmount: 5
m_TightenPosition: 0.5
m_TrackRotation: 1
m_SmoothRotation: 0
m_SmoothRotationAmount: 5
m_TightenRotation: 0.5
m_ThrowOnDetach: 1
m_ThrowSmoothingDuration: 0.25
m_ThrowSmoothingCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_ThrowVelocityScale: 1.5
m_ThrowAngularVelocityScale: 1
m_ForceGravityOnDetach: 0
m_RetainTransformParent: 1
m_AttachPointCompatibilityMode: 0
--- !u!114 &1264022012566418942
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c93cfeee8cd29624bae7c5203dedb433, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &759522315152862422
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5fea29bb7c508c244a1f805a5fd3fc4d, type: 3}
m_Name:
m_EditorClassIdentifier:
outlineMode: 0
outlineColor: {r: 1, g: 1, b: 1, a: 1}
outlineWidth: 2
precomputeOutline: 0
bakeKeys: []
bakeValues: []
--- !u!114 &7019801789685915322
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3057085693074020240}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fc417ab3a5b06f04db2149be4cfdf6e4, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 5
canStack: 1
itemName: Wood Log
itemDescription: A simple wooden log. A key ingredient for many things.

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 79529cede28e9b9499885b2d83b8adcf
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -1,166 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1015801306266775025
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1015801306266775024}
- component: {fileID: 3918595098149605214}
- component: {fileID: 5155207960822887486}
- component: {fileID: 1015801306266775026}
- component: {fileID: 1015801306266775027}
- component: {fileID: 7148710207580294270}
m_Layer: 21
m_Name: Holster
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1015801306266775024
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015801306266775025}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &3918595098149605214
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015801306266775025}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &5155207960822887486
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015801306266775025}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: bcd4c7c7522235044b0026229d01d661, 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
m_AdditionalVertexStreams: {fileID: 0}
--- !u!135 &1015801306266775026
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015801306266775025}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &1015801306266775027
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015801306266775025}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 60523e0647cc6ab43acc73cb266a32a7, type: 3}
m_Name:
m_EditorClassIdentifier:
m_InteractionManager: {fileID: 0}
m_InteractionLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_InteractionLayers:
m_Bits: 4294967295
m_AttachTransform: {fileID: 0}
m_KeepSelectedTargetValid: 1
m_StartingSelectedInteractable: {fileID: 0}
m_HoverEntered:
m_PersistentCalls:
m_Calls: []
m_HoverExited:
m_PersistentCalls:
m_Calls: []
m_SelectEntered:
m_PersistentCalls:
m_Calls: []
m_SelectExited:
m_PersistentCalls:
m_Calls: []
m_OnHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectEntered:
m_PersistentCalls:
m_Calls: []
m_OnSelectExited:
m_PersistentCalls:
m_Calls: []
m_ShowInteractableHoverMeshes: 1
m_InteractableHoverMeshMaterial: {fileID: 2100000, guid: e944091e9e7c68f438499bc41f182b6d,
type: 2}
m_InteractableCantHoverMeshMaterial: {fileID: 2100000, guid: 4cf3d6647a5c3ef4da704441f4015387,
type: 2}
m_SocketActive: 1
m_InteractableHoverScale: 1
m_RecycleDelayTime: 1
--- !u!114 &7148710207580294270
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015801306266775025}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aca2b5bf18c279c4cb265c82010714b1, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: fe14b264b0f9cdf4cb9b3b8da9d57a51
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,251 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4385080170328260021
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4385080170327957909}
- component: {fileID: 4385080170331349429}
- component: {fileID: 4385080170330252149}
- component: {fileID: 4729065021270817612}
- component: {fileID: 5579585539182961868}
- component: {fileID: 8105550803505491054}
- component: {fileID: 4591371125200328589}
m_Layer: 10
m_Name: Mushroom_01
m_TagString: Throwable
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4385080170327957909
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4385080170328260021}
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &4385080170331349429
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4385080170328260021}
m_Mesh: {fileID: 4300000, guid: d062f5c56ffb55c4f832432ada269abe, type: 3}
--- !u!23 &4385080170330252149
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4385080170328260021}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 93caadf4359ae8143aad35b3145d31af, 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: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!64 &4729065021270817612
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4385080170328260021}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 1
m_CookingOptions: 30
m_Mesh: {fileID: 4300000, guid: d062f5c56ffb55c4f832432ada269abe, type: 3}
--- !u!54 &5579585539182961868
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4385080170328260021}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &8105550803505491054
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4385080170328260021}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ad34abafad169848a38072baa96cdb2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_InteractionManager: {fileID: 0}
m_Colliders: []
m_InteractionLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_InteractionLayers:
m_Bits: 1
m_SelectMode: 0
m_CustomReticle: {fileID: 0}
m_FirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_LastHoverExited:
m_PersistentCalls:
m_Calls: []
m_HoverEntered:
m_PersistentCalls:
m_Calls: []
m_HoverExited:
m_PersistentCalls:
m_Calls: []
m_FirstSelectEntered:
m_PersistentCalls:
m_Calls: []
m_LastSelectExited:
m_PersistentCalls:
m_Calls: []
m_SelectEntered:
m_PersistentCalls:
m_Calls: []
m_SelectExited:
m_PersistentCalls:
m_Calls: []
m_Activated:
m_PersistentCalls:
m_Calls: []
m_Deactivated:
m_PersistentCalls:
m_Calls: []
m_OnFirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnLastHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectEntered:
m_PersistentCalls:
m_Calls: []
m_OnSelectExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectCanceled:
m_PersistentCalls:
m_Calls: []
m_OnActivate:
m_PersistentCalls:
m_Calls: []
m_OnDeactivate:
m_PersistentCalls:
m_Calls: []
m_AttachTransform: {fileID: 0}
m_AttachEaseInTime: 0.15
m_MovementType: 2
m_VelocityDamping: 1
m_VelocityScale: 1
m_AngularVelocityDamping: 1
m_AngularVelocityScale: 1
m_TrackPosition: 1
m_SmoothPosition: 0
m_SmoothPositionAmount: 5
m_TightenPosition: 0.5
m_TrackRotation: 1
m_SmoothRotation: 0
m_SmoothRotationAmount: 5
m_TightenRotation: 0.5
m_ThrowOnDetach: 1
m_ThrowSmoothingDuration: 0.25
m_ThrowSmoothingCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_ThrowVelocityScale: 1.5
m_ThrowAngularVelocityScale: 1
m_ForceGravityOnDetach: 0
m_RetainTransformParent: 1
m_AttachPointCompatibilityMode: 0
--- !u!114 &4591371125200328589
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4385080170328260021}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fc417ab3a5b06f04db2149be4cfdf6e4, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 1
canStack: 1
itemName: Red Mushroom
itemDescription:
prefab: {fileID: 4385080170328260021}

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ff07c0f77f650934fa56842fd0da5b3f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,251 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5440707293445505367
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5440707293445741943}
- component: {fileID: 5440707293442317655}
- component: {fileID: 5440707293443317655}
- component: {fileID: 5371485246626056766}
- component: {fileID: 5868452619794669030}
- component: {fileID: 2669145217468523370}
- component: {fileID: 8028753017960928093}
m_Layer: 10
m_Name: Mushroom_02
m_TagString: Throwable
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5440707293445741943
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440707293445505367}
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: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &5440707293442317655
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440707293445505367}
m_Mesh: {fileID: 4300000, guid: 6c890c97a154a474082af84a379dffce, type: 3}
--- !u!23 &5440707293443317655
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440707293445505367}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 93caadf4359ae8143aad35b3145d31af, 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: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!64 &5371485246626056766
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440707293445505367}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 1
m_CookingOptions: 30
m_Mesh: {fileID: 4300000, guid: 6c890c97a154a474082af84a379dffce, type: 3}
--- !u!54 &5868452619794669030
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440707293445505367}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &2669145217468523370
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440707293445505367}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ad34abafad169848a38072baa96cdb2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_InteractionManager: {fileID: 0}
m_Colliders: []
m_InteractionLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_InteractionLayers:
m_Bits: 1
m_SelectMode: 0
m_CustomReticle: {fileID: 0}
m_FirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_LastHoverExited:
m_PersistentCalls:
m_Calls: []
m_HoverEntered:
m_PersistentCalls:
m_Calls: []
m_HoverExited:
m_PersistentCalls:
m_Calls: []
m_FirstSelectEntered:
m_PersistentCalls:
m_Calls: []
m_LastSelectExited:
m_PersistentCalls:
m_Calls: []
m_SelectEntered:
m_PersistentCalls:
m_Calls: []
m_SelectExited:
m_PersistentCalls:
m_Calls: []
m_Activated:
m_PersistentCalls:
m_Calls: []
m_Deactivated:
m_PersistentCalls:
m_Calls: []
m_OnFirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnLastHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnHoverEntered:
m_PersistentCalls:
m_Calls: []
m_OnHoverExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectEntered:
m_PersistentCalls:
m_Calls: []
m_OnSelectExited:
m_PersistentCalls:
m_Calls: []
m_OnSelectCanceled:
m_PersistentCalls:
m_Calls: []
m_OnActivate:
m_PersistentCalls:
m_Calls: []
m_OnDeactivate:
m_PersistentCalls:
m_Calls: []
m_AttachTransform: {fileID: 0}
m_AttachEaseInTime: 0.15
m_MovementType: 2
m_VelocityDamping: 1
m_VelocityScale: 1
m_AngularVelocityDamping: 1
m_AngularVelocityScale: 1
m_TrackPosition: 1
m_SmoothPosition: 0
m_SmoothPositionAmount: 5
m_TightenPosition: 0.5
m_TrackRotation: 1
m_SmoothRotation: 0
m_SmoothRotationAmount: 5
m_TightenRotation: 0.5
m_ThrowOnDetach: 1
m_ThrowSmoothingDuration: 0.25
m_ThrowSmoothingCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_ThrowVelocityScale: 1.5
m_ThrowAngularVelocityScale: 1
m_ForceGravityOnDetach: 0
m_RetainTransformParent: 1
m_AttachPointCompatibilityMode: 0
--- !u!114 &8028753017960928093
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440707293445505367}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fc417ab3a5b06f04db2149be4cfdf6e4, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 2
canStack: 1
itemName: Brown Mushroom
itemDescription:
prefab: {fileID: 5440707293445505367}

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: acae1ba4da5728745aae501446dd78fc
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
fileFormatVersion: 2
<<<<<<<< HEAD:Assets/Project Files/Scripts/Helar/Items.meta
guid: 215fe2a51d12ecc43ba8f86d3dc3ae54
folderAsset: yes
DefaultImporter:
========
guid: 1e00d72d45b494a4ea598ff34d46a589
PrefabImporter:
>>>>>>>> origin/joonasp_Milestone2:Assets/Project Files/Prefabs/JoonasP/EssenceNode.prefab.meta
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -87,7 +87,7 @@ public class HandAnim : MonoBehaviour
private void GripActionPerformed(InputAction.CallbackContext obj)
{
Debug.Log("grip");
//Debug.Log("grip");
CalculateState(obj.ReadValue<float>(), ref grip_state);
m_animator.SetFloat(m_animParamIndexFlex, grip_state);
}

View File

@@ -1,17 +1,22 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;
[Serializable]
public class Inventory : MonoBehaviour
{
//perhaps use these additional slots for holsters attached to the player?
public List<InventorySlot> additionalSlots;
public GameObject itemContainerPrefab;
private List<InventorySlot> _inventorySlots;
public InventorySaveData inventorySaveData;
private void Awake()
{
_inventorySlots = new List<InventorySlot>();
@@ -20,10 +25,15 @@ public class Inventory : MonoBehaviour
inventorySlot.SetParentInventory(this);
_inventorySlots.Add(inventorySlot);
}
Debug.Log(_inventorySlots.Count);
}
private void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
var inventorySlotsInChildren = GetComponentsInChildren<InventorySlot>();
foreach (var inventorySlot in inventorySlotsInChildren)
{
@@ -32,6 +42,12 @@ public class Inventory : MonoBehaviour
}
}
private void OnDisable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
public bool AddItem(ItemData item)
{
if (item.canStack)
@@ -39,16 +55,17 @@ public class Inventory : MonoBehaviour
return AddItem(ConvertToInventoryItem(item));
}
return AddToFirstOpenSlot(item.gameObject);
return AddToFirstOpenSlot(item.prefab.gameObject);
}
public bool AddItem(InventoryItem item)
{
//Stacks the item if it already exists in the inventory.
foreach (var inventorySlot in _inventorySlots.Where(inventorySlot =>
inventorySlot.ContainsItem(item.GetItemid())))
{
inventorySlot.GetItem().ChangeCount(item.Count);
inventorySlot.GetItem().ChangeCount(item.saveData.count);
return true;
}
@@ -67,11 +84,91 @@ public class Inventory : MonoBehaviour
return false;
}
private void AddToSpecificSlot(GameObject item, int slot)
{
_inventorySlots[slot].AssignItem(item);
}
private InventoryItem ConvertToInventoryItem(ItemData item)
{
var inventoryItem = Instantiate(itemContainerPrefab, transform);
itemContainerPrefab.GetComponent<InventoryItem>().itemPrefab = item.gameObject;
itemContainerPrefab.GetComponent<InventoryItem>().itemPrefab = item.prefab.gameObject;
return inventoryItem.gameObject.GetComponent<InventoryItem>();
}
public void SaveInventory()
{
inventorySaveData.inventoryContents.Clear();
foreach (var inventoryItem in _inventorySlots.Select(inventorySlot => inventorySlot.GetItem()))
{
//adds an itemsavedata to the list if it exists or an empty one if it doesnt
inventorySaveData.inventoryContents.Add(inventoryItem != null
? inventoryItem.saveData
: new ItemSaveData());
}
var json = JsonUtility.ToJson(inventorySaveData);
Debug.Log(json);
using var sw = new StreamWriter(Path.Combine(Application.persistentDataPath, "invSave.dat"));
sw.Write(json);
Debug.Log("Inv data saved!");
}
public IEnumerator LoadInventory()
{
//Wait for 1 second after loading the scene to prevent missing prefabs. (1 second delay might also break something in the future)
yield return new WaitForSeconds(1);
//todo make this modular, currently only supports one inventory, although the slots can be anywhere.
if (File.Exists(Path.Combine(Application.persistentDataPath, "invSave.dat")))
{
var saveData = JsonUtility.FromJson<InventorySaveData>(File.ReadAllText(Path.Combine(Application.persistentDataPath, "invSave.dat")));
Debug.Log(saveData);
Debug.Log("Inv data loaded! total "+saveData.inventoryContents.Count);
for (var i = 0; i < saveData.inventoryContents.Count; i++)
{
//prevents overwriting inventory slots when there is something already in there.
//if (_inventorySlots[i]._itemInSlot != null) continue;
var data = saveData.inventoryContents[i];
//if there isnt an item in the slot the count is 0
Debug.Log(data.assetPath + " "+data.count);
if (data.count == 0) continue;
//Loads the prefab from resources folder
var load = Resources.Load(data.assetPath, typeof(GameObject)) as GameObject;
if (load == null)
{
Debug.LogError("Didn't find a prefab at " + data.assetPath);
yield break;
}
Debug.Log(load);
AddToSpecificSlot(load, i);
//sets the count after the item has been converted into inventoryitem
if (load.GetComponent<ItemData>().canStack) _inventorySlots[i]._itemInSlot.GetComponent<InventoryItem>().saveData.count = data.count;
}
}
else
Debug.LogError("There is no save data!");
}
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
Debug.Log("OnSceneLoaded: " + scene.name);
//primitive check to only load the inventory when you are in the home scene.
if (scene.name.Contains("Homebase")) StartCoroutine(LoadInventory());
}
}

View File

@@ -4,16 +4,14 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
[Serializable]
[RequireComponent(typeof(XRSocketInteractor))]
public class InventorySlot : MonoBehaviour
{
private XRSocketInteractor xrSocketInteractor;
private GameObject _itemInSlot;
public GameObject _itemInSlot;
private Inventory _parentInventory;
private void Awake()
{
xrSocketInteractor = GetComponent<XRSocketInteractor>();
@@ -35,6 +33,7 @@ public class InventorySlot : MonoBehaviour
if (_itemInSlot.GetComponent<InventoryItem>() == null) return;
if (_itemInSlot == args.interactableObject.transform.gameObject) return;
//Debug.Log("hoverenter "+args.interactableObject + " " + xrSocketInteractor.hasHover + " " + xrSocketInteractor.hasSelection);
var newItem = args.interactableObject.transform.gameObject;
@@ -47,7 +46,7 @@ public class InventorySlot : MonoBehaviour
if (inventoryItem != null)
{
_itemInSlot.GetComponent<InventoryItem>().ChangeCount(inventoryItem.Count);
_itemInSlot.GetComponent<InventoryItem>().ChangeCount(inventoryItem.saveData.count);
}
else
{
@@ -70,11 +69,13 @@ public class InventorySlot : MonoBehaviour
private void SelectEnter(SelectEnterEventArgs args)
{
Debug.Log("Added to slot item " + _itemInSlot);
var newItem = args.interactableObject.transform.gameObject;
//todo: fix ones that cant stack
//Converts the item into a inventory item
if (newItem.GetComponent<InventoryItem>() == null && newItem.GetComponent<ItemData>().canStack)
if (newItem.GetComponent<InventoryItem>() == null)
{
var load = Resources.Load("Helar/Item", typeof(GameObject)) as GameObject;
@@ -101,12 +102,39 @@ public class InventorySlot : MonoBehaviour
_itemInSlot = instance;
//_parentInventory.AddItem(instance.GetComponent<InventoryItem>());
return;
}
_itemInSlot = newItem;
//_parentInventory.AddItem(newItem.GetComponentInChildren<ItemData>());
//xrSocketInteractor.attachTransform = _itemInSlot.transform;
Debug.Log("Holstered item" + _itemInSlot.GetComponentInChildren<ItemData>());
}
private GameObject ConvertItem(GameObject item)
{
//load container object
var load = Resources.Load("Helar/Item", typeof(GameObject)) as GameObject;
//instantiate the container object
var instance = Instantiate(load, transform);
//load the container with the item to convert
instance.GetComponent<InventoryItem>().itemPrefab = item.gameObject;
//set the position and scale so it fits in the container
instance.transform.localScale = Vector3.one;
instance.transform.localPosition = Vector3.zero;
instance.transform.rotation = Quaternion.identity;
//enable the itemcontainer (more logic in InventoryItem OnEnable() method)
instance.GetComponent<InventoryItem>().enabled = true;
return instance;
}
private void ManagerOninteractableUnregistered(InteractableUnregisteredEventArgs obj)
@@ -126,12 +154,14 @@ public class InventorySlot : MonoBehaviour
component.drag = 0.5f;
if (!_itemInSlot.GetComponentInChildren<ItemData>().canStack ||
_itemInSlot.GetComponent<InventoryItem>().Count == 1)
_itemInSlot.GetComponent<InventoryItem>().saveData.count == 1)
{
//todo change back to regular item
//_itemInSlot.GetComponent<InventoryItem>().PopItem();
//var transformGameObject = _itemInSlot.GetComponentInChildren<ItemData>().transform.gameObject;
//Debug.Log(transformGameObject);
//args.interactableObject = transformGameObject.GetComponent<XRGrabInteractable>();
//todo change back to regular item
}
Debug.Log("Removed from slot item " + _itemInSlot);
_itemInSlot = null;
@@ -160,11 +190,20 @@ public class InventorySlot : MonoBehaviour
public void AssignItem(GameObject newObject)
{
_itemInSlot = newObject;
if (newObject.GetComponent<InventoryItem>() == null)
{
_itemInSlot = ConvertItem(newObject);
}
else
{
_itemInSlot = newObject;
}
}
public InventoryItem GetItem()
{
if (_itemInSlot == null) return null;
var inventoryItem = _itemInSlot.GetComponent<InventoryItem>();
if (inventoryItem == null) Debug.LogError("Item in slot doesn't have InventoryItem component");
return inventoryItem;

View File

@@ -9,7 +9,7 @@ public class ItemSpawner : MonoBehaviour
public GameObject placeToSpawn;
public void SpawnItem()
{
Debug.Log("Spawned " + objectToSpawn);
Instantiate(objectToSpawn, placeToSpawn.transform);
Debug.Log("Spawned " + objectToSpawn);
}
}

View File

@@ -3,7 +3,6 @@ using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.Mathematics;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
@@ -13,15 +12,13 @@ public class InventoryItem : MonoBehaviour
public GameObject itemPrefab;
private int _itemId;
private GameObject _childPrefab;
public int Count { get; private set; }
private TMP_Text itemCounterText;
public TMP_Text itemCounterText;
private ItemData itemData;
private ItemData _itemData;
public ItemSaveData saveData;
private void OnEnable()
@@ -37,13 +34,15 @@ public class InventoryItem : MonoBehaviour
if (itemCounterText == null) itemCounterText = GetComponentInChildren<TMP_Text>();
_childPrefab = GetComponentInChildren<ItemData>()?.gameObject;
_childPrefab = GetComponentInChildren<ItemData>()?.prefab.gameObject;
//Only attaches the prefab if it doesn't already have one ([ExecuteAlways] causes one to be spawned in editor).
if (_childPrefab != null) return;
_childPrefab = Instantiate(itemPrefab, transform);
_childPrefab.transform.localPosition = new Vector3(0, -0.45f, 0);
_childPrefab.transform.localScale = new Vector3(2, 2, 2);
//todo switch to multiply instead so items with non 1,1,1 scale will retain their proportions
_childPrefab.transform.localPosition = GetComponentInChildren<ItemData>().positionInContainer;
_childPrefab.transform.localScale = GetComponentInChildren<ItemData>().scaleInContainer;
_childPrefab.transform.rotation = quaternion.identity;
//Disable prefab components that arent relevant.
@@ -59,24 +58,29 @@ public class InventoryItem : MonoBehaviour
var xrGrabInteractableComponent = _childPrefab.GetComponent<XRGrabInteractable>();
if (xrGrabInteractableComponent != null) xrGrabInteractableComponent.enabled = false;
}
private void Start()
{
_itemData = _childPrefab.GetComponent<ItemData>();
itemData = _childPrefab.GetComponent<ItemData>();
if (_itemData == null) Debug.LogError("Item prefab has no attached ItemData", _childPrefab);
_itemId = _itemData.itemId;
if (Count == 0) Count = 1;
if (itemData == null) Debug.LogError("Item prefab has no attached ItemData", _childPrefab);
Debug.Log(saveData);
if (string.IsNullOrEmpty(saveData.assetPath))
{
saveData.assetPath = itemData.assetLocation;
saveData.count = saveData.count == 0 ? 1 : saveData.count;
}
UpdateText();
}
private void UpdateText()
{
itemCounterText.text = _itemData.canStack ? Count.ToString() : "";
itemCounterText.text = itemData.canStack ? saveData.count.ToString() : "";
}
/**
@@ -85,11 +89,11 @@ public class InventoryItem : MonoBehaviour
*/
public bool ChangeCount(int amount)
{
if (Count + amount < 0) return false;
if (saveData.count + amount < 0) return false;
Count += amount;
saveData.count += amount;
if (Count == 0)
if (saveData.count == 0)
{
//Destroys this gameobject if the count is 0 or lower
Destroy(gameObject);
@@ -103,10 +107,11 @@ public class InventoryItem : MonoBehaviour
public void PopItem()
{
GameObject item = Instantiate(_itemData.prefab, transform.position + transform.forward, Quaternion.identity);
GameObject item = Instantiate(itemData.prefab, transform.position + transform.forward, Quaternion.identity);
item.transform.localScale = Vector3.one;
item.transform.name = _itemData.name;
item.transform.name = itemData.itemName;
var colliderComponent = item.GetComponent<Collider>();
if (colliderComponent != null) colliderComponent.enabled = true;
@@ -127,13 +132,13 @@ public class InventoryItem : MonoBehaviour
public int GetItemid()
{
return _itemId;
return itemData.itemId;;
}
public override string ToString()
{
return $"{base.ToString()}, Count: {Count}, ItemData: {_itemData}";
return $"{base.ToString()}, Count: {saveData.count}, ItemData: {itemData}";
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class InventorySaveData
{
public List<ItemSaveData> inventoryContents;
}

View File

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

View File

@@ -1,16 +1,44 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
[Serializable]
public class ItemData : MonoBehaviour
{
[Tooltip("Location is populated automatically")]
public string assetLocation;
public int itemId;
public bool canStack;
public string itemName;
public string itemDescription;
public GameObject prefab;
public Vector3 scaleInContainer;
public Vector3 positionInContainer;
private void OnValidate()
{
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(prefab))) assetLocation = AssetDatabase.GetAssetPath(prefab);
AdjustPath();
}
private void AdjustPath()
{
//trims the location for use with Resources.Load later
if (assetLocation.StartsWith("Assets/Resources/"))
assetLocation = assetLocation[17 .. ^7];
else if (!string.IsNullOrEmpty(assetLocation))
if (assetLocation.StartsWith("Assets"))
{
Debug.LogError(itemName +
": item with this script should be placed in the Assets/Resources/ folder. Currently: " +
assetLocation);
}
}
public override string ToString()
{

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class ItemSaveData
{
public string assetPath;
public int count;
}

View File

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