SceneUIManager added

This commit is contained in:
2022-07-15 16:26:40 +02:00
parent 9f2b1ff5d6
commit c4449488ae
5 changed files with 86 additions and 45 deletions

View File

@@ -17,16 +17,6 @@ public class ColorManager : MonoBehaviour
{ {
public Material[] colorMaterials = new Material[Enum.GetNames(typeof(Colors)).Length]; public Material[] colorMaterials = new Material[Enum.GetNames(typeof(Colors)).Length];
private void OnCollisionEnter(Collision collision) {
if (collision.collider.CompareTag("Water")) {
WashColor(collision.gameObject);
} else if (collision.collider.CompareTag("Ground")){
CheckGroundColor(collision.gameObject);
} else if (collision.collider.CompareTag("ColorChanger")) {
SetColor(Colors.None, transform.gameObject, collision);
}
}
public void WashColor(GameObject washed) { public void WashColor(GameObject washed) {
SetColor(Colors.Grey, washed); SetColor(Colors.Grey, washed);
} }
@@ -34,7 +24,7 @@ public class ColorManager : MonoBehaviour
public void SetColor(Colors color, GameObject toPaint, Collision collision = null) { public void SetColor(Colors color, GameObject toPaint, Collision collision = null) {
if(color == Colors.None) { if(color == Colors.None) {
if (collision.transform.CompareTag("ColorChanger")) { if (collision.transform.CompareTag("ColorChanger")) {
transform.GetComponent<Renderer>().material.color = collision.transform.GetComponent<Renderer>().material.color; toPaint.GetComponent<Renderer>().material.color = collision.transform.GetComponent<Renderer>().material.color;
} }
} else { } else {
toPaint.GetComponent<Renderer>().material.color = colorMaterials[(int)color].color; toPaint.GetComponent<Renderer>().material.color = colorMaterials[(int)color].color;
@@ -48,4 +38,14 @@ public class ColorManager : MonoBehaviour
+ transform.GetComponent<Renderer>().material.color); + transform.GetComponent<Renderer>().material.color);
} }
} }
private void OnCollisionEnter(Collision collision) {
if (collision.collider.CompareTag("Water")) {
WashColor(collision.gameObject);
} else if (collision.collider.CompareTag("Ground")) {
CheckGroundColor(collision.gameObject);
} else if (collision.collider.CompareTag("ColorChanger")) {
SetColor(Colors.None, transform.gameObject, collision);
}
}
} }

View File

@@ -4,20 +4,17 @@ using UnityEngine;
public class PlayerController : MonoBehaviour public class PlayerController : MonoBehaviour
{ {
public Rigidbody rb;
public float moveSpeed = 5f; public float moveSpeed = 5f;
public float jumpforce = 5f; public float jumpforce = 5f;
private Vector3 direction; private Vector3 direction;
public Rigidbody rb; private float horizontal, vertical, isJumping;
private float horizontal, vertical;
public float isJumping;
private bool isOnGround; private bool isOnGround;
private void Awake() { private void Awake() {
rb = GetComponent<Rigidbody>(); rb = GetComponent<Rigidbody>();
} }
// Update is called once per frame
void Update() void Update()
{ {
horizontal = Input.GetAxis("Horizontal"); horizontal = Input.GetAxis("Horizontal");

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneUIManager : MonoBehaviour
{
private int menuSceneIndex = 0, currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
public void LoadMenuScene() {
SceneManager.LoadScene(menuSceneIndex);
}
public void LoadPauseMenu() {
//to be implemented when the ui is done
}
public void LoadOptionsMenu() {
//to be implemented when the ui is done
}
public void LoadNextScene() {
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void LoadScene(int sceneIndex) {
SceneManager.LoadScene(sceneIndex);
}
public void DisableUI(string UIName) {
//to be implemented when some ui is done
}
}

View File

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

View File

@@ -74,7 +74,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 100} m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 8096} m_MaxSize: {x: 16192, y: 8096}
vertical: 0 vertical: 0
controlID: 93 controlID: 103
--- !u!114 &4 --- !u!114 &4
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@@ -99,7 +99,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200} m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192} m_MaxSize: {x: 24288, y: 16192}
vertical: 0 vertical: 0
controlID: 52 controlID: 53
--- !u!114 &5 --- !u!114 &5
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@@ -119,8 +119,8 @@ MonoBehaviour:
y: 0 y: 0
width: 453 width: 453
height: 947 height: 947
m_MinSize: {x: 275, y: 50} m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 15} m_ActualView: {fileID: 15}
m_Panes: m_Panes:
- {fileID: 15} - {fileID: 15}
@@ -145,8 +145,8 @@ MonoBehaviour:
y: 0 y: 0
width: 218 width: 218
height: 561 height: 561
m_MinSize: {x: 200, y: 200} m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 16} m_ActualView: {fileID: 16}
m_Panes: m_Panes:
- {fileID: 16} - {fileID: 16}
@@ -273,7 +273,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 200} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 16192, y: 16192} m_MaxSize: {x: 16192, y: 16192}
vertical: 1 vertical: 1
controlID: 53 controlID: 54
--- !u!114 &12 --- !u!114 &12
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@@ -298,7 +298,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 100} m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 8096} m_MaxSize: {x: 16192, y: 8096}
vertical: 0 vertical: 0
controlID: 54 controlID: 55
--- !u!114 &13 --- !u!114 &13
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@@ -309,7 +309,7 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 1 m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0} m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: GameView m_Name: SceneView
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Children: [] m_Children: []
m_Position: m_Position:
@@ -318,14 +318,14 @@ MonoBehaviour:
y: 0 y: 0
width: 1249 width: 1249
height: 561 height: 561
m_MinSize: {x: 200, y: 200} m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 18} m_ActualView: {fileID: 17}
m_Panes: m_Panes:
- {fileID: 17} - {fileID: 17}
- {fileID: 18} - {fileID: 18}
m_Selected: 1 m_Selected: 0
m_LastSelected: 0 m_LastSelected: 1
--- !u!114 &14 --- !u!114 &14
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@@ -367,22 +367,22 @@ MonoBehaviour:
m_SkipHidden: 0 m_SkipHidden: 0
m_SearchArea: 1 m_SearchArea: 1
m_Folders: m_Folders:
- Assets/Scripts - Assets
m_Globs: [] m_Globs: []
m_OriginalText: m_OriginalText:
m_ViewMode: 1 m_ViewMode: 1
m_StartGridSize: 64 m_StartGridSize: 64
m_LastFolders: m_LastFolders:
- Assets/Scripts - Assets
m_LastFoldersGridSize: -1 m_LastFoldersGridSize: -1
m_LastProjectPath: C:\dev\Ball Puzzle m_LastProjectPath: C:\dev\Ball Puzzle
m_LockTracker: m_LockTracker:
m_IsLocked: 0 m_IsLocked: 0
m_FolderTreeState: m_FolderTreeState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: 705a0000 m_SelectedIDs: 665a0000
m_LastClickedID: 23152 m_LastClickedID: 23142
m_ExpandedIDs: 00000000625a0000 m_ExpandedIDs: 00000000665a0000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@@ -410,7 +410,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: 00000000625a0000 m_ExpandedIDs: 00000000665a0000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@@ -454,7 +454,7 @@ MonoBehaviour:
m_IsRenaming: 0 m_IsRenaming: 0
m_OriginalEventType: 11 m_OriginalEventType: 11
m_IsRenamingFilename: 1 m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 7} m_ClientGUIView: {fileID: 13}
m_CreateAssetUtility: m_CreateAssetUtility:
m_EndAction: {fileID: 0} m_EndAction: {fileID: 0}
m_InstanceID: 0 m_InstanceID: 0
@@ -673,7 +673,7 @@ MonoBehaviour:
containerId: overlay-container--right containerId: overlay-container--right
floating: 0 floating: 0
collapsed: 0 collapsed: 0
displayed: 1 displayed: 0
snapOffset: {x: 0, y: 0} snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 0} snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0 snapCorner: 0
@@ -789,9 +789,9 @@ MonoBehaviour:
m_PlayAudio: 0 m_PlayAudio: 0
m_AudioPlay: 0 m_AudioPlay: 0
m_Position: m_Position:
m_Target: {x: 4.2956486, y: 2.0538712, z: 3.4216719} m_Target: {x: 4.3949623, y: 0.073812485, z: 2.3814888}
speed: 2 speed: 2
m_Value: {x: 4.2956486, y: 2.0538712, z: 3.4216719} m_Value: {x: 4.3949623, y: 0.073812485, z: 2.3814888}
m_RenderMode: 0 m_RenderMode: 0
m_CameraMode: m_CameraMode:
drawMode: 0 drawMode: 0
@@ -838,13 +838,13 @@ MonoBehaviour:
m_GridAxis: 1 m_GridAxis: 1
m_gridOpacity: 0.5 m_gridOpacity: 0.5
m_Rotation: m_Rotation:
m_Target: {x: -0.34271905, y: 0.0005610486, z: -0.00020494133, w: -0.93943846} m_Target: {x: -0.36944824, y: -0.19247824, z: 0.07851425, w: -0.90570277}
speed: 2 speed: 2
m_Value: {x: -0.34271884, y: 0.0005610483, z: -0.00020494121, w: -0.9394379} m_Value: {x: -0.3693297, y: -0.1938364, z: 0.07906826, w: -0.9054122}
m_Size: m_Size:
m_Target: 4.338933 m_Target: 7.68944
speed: 2 speed: 2
m_Value: 4.338933 m_Value: 7.3583155
m_Ortho: m_Ortho:
m_Target: 0 m_Target: 0
speed: 2 speed: 2
@@ -911,7 +911,7 @@ MonoBehaviour:
m_UseMipMap: 0 m_UseMipMap: 0
m_VSyncEnabled: 0 m_VSyncEnabled: 0
m_Gizmos: 0 m_Gizmos: 0
m_Stats: 1 m_Stats: 0
m_SelectedSizes: 00000000000000000000000000000000000000000000000000000000000000000000000000000000 m_SelectedSizes: 00000000000000000000000000000000000000000000000000000000000000000000000000000000
m_ZoomArea: m_ZoomArea:
m_HRangeLocked: 0 m_HRangeLocked: 0