Skip to content

Commit

Permalink
#4 #7 Loading scene is a go
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisas committed Mar 22, 2017
1 parent 999bdcc commit 6eca3eb
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ AnimatorOverrideController:
m_PrefabInternal: {fileID: 0}
m_Name: Loading Scene
m_Controller: {fileID: 9100000, guid: 1f4b1a8955bd64c4f99e873b0c32e433, type: 2}
m_Clips: []
m_Clips:
- m_OriginalClip: {fileID: 7400000, guid: 7e558b103ab7d8b4d99c781389a4d1b5, type: 2}
m_OverrideClip: {fileID: 7400000, guid: bf8f3efbb06b87b4c927c2793a3e02ce, type: 2}
- m_OriginalClip: {fileID: 7400000, guid: e0a4337f077bc3f42aa77e56f8fdf246, type: 2}
m_OverrideClip: {fileID: 7400000, guid: e0a4337f077bc3f42aa77e56f8fdf246, type: 2}
2 changes: 1 addition & 1 deletion Assets/Animations/UI/LoadingSceneFadeIn.anim
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
Expand Down
111 changes: 111 additions & 0 deletions Assets/Animations/UI/LoadingSceneFadeOut.anim
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: LoadingSceneFadeOut
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path: RawImage
classID: 114
script: {fileID: -98529514, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- path: 2333707708
attribute: 304273561
script: {fileID: -98529514, guid: f70555f144d8491a825f0804e09c671c, type: 3}
classID: 114
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
- serializedVersion: 2
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path: RawImage
classID: 114
script: {fileID: -98529514, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_IsEmpty: 0
m_Events:
- time: 0.9166667
functionName: LoadScene
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
8 changes: 8 additions & 0 deletions Assets/Animations/UI/LoadingSceneFadeOut.anim.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Assets/LoadingScene.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class LoadingScene : MonoBehaviour {
Expand All @@ -11,10 +12,35 @@ public class LoadingScene : MonoBehaviour {
public Animator m_CanvasAnimator;
public Image m_ImageToChange;
public Sprite[] m_BillboardImages;
public float posterDisplayTime;

private float timer;
private bool fading = false;

// Use this for initialization
void Start () {
m_CanvasAnimator.SetTrigger("fadeIn");
m_ImageToChange.sprite = m_BillboardImages[m_ImageToLoad];
timer = posterDisplayTime;
}

private void Update()
{
timer -= Time.deltaTime;

if(timer <= 0 && !fading)
{
fading = true;
m_CanvasAnimator.SetTrigger("fadeOut");
}
}

public void LoadScene()
{
#if NETWORKING
UnityEngine.Networking.NetworkManager.singleton.ServerChangeScene(m_SceneToLoad);
#else
SceneManager.LoadScene(m_SceneToLoad);
#endif
}
}
71 changes: 22 additions & 49 deletions Assets/Scene/Menus/LoadingScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &531512833
GameObject:
Expand Down Expand Up @@ -241,52 +241,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &694769875
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 694769877}
- component: {fileID: 694769876}
m_Layer: 0
m_Name: Loading Scene Controller
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &694769876
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 694769875}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7e12eb12bcd01d9468037cfaeae5ab59, type: 3}
m_Name:
m_EditorClassIdentifier:
m_CanvasAnimator: {fileID: 1281708303}
m_ImageToChange: {fileID: 701143538}
m_BillboardImages:
- {fileID: 21300000, guid: ab83aa95e53179543b2c0a294ee98d93, type: 3}
- {fileID: 21300000, guid: fdf6090c929e53341ac3f01c81212e46, type: 3}
- {fileID: 21300000, guid: ea6dd28037c363647837f95ad549c28e, type: 3}
--- !u!4 &694769877
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 694769875}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -8.545807, y: 5.1290665, z: -12.035431}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &701143536
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -434,8 +388,9 @@ GameObject:
- component: {fileID: 1281708300}
- component: {fileID: 1281708299}
- component: {fileID: 1281708303}
- component: {fileID: 1281708304}
m_Layer: 5
m_Name: Canvas
m_Name: Loading Scene Controller
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -510,7 +465,7 @@ RectTransform:
- {fileID: 701143537}
- {fileID: 725541642}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand All @@ -534,6 +489,24 @@ Animator:
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
--- !u!114 &1281708304
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1281708298}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7e12eb12bcd01d9468037cfaeae5ab59, type: 3}
m_Name:
m_EditorClassIdentifier:
m_CanvasAnimator: {fileID: 1281708303}
m_ImageToChange: {fileID: 701143538}
m_BillboardImages:
- {fileID: 21300000, guid: ab83aa95e53179543b2c0a294ee98d93, type: 3}
- {fileID: 21300000, guid: fdf6090c929e53341ac3f01c81212e46, type: 3}
- {fileID: 21300000, guid: ea6dd28037c363647837f95ad549c28e, type: 3}
posterDisplayTime: 3
--- !u!1 &1443793798
GameObject:
m_ObjectHideFlags: 0
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Utility/SceneSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ public void LoadScene()
{
LoadingScene.m_ImageToLoad = m_TutorialPosterIndex;
#if NETWORKING
UnityEngine.Networking.NetworkManager.singleton.ServerChangeScene(m_SceneToLoad);
LoadingScene.m_SceneToLoad = m_SceneToLoad;
UnityEngine.Networking.NetworkManager.singleton.ServerChangeScene("LoadingScreen");
#else
SceneManager.LoadScene(m_SceneToLoad);
LoadingScene.m_SceneToLoad = m_SceneToLoad;
SceneManager.LoadScene("LoadingScene");
#endif
}
}

0 comments on commit 6eca3eb

Please sign in to comment.