Further prototyping for inspection window. added an example for item preview

This commit is contained in:
tonyomendoza 2023-03-17 04:18:16 -07:00
parent eee855551a
commit 8d46b15c3d
9 changed files with 1511 additions and 75 deletions

View File

@ -295,6 +295,7 @@ namespace SimpleInventorySystem
public Transform DefaultItemSpawn; public Transform DefaultItemSpawn;
[HideInInspector] public bool IsDraggingItem; [HideInInspector] public bool IsDraggingItem;
public List<GameObject> hResults; public List<GameObject> hResults;
public ItemViewer itemViewer;
public enum States { Undefined, Loot, PickUp }; public enum States { Undefined, Loot, PickUp };
public States CurrentState = States.Undefined; public States CurrentState = States.Undefined;
@ -388,7 +389,13 @@ namespace SimpleInventorySystem
return Instantiate(InventorySystem.instance.StorageWindowPrefab, inventoryUI.transform); return Instantiate(InventorySystem.instance.StorageWindowPrefab, inventoryUI.transform);
} }
else if(windowType == nameof(InspectionWindowUI) && InventorySystem.instance.InspectionWindowPrefab.GetComponent<InspectionWindowUI>() != null) else if(windowType == nameof(InspectionWindowUI) && InventorySystem.instance.InspectionWindowPrefab.GetComponent<InspectionWindowUI>() != null)
{
if(itemViewer != null)
{
itemViewer.OpenCamera();
}
return Instantiate(InventorySystem.instance.InspectionWindowPrefab, inventoryUI.transform); return Instantiate(InventorySystem.instance.InspectionWindowPrefab, inventoryUI.transform);
}
else else
return null; return null;
} }

View File

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemViewer : MonoBehaviour
{
public Camera viewerCamera;
public GameObject cameraHolder;
public void OpenCamera()
{
viewerCamera.gameObject.SetActive(true);
}
public void CloseCamera()
{
viewerCamera.gameObject.SetActive(false);
}
public void Update()
{
}
}

View File

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

View File

@ -0,0 +1,101 @@
/*
Original script from: https://wiki.unity3d.com/index.php/MouseOrbitImproved
Just a few line modification by me: https://www.youtube.com/channel/UCjAFR8Gm-7GsMvtC_scsp8A/
*/
using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Orbit with zoom")]
public class MouseOrbitImproved : MonoBehaviour
{
public Transform target;
public float distance = 5.0f;
public float xSpeed = 120.0f;
public float ySpeed = 120.0f;
public float yMinLimit = -20f;
public float yMaxLimit = 80f;
public float distanceMin = .5f;
public float distanceMax = 15f;
private Rigidbody rigidbody;
float x = 0.0f;
float y = 0.0f;
bool orbitable;
// Use this for initialization
void Start()
{
Vector3 angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
rigidbody = GetComponent<Rigidbody>();
// Make the rigid body not change rotation
if (rigidbody != null)
{
rigidbody.freezeRotation = true;
}
}
void Update()
{
/*
if (Input.GetKeyDown(KeyCode.LeftControl) == true)
{
orbitable = true;
}
else if (Input.GetKeyUp(KeyCode.LeftControl) == true)
{
orbitable = false;
}
*/
if (Input.GetMouseButtonDown(0))
orbitable = true;
else if (Input.GetMouseButtonUp(0))
orbitable = false;
if (orbitable)
{
if (target)
{
x += Input.GetAxis("Mouse X") * xSpeed * distance * Time.deltaTime;
y -= Input.GetAxis("Mouse Y") * ySpeed * Time.deltaTime;
y = ClampAngle(y, yMinLimit, yMaxLimit);
Quaternion rotation = Quaternion.Euler(y, x, 0);
distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel") *Time.deltaTime, distanceMin, distanceMax);
RaycastHit hit;
if (Physics.Linecast(target.position, transform.position, out hit))
{
distance -= hit.distance;
}
Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
}
}
}
public static float ClampAngle(float angle, float min, float max)
{
if (angle < -360F)
angle += 360F;
if (angle > 360F)
angle -= 360F;
return Mathf.Clamp(angle, min, max);
}
}

View File

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

View File

@ -0,0 +1,37 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!84 &8400000
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ItemViewerRenderTexture
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 2048
m_Height: 512
m_AntiAliasing: 1
m_MipCount: -1
m_DepthFormat: 2
m_ColorFormat: 8
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 528ea652096d5a44aad6b5f1b0f9cd79
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1883,6 +1883,12 @@ MeshFilter:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 106699460} m_GameObject: {fileID: 106699460}
m_Mesh: {fileID: 4300000, guid: 0e821fe9c748a3845a35720d67512bae, type: 3} m_Mesh: {fileID: 4300000, guid: 0e821fe9c748a3845a35720d67512bae, type: 3}
--- !u!4 &116436006 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
m_PrefabInstance: {fileID: 1903067589}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &119691890 --- !u!1001 &119691890
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3217,6 +3223,37 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 421f12c4cc2c4614f9e0616ef942cf44, type: 3} m_Script: {fileID: 11500000, guid: 421f12c4cc2c4614f9e0616ef942cf44, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!1 &182285666
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 182285667}
m_Layer: 0
m_Name: Item
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &182285667
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 182285666}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 116436006}
m_Father: {fileID: 952502937}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &184085248 --- !u!1001 &184085248
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5378,6 +5415,110 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 17 m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
--- !u!1 &235689161
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 235689162}
- component: {fileID: 235689164}
- component: {fileID: 235689163}
- component: {fileID: 235689165}
m_Layer: 0
m_Name: Camera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &235689162
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 235689161}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0.15}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 952502937}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!81 &235689163
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 235689161}
m_Enabled: 1
--- !u!20 &235689164
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 235689161}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
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.1
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 8400000, guid: 528ea652096d5a44aad6b5f1b0f9cd79, type: 2}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!114 &235689165
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 235689161}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ab9c1c17ac31fe54f913563968700f16, type: 3}
m_Name:
m_EditorClassIdentifier:
target: {fileID: 182285667}
distance: 0.15
xSpeed: 300
ySpeed: 300
yMinLimit: -20
yMaxLimit: 80
distanceMin: 0.15
distanceMax: 1
--- !u!54 &236675544 --- !u!54 &236675544
Rigidbody: Rigidbody:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -23561,6 +23702,36 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 935467738} m_PrefabInstance: {fileID: 935467738}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &936399551
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 936399552}
m_Layer: 0
m_Name: CameraHolder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &936399552
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 936399551}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 952502937}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &937292165 --- !u!1001 &937292165
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -24010,6 +24181,54 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 690566991} m_PrefabInstance: {fileID: 690566991}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &952502936
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 952502937}
- component: {fileID: 952502938}
m_Layer: 0
m_Name: Item Viewer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &952502937
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 952502936}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -873.1286, y: -10535.676, z: 22.848022}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 235689162}
- {fileID: 936399552}
- {fileID: 182285667}
m_Father: {fileID: 1625489126}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &952502938
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 952502936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1ab299478edec704f8d044dc7f79227e, type: 3}
m_Name:
m_EditorClassIdentifier:
viewerCamera: {fileID: 235689164}
cameraHolder: {fileID: 936399551}
--- !u!1001 &953792832 --- !u!1001 &953792832
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -43717,6 +43936,12 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dfb70f42b1ba68342a1a2c7fa95a4095, type: 3} m_SourcePrefab: {fileID: 100100000, guid: dfb70f42b1ba68342a1a2c7fa95a4095, type: 3}
--- !u!4 &1625489126 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2770326605790841686, guid: 9f005685dc17f4643b4a1156970fe2f6,
type: 3}
m_PrefabInstance: {fileID: 2770326605231792848}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1625518134 --- !u!1001 &1625518134
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -49428,6 +49653,110 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1901829060} m_PrefabInstance: {fileID: 1901829060}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1001 &1903067589
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 182285667}
m_Modifications:
- target: {fileID: 3516595912989551378, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3516595912989551378, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3516595912989551378, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3516595912989551378, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3516595912989551378, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3516595912989551378, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6431934805223382759, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6437227991555130963, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_Name
value: 1x1 Brown Pouch
objectReference: {fileID: 0}
- target: {fileID: 6479586328427631359, guid: a173e349ae63c5a4d92337ea2872d13c,
type: 3}
propertyPath: m_UseGravity
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a173e349ae63c5a4d92337ea2872d13c, type: 3}
--- !u!1001 &1903575850 --- !u!1001 &1903575850
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -57043,6 +57372,11 @@ PrefabInstance:
value: value:
objectReference: {fileID: 4417106255924003221, guid: 94f7925a9ec6ba94f991f7f462adb6f2, objectReference: {fileID: 4417106255924003221, guid: 94f7925a9ec6ba94f991f7f462adb6f2,
type: 3} type: 3}
- target: {fileID: 2770326605790841687, guid: 9f005685dc17f4643b4a1156970fe2f6,
type: 3}
propertyPath: itemViewer
value:
objectReference: {fileID: 952502938}
- target: {fileID: 2770326605790841688, guid: 9f005685dc17f4643b4a1156970fe2f6, - target: {fileID: 2770326605790841688, guid: 9f005685dc17f4643b4a1156970fe2f6,
type: 3} type: 3}
propertyPath: pauseMenu propertyPath: pauseMenu