persistance
mohamed 3 years ago
parent 7bbe37bae3
commit 5c443d7db2

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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

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

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

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HidePanelButton : MonoBehaviour
{
/// <summary>
/// Cached reference to the PanelManager
/// </summary>
private PanelManager _panelManager;
private void Start()
{
// Cache the manager
_panelManager = PanelManager.Instance;
}
public void DoHidePanel()
{
// Hide the last panel
_panelManager.HideLastPanel();
}
}

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

@ -0,0 +1,31 @@
using UnityEngine;
public class ShowPanelButton : MonoBehaviour
{
/// <summary>
/// The id of the panel to show
/// </summary>
public string PanelId;
/// <summary>
/// The panel show behaviour
/// </summary>
public PanelShowBehaviour Behaviour;
/// <summary>
/// Cached reference to the PanelManager
/// </summary>
private PanelManager _panelManager;
private void Start()
{
// Cache the manager
_panelManager = PanelManager.Instance;
}
public void DoShowPanel()
{
// Show the panel
_panelManager.ShowPanel(PanelId, Behaviour);
}
}

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

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

@ -0,0 +1,8 @@
public enum PanelShowBehaviour
{
// Keep the previous panel when showing a new one
KEEP_PREVIOUS,
// Hide the previous panel before showing a new one
HIDE_PREVIOUS
}

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

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

@ -0,0 +1,65 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
/// <summary>
/// Object Pool
/// </summary>
public class ObjectPool : Singleton<ObjectPool>
{
/// <summary>
/// List of the objects to be pooled
/// </summary>
public List<GameObject> PrefabsForPool;
/// <summary>
/// List of the pooled objects
/// </summary>
private List<GameObject> _pooledObjects = new List<GameObject>();
public GameObject GetObjectFromPool(string objectName)
{
// Try to get a pooled instance
var instance = _pooledObjects.FirstOrDefault(obj => obj.name == objectName);
// If we have a pooled instance already
if (instance != null)
{
// Remove it from the list of pooled objects
_pooledObjects.Remove(instance);
// Enable it
instance.SetActive(true);
return instance;
}
// If we don't have a pooled instance
var prefab = PrefabsForPool.FirstOrDefault(obj => obj.name == objectName);
if (prefab != null)
{
// Create a new instance
var newInstace = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
// Make sure you set it's name (so you remove the Clone that Unity ads)
newInstace.name = objectName;
// Set it's position to zero
newInstace.transform.localPosition = Vector3.zero;
return newInstace;
}
Debug.LogWarning("Object pool doesn't have a prefab for the object with name " + objectName);
return null;
}
public void PoolObject(GameObject obj)
{
// Disable the object
obj.SetActive(false);
// Add it to the list of pooled objects
_pooledObjects.Add(obj);
}
}

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

@ -0,0 +1,26 @@
using UnityEngine;
/// <summary>
/// Generic Singleton
/// </summary>
/// <typeparam name="T">The type for the Singleton</typeparam>
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
/// <summary>
/// The instance
/// </summary>
private static T _instance;
/// <summary>
/// The instance property
/// </summary>
public static T Instance => _instance;
/// <summary>
/// Cast this to the instance
/// </summary>
public void Awake()
{
_instance = (T) (object) this;
}
}

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

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

@ -0,0 +1,107 @@

using System.Collections.Generic;
using UnityEngine;
public class PanelManager : Singleton<PanelManager>
{
/// <summary>
/// This is going to hold all of our instances
/// </summary>
private List<PanelInstanceModel> _panelInstanceModels = new List<PanelInstanceModel>();
/// <summary>
/// Pool of panels
/// </summary>
private ObjectPool _objectPool;
private void Start()
{
// Cache the ObjectPool
_objectPool = ObjectPool.Instance;
}
public void ShowPanel(string panelId, PanelShowBehaviour behaviour = PanelShowBehaviour.KEEP_PREVIOUS)
{
// Get a panel instance from the ObjectPool
GameObject panelInstance = _objectPool.GetObjectFromPool(panelId);
// If we have one
if (panelInstance != null)
{
// If we should hide the previous panel, and we have one
if (behaviour == PanelShowBehaviour.HIDE_PREVIOUS && GetAmountPanelsInQueue() > 0)
{
// Get the last panel
var lastPanel = GetLastPanel();
// Disable it
lastPanel?.PanelInstance.SetActive(false);
}
// Add this new panel to the queue
_panelInstanceModels.Add(new PanelInstanceModel
{
PanelId = panelId,
PanelInstance = panelInstance
});
}
else
{
Debug.LogWarning($"Trying to use panelId = {panelId}, but this is not found in the ObjectPool");
}
}
public void HideLastPanel()
{
// Make sure we do have a panel showing
if (AnyPanelShowing())
{
// Get the last panel showing
var lastPanel = GetLastPanel();
// Remove it from the list of instances
_panelInstanceModels.Remove(lastPanel);
// Pool the object
_objectPool.PoolObject(lastPanel.PanelInstance);
// If we have more panels in the queue
if (GetAmountPanelsInQueue() > 0)
{
lastPanel = GetLastPanel();
if (lastPanel != null && !lastPanel.PanelInstance.activeInHierarchy)
{
lastPanel.PanelInstance.SetActive(true);
}
}
}
}
/// <summary>
/// Returns the last panel in the queue
/// </summary>
/// <returns>The last panel in the queue</returns>
PanelInstanceModel GetLastPanel()
{
return _panelInstanceModels[_panelInstanceModels.Count - 1];
}
/// <summary>
/// Returns if any panel is showing
/// </summary>
/// <returns>Do we have a panel showing?</returns>
public bool AnyPanelShowing()
{
return GetAmountPanelsInQueue() > 0;
}
/// <summary>
/// Returns how many panels we have in queue
/// </summary>
/// <returns>Amount of panels in queue</returns>
public int GetAmountPanelsInQueue()
{
return _panelInstanceModels.Count;
}
}

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

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

@ -0,0 +1,14 @@
using UnityEngine;
public class PanelInstanceModel
{
/// <summary>
/// The Id of the panel
/// </summary>
public string PanelId;
/// <summary>
/// The instance of the panel
/// </summary>
public GameObject PanelInstance;
}

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

Binary file not shown.

@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 031f4f1b86d89fe40b4a44a8fd258b2a
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Penakut
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

@ -1,9 +1,5 @@
sceneSetups: sceneSetups:
- path: Assets/Scenes/MainScene.unity - path: Assets/Scenes/map.unity
isLoaded: 1 isLoaded: 1
isActive: 1 isActive: 1
isSubScene: 0 isSubScene: 0
- path: Assets/PolygonHorrorMansion/Scenes/Demo_01.unity
isLoaded: 1
isActive: 0
isSubScene: 0

Binary file not shown.

@ -1 +1 @@
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"m_AlwaysRefresh":false,"showFog":true,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true,"showVisualEffectGraphs":true,"m_FxEnabled":true},"in2DMode":false,"pivot":{"x":-1.3285560607910157,"y":4.436185359954834,"z":-7.2717695236206059},"rotation":{"x":0.02800738997757435,"y":0.945084810256958,"z":-0.3145654499530792,"w":0.08414571732282639},"size":0.5124502182006836,"orthographic":false} {"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"m_AlwaysRefresh":false,"showFog":true,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true,"showVisualEffectGraphs":true,"m_FxEnabled":true},"in2DMode":false,"pivot":{"x":-4.309446334838867,"y":3.699798583984375,"z":40.984771728515628},"rotation":{"x":-0.19062255322933198,"y":0.7342864274978638,"z":-0.22955727577209474,"w":-0.6097459197044373},"size":7.224977493286133,"orthographic":false}

Binary file not shown.

@ -5,6 +5,12 @@ EditorUserSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 4 serializedVersion: 4
m_ConfigSettings: m_ConfigSettings:
RecentlyUsedSceneGuid-0:
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
flags: 0
RecentlyUsedSceneGuid-1:
value: 0150075704020c5f09575e2741740b44464f1c2c2f7a2263787d1b6bb0b7613c
flags: 0
RecentlyUsedScenePath-0: RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0 flags: 0
@ -22,9 +28,13 @@ EditorUserSettings:
m_VCDebugCmd: 0 m_VCDebugCmd: 0
m_VCDebugOut: 0 m_VCDebugOut: 0
m_SemanticMergeMode: 2 m_SemanticMergeMode: 2
m_DesiredImportWorkerCount: 3
m_StandbyImportWorkerCount: 2
m_IdleImportWorkerShutdownDelay: 60000
m_VCShowFailedCheckout: 1 m_VCShowFailedCheckout: 1
m_VCOverwriteFailedCheckoutAssets: 1 m_VCOverwriteFailedCheckoutAssets: 1
m_VCProjectOverlayIcons: 1 m_VCProjectOverlayIcons: 1
m_VCHierarchyOverlayIcons: 1 m_VCHierarchyOverlayIcons: 1
m_VCOtherOverlayIcons: 1 m_VCOtherOverlayIcons: 1
m_VCAllowAsyncUpdate: 1 m_VCAllowAsyncUpdate: 1
m_ArtifactGarbageCollection: 1

Loading…
Cancel
Save