Remake about a half of the inventory UI

This commit is contained in:
excitedneon 2017-05-13 22:56:06 +03:00
parent 5eb424bea0
commit fc1c61e9df
13 changed files with 4506 additions and 181 deletions

View File

@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Hologram Item Selector
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 30}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 0
- _InvFade: 1
- _Metallic: 1
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 0
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 1, g: 0.4980392, b: 0.98615295, a: 0.2509804}
- _EmissionColor: {r: 1, g: 0.543, b: 0.97349375, a: 1}
- _TintColor: {r: 1, g: 0.13725491, b: 0.7058824, a: 0.028}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ccb492954e2b14f559ffb8163add4421
timeCreated: 1494534721
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Hologram Item
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 30}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 0
- _InvFade: 1
- _Metallic: 1
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 0
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 1, g: 0.14700001, b: 0.97646916, a: 0.5019608}
- _EmissionColor: {r: 2.4, g: 1.5287998, b: 2.34947, a: 1}
- _TintColor: {r: 1, g: 0.13725491, b: 0.7058824, a: 0.028}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: dc8a9321c9cc446d3b29e4581ce4524d
timeCreated: 1494534721
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c3365db67a7080b4bbd25629e8e955db33ca4683b2810c43c21ab8f6ad137500 oid sha256:9a55af0841d7c7c5343907c58c3e333a9116cfacab9e3556bd871f4ac71a1a05
size 318 size 552

View File

@ -7,8 +7,8 @@ TextureImporter:
serializedVersion: 4 serializedVersion: 4
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
enableMipMap: 1 enableMipMap: 0
sRGBTexture: 1 sRGBTexture: 0
linearTexture: 0 linearTexture: 0
fadeOut: 0 fadeOut: 0
borderMipMap: 0 borderMipMap: 0
@ -31,7 +31,7 @@ TextureImporter:
aniso: -1 aniso: -1
mipBias: -1 mipBias: -1
wrapMode: 1 wrapMode: 1
nPOTScale: 1 nPOTScale: 0
lightmap: 0 lightmap: 0
compressionQuality: 50 compressionQuality: 50
spriteMode: 0 spriteMode: 0

File diff suppressed because it is too large Load Diff

View File

@ -466,6 +466,49 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 270758321} m_GameObject: {fileID: 270758321}
--- !u!1 &274219295
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 274219296}
- component: {fileID: 274219297}
m_Layer: 0
m_Name: MeshDB
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &274219296
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 274219295}
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: 344272455}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &274219297
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 274219295}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 928708f1fbd954c6e9e015942b8ddb92, type: 3}
m_Name:
m_EditorClassIdentifier:
Meshes:
- {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
- {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &310461191 --- !u!1 &310461191
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -540,6 +583,7 @@ Transform:
- {fileID: 1939832658} - {fileID: 1939832658}
- {fileID: 375619906} - {fileID: 375619906}
- {fileID: 1610252930} - {fileID: 1610252930}
- {fileID: 274219296}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -821,7 +865,7 @@ MeshFilter:
Transform: Transform:
m_PrefabParentObject: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, m_PrefabParentObject: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2,
type: 2} type: 2}
m_PrefabInternal: {fileID: 2139315739} m_PrefabInternal: {fileID: 1560587483}
--- !u!1 &566501560 --- !u!1 &566501560
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2176,6 +2220,112 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1560587483
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 132238582}
m_Modifications:
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.x
value: -0.02
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.x
value: 0.02
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalScale.x
value: 0.8
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalScale.y
value: 0.8
objectReference: {fileID: 0}
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalScale.z
value: 0.8
objectReference: {fileID: 0}
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.y
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalEulerAnglesHint.y
value: 90
objectReference: {fileID: 0}
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
m_IsPrefabParent: 0
--- !u!1 &1610252928 --- !u!1 &1610252928
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2861,45 +3011,3 @@ Camera:
m_StereoConvergence: 10 m_StereoConvergence: 10
m_StereoSeparation: 0.022 m_StereoSeparation: 0.022
m_StereoMirrorMode: 0 m_StereoMirrorMode: 0
--- !u!1001 &2139315739
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 132238582}
m_Modifications:
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4586682446228250, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
m_IsPrefabParent: 0

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Cyber.Util; using Cyber.Util;
using Cyber.Console;
namespace Cyber.Controls { namespace Cyber.Controls {
@ -20,6 +21,16 @@ namespace Cyber.Controls {
/// </summary> /// </summary>
public Hologram Hologram; public Hologram Hologram;
/// <summary>
/// The item preview mesh.
/// </summary>
public MeshFilter ItemPreviewMesh;
/// <summary>
/// The item preview spinner.
/// </summary>
public Spinner ItemPreviewSpinner;
/// <summary> /// <summary>
/// The icon for the inventory. /// The icon for the inventory.
/// </summary> /// </summary>
@ -46,20 +57,28 @@ namespace Cyber.Controls {
public TextTextureApplier IconExplainerText; public TextTextureApplier IconExplainerText;
/// <summary> /// <summary>
/// The text that contains the item list. /// The selector mesh. It'll move to the position of the selected item
/// in the grid.
/// </summary> /// </summary>
public TextTextureApplier ItemListText; public Transform ItemGridSelector;
/// <summary> /// <summary>
/// How many items can be shown on the screen at the same time. /// The parent of all the gameobjects that create the grid.
/// </summary> /// </summary>
public float ItemsPerScreen; public Transform ItemGridParent;
/// <summary>
/// The item grid dimensions.
/// </summary>
public Vector2 ItemGridDimensions;
private CursorHandler CursorHandler; private CursorHandler CursorHandler;
private MeshDB MeshDB;
private bool InventoryOpen = false; private bool InventoryOpen = false;
private int TestingInventorySize = 20;
private int ScrollingIndex = 0; private List<Transform> ItemGridCells;
private int SelectedIndex = -1; private List<MeshFilter> ItemGridCellMeshes;
private int ItemGridSelectedIndex;
private Color IconInventoryColor; private Color IconInventoryColor;
private Color IconStatusColor; private Color IconStatusColor;
@ -68,7 +87,16 @@ namespace Cyber.Controls {
private void Start() { private void Start() {
CursorHandler = GameObject.Find("/Systems/CursorHandler").GetComponent<CursorHandler>(); CursorHandler = GameObject.Find("/Systems/CursorHandler").GetComponent<CursorHandler>();
RebuildItemList(-1); MeshDB = GameObject.Find("/Systems/MeshDB").GetComponent<MeshDB>();
int ItemGridSize = (int) ItemGridDimensions.x * (int) ItemGridDimensions.y;
ItemGridCells = new List<Transform>(ItemGridSize);
ItemGridCellMeshes = new List<MeshFilter>(ItemGridSize);
for (int i = 0; i < ItemGridSize; i++) {
Transform Cell = ItemGridParent.GetChild(i).transform;
ItemGridCells.Add(Cell);
ItemGridCellMeshes.Add(Cell.GetComponentInChildren<MeshFilter>());
}
IconInventoryColor = IconInventory.material.GetColor("_EmissionColor"); IconInventoryColor = IconInventory.material.GetColor("_EmissionColor");
IconStatusColor = IconStatus.material.GetColor("_EmissionColor"); IconStatusColor = IconStatus.material.GetColor("_EmissionColor");
@ -77,35 +105,26 @@ namespace Cyber.Controls {
} }
private void Update() { private void Update() {
if (Term.IsVisible()) {
return;
}
if (Input.GetButtonDown("Inventory")) { if (Input.GetButtonDown("Inventory")) {
InventoryOpen = !InventoryOpen; InventoryOpen = !InventoryOpen;
Hologram.Visible = InventoryOpen; Hologram.Visible = InventoryOpen;
CursorHandler.RequestLockState(!InventoryOpen); CursorHandler.RequestLockState(!InventoryOpen);
} }
int CurrentIndex = -1;
RaycastHit LookedAt = CameraUtil.GetLookedAtHit(Camera, 1f, true); RaycastHit LookedAt = CameraUtil.GetLookedAtHit(Camera, 1f, true);
if (LookedAt.collider != null) { if (LookedAt.collider != null) {
TextTextureApplier Text = LookedAt.collider.GetComponent<TextTextureApplier>();
MeshRenderer Mesh = LookedAt.collider.GetComponent<MeshRenderer>(); MeshRenderer Mesh = LookedAt.collider.GetComponent<MeshRenderer>();
if (Text != null && Text == ItemListText) { if (ItemGridCells.Contains(LookedAt.collider.transform)) {
// Interacting with the item list // Interacting with the item list
// Calculate the index CurrentIndex = int.Parse(LookedAt.collider.name.Split(' ')[1]);
float ScaledY = (Text.transform.InverseTransformPoint(LookedAt.point).z * 0.1f) + 0.5f;
int CurrentIndex = ScrollingIndex + (int)(ScaledY * ItemsPerScreen);
// Update inputs
if (Input.GetAxis("Mouse ScrollWheel") > 0 && ScrollingIndex > 0) {
ScrollingIndex--;
}
if (Input.GetAxis("Mouse ScrollWheel") < 0 && ScrollingIndex < TestingInventorySize - 1) {
ScrollingIndex++;
}
if (Input.GetButtonDown("Activate")) { if (Input.GetButtonDown("Activate")) {
SelectedIndex = CurrentIndex; ItemGridSelectedIndex = CurrentIndex;
} }
// Rebuild the list
RebuildItemList(CurrentIndex);
} else if (Mesh != null) { } else if (Mesh != null) {
float InvBrightness = 1f; float InvBrightness = 1f;
float StsBrightness = 1f; float StsBrightness = 1f;
@ -115,7 +134,7 @@ namespace Cyber.Controls {
if (Mesh == IconInventory) { if (Mesh == IconInventory) {
InvBrightness = 1.2f; InvBrightness = 1.2f;
SelectedIcon = "Inventory"; SelectedIcon = "Storage";
} else if (Mesh == IconStatus) { } else if (Mesh == IconStatus) {
StsBrightness = 1.2f; StsBrightness = 1.2f;
SelectedIcon = "Status"; SelectedIcon = "Status";
@ -131,37 +150,91 @@ namespace Cyber.Controls {
Props.Text = SelectedIcon; Props.Text = SelectedIcon;
IconExplainerText.SetTextProperties(Props); IconExplainerText.SetTextProperties(Props);
IconInventory.material.SetColor("_EmissionColor", IconInventoryColor * InvBrightness);
IconStatus.material.SetColor("_EmissionColor", IconStatusColor * StsBrightness); IconInventory.material.SetColor("_EmissionColor", new Color(IconInventoryColor.r * InvBrightness,
IconSocial.material.SetColor("_EmissionColor", IconSocialColor * SclBrightness); IconInventoryColor.g * InvBrightness, IconInventoryColor.b * InvBrightness));
IconMap.material.SetColor("_EmissionColor", IconMapColor * MapBrightness); IconStatus.material.SetColor("_EmissionColor", new Color(IconStatusColor.r * StsBrightness,
IconStatusColor.g * StsBrightness, IconStatusColor.b * StsBrightness));
IconSocial.material.SetColor("_EmissionColor", new Color(IconSocialColor.r * SclBrightness,
IconSocialColor.g * SclBrightness, IconSocialColor.b * SclBrightness));
IconMap.material.SetColor("_EmissionColor", new Color(IconMapColor.r * MapBrightness,
IconMapColor.g * MapBrightness, IconMapColor.b * MapBrightness));
} }
} else { } else {
// Outside of the inventory, clicking will unselect // Outside of the inventory, clicking will unselect
if (Input.GetButtonDown("Activate")) { if (Input.GetButtonDown("Activate")) {
SelectedIndex = -1; ItemGridSelectedIndex = -1;
RebuildItemList(-1);
} }
} }
RebuildItemGrid(CurrentIndex);
}
private void RebuildItemGrid(int focused) {
if (ItemGridSelectedIndex < 0) {
SetPreviewMesh(null);
}
for (int i = 0; i < ItemGridDimensions.x * ItemGridDimensions.y; i++) {
ItemGridCellMeshes[i].mesh = MeshDB.Meshes[i % MeshDB.Meshes.Length];
float Scale = 0.08f;
bool Spinning = false;
if (focused == i || ItemGridSelectedIndex == i) {
Scale = 0.1f;
Spinning = true;
}
if (ItemGridSelectedIndex == i) {
SetPreviewMesh(ItemGridCellMeshes[i].mesh);
if ((ItemGridSelector.position - ItemGridCells[i].position).magnitude < 0.01f) {
ItemGridSelector.position = ItemGridCells[i].position;
} else {
ItemGridSelector.position =
Vector3.Lerp(ItemGridSelector.position,
ItemGridCells[i].position, 20f * Time.deltaTime);
}
ItemGridSelector.LookAt(Camera.transform);
Vector3 NewRot = ItemGridSelector.localEulerAngles;
NewRot.z = 0;
ItemGridSelector.localEulerAngles = NewRot;
}
if (!Spinning) {
ItemGridCellMeshes[i].transform.LookAt(Camera.transform);
Vector3 NewRot = ItemGridCellMeshes[i].transform.localEulerAngles;
NewRot.z = 0;
ItemGridCellMeshes[i].transform.localEulerAngles = NewRot;
}
ItemGridCells[i].GetComponent<Spinner>().Spinning = Spinning;
FixMeshScaling(ItemGridCellMeshes[i], Scale);
}
} }
private void RebuildItemList(int focused) { private void SetPreviewMesh(Mesh mesh) {
string Inv = ""; ItemPreviewSpinner.Spinning = mesh != null;
for (int i = ScrollingIndex; i < TestingInventorySize; i++) { ItemPreviewMesh.mesh = mesh;
if (i == focused) {
Inv += "<b>"; if (mesh != null) {
} FixMeshScaling(ItemPreviewMesh, 0.175f);
if (i == SelectedIndex) {
Inv += "·";
}
Inv += "Item #" + i + "\n";
if (i == focused) {
Inv += "</b>";
} }
} }
TextTextureProperties NewProps = ItemListText.TextProperties;
NewProps.Text = Inv; private void FixMeshScaling(MeshFilter toFix, float scale) {
ItemListText.SetTextProperties(NewProps); float HighestExtent = 0f;
float Height = toFix.mesh.bounds.extents.y * 2f;
float Width = Mathf.Sqrt(Mathf.Pow(toFix.mesh.bounds.extents.x * 2f, 2) +
Mathf.Pow(toFix.mesh.bounds.extents.y * 2f, 2));
float Depth = Mathf.Sqrt(Mathf.Pow(toFix.mesh.bounds.extents.z * 2f, 2) +
Mathf.Pow(toFix.mesh.bounds.extents.y * 2f, 2));
if (Height > HighestExtent) {
HighestExtent = Height;
}
if (Width > HighestExtent) {
HighestExtent = Width;
}
if (Depth > HighestExtent) {
HighestExtent = Depth;
}
float Scale = scale * 1f / HighestExtent;
toFix.transform.localScale = new Vector3(Scale, Scale, Scale);
} }
} }
} }

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Cyber.Util {
/// <summary>
/// Mesh database, contains all the meshes in the game. This should be
/// used if meshes are needed at runtime.
/// </summary>
public class MeshDB : MonoBehaviour {
/// <summary>
/// The meshes that can be used at runtime.
/// </summary>
public Mesh[] Meshes;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 928708f1fbd954c6e9e015942b8ddb92
timeCreated: 1494617518
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Cyber.Util {
/// <summary>
/// Spins the transform at a defined speed.
/// </summary>
public class Spinner : MonoBehaviour {
/// <summary>
/// The axis this spinner spins around.
/// </summary>
public Vector3 Axis = new Vector3(0, 1, 0);
/// <summary>
/// The rounds per minute of the spinning.
/// </summary>
public float RoundsPerMinute = 30;
/// <summary>
/// Whether the spinner is spinning currently.
/// </summary>
public bool Spinning = true;
private float CurrentRelativeSpeed = 1f;
private void Start() {
CurrentRelativeSpeed = Spinning ? 1f : 0f;
}
private void Update() {
CurrentRelativeSpeed = Mathf.Lerp(CurrentRelativeSpeed,
Spinning ? 1f : 0f, 20f * Time.deltaTime);
transform.localEulerAngles = transform.localEulerAngles +
Axis * RoundsPerMinute * CurrentRelativeSpeed * Time.deltaTime;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0b0a8d5b96e07491dbcbbaa244f887f0
timeCreated: 1494617956
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: