Skip to content

Commit

Permalink
Timeline control debug finished
Browse files Browse the repository at this point in the history
  • Loading branch information
syKevinPeng committed May 1, 2024
1 parent 7579d84 commit ad039ec
Show file tree
Hide file tree
Showing 11 changed files with 1,311 additions and 1,299 deletions.
2,415 changes: 1,207 additions & 1,208 deletions Assets/Scenes/IllusionInMotionScene.unity

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Assets/Scenes/IllusionStationaryScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1730757804}
m_TargetAssemblyTypeName: ConfirmButton, Assembly-CSharp
m_TargetAssemblyTypeName: IllusionCanvasController, Assembly-CSharp
m_MethodName: OnClick
m_Mode: 1
m_Arguments:
Expand Down Expand Up @@ -2995,7 +2995,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1730757802}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 60a8b034a26e6be448a9b16fe42ba59a, type: 3}
m_Script: {fileID: 11500000, guid: 5343f8c38f918834397311e61ab51713, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1730757805
Expand Down
41 changes: 17 additions & 24 deletions Assets/Scenes/WelcomeScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ GameObject:
- component: {fileID: 103826310}
- component: {fileID: 103826309}
- component: {fileID: 103826315}
- component: {fileID: 103826316}
m_Layer: 0
m_Name: Menu Canvas
m_Name: MenuCanvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -312,6 +313,18 @@ MonoBehaviour:
m_BlockingMask:
serializedVersion: 2
m_Bits: 31
--- !u!114 &103826316
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 103826307}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 379534438f1ffa94d89d074b27a9c41e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &168893614
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1002,7 +1015,6 @@ GameObject:
m_Component:
- component: {fileID: 442574397}
- component: {fileID: 442574398}
- component: {fileID: 442574399}
m_Layer: 0
m_Name: BtnInteractable
m_TagString: Untagged
Expand Down Expand Up @@ -1068,25 +1080,6 @@ MonoBehaviour:
_whenSelectingInteractorViewRemoved:
m_PersistentCalls:
m_Calls: []
--- !u!114 &442574399
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 442574396}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 379534438f1ffa94d89d074b27a9c41e, type: 3}
m_Name:
m_EditorClassIdentifier:
WelcomePage: {fileID: 652691016}
BeforeStartedPage: {fileID: 1040491324}
InstructionPage: {fileID: 1088801427}
NxtButton: {fileID: 1676848792}
BSPCheckBox1: {fileID: 982628364}
BSPCheckBox2: {fileID: 607923300}
BSPCheckBox3: {fileID: 232063225}
--- !u!1 &458760245
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -4475,7 +4468,7 @@ GameObject:
- component: {fileID: 1676848792}
- component: {fileID: 1676848795}
m_Layer: 0
m_Name: NextBtn
m_Name: NextButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -4546,8 +4539,8 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 442574399}
m_TargetAssemblyTypeName: NextBtnController, Assembly-CSharp
- m_Target: {fileID: 103826316}
m_TargetAssemblyTypeName: WelcomeCanvasController, Assembly-CSharp
m_MethodName: NextBtnClick
m_Mode: 1
m_Arguments:
Expand Down
28 changes: 0 additions & 28 deletions Assets/Scripts/ConfirmButton.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Scripts/ConfirmButton.cs.meta

This file was deleted.

15 changes: 14 additions & 1 deletion Assets/Scripts/IllusionCanvasController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
using UnityEngine.UI;
// This class is used to manage the controller of your VR equipment


Expand All @@ -14,7 +15,7 @@ public class IllusionCanvasController : MonoBehaviour
private GameObject Slider;
private GameObject UpButton;
private GameObject DownButton;
public float stepSize = 0.1f;
private GameObject ConfirmButton;

// Start is called before the first frame update
void GetIncreaseButtonPressed()
Expand Down Expand Up @@ -83,6 +84,17 @@ private float GetMaxRatio()
return RawImage.GetComponent<IllusionPatternLoader>().GetMaxRatio();
}

public void OnClick()
{
Debug.Log("Confirm Button Clicked");
abstractIllusionPattern NextPattern = RawImage.GetComponent<IllusionPatternLoader>().GetNextPattern();
if (NextPattern == null)
{
Debug.Log("No More Patterns. Moving to the next scene.");
GameObject.Find("TimelineController").GetComponent<TimelineController>().GetNextScene();
}

}



Expand All @@ -92,6 +104,7 @@ void Start()
UpButton = GameObject.Find("UpButton");
DownButton = GameObject.Find("DownButton");
Slider = GameObject.Find("Slider");
ConfirmButton = GameObject.Find("ConfirmButton");
Debug.Log("Current Ratio: " + GetCurrentRatio() + " Init Ratio: " + GetInitRatio());
// Config the slider
Slider.GetComponent<UnityEngine.UI.Slider>().maxValue = GetMaxRatio();
Expand Down
24 changes: 21 additions & 3 deletions Assets/Scripts/IllusionPatternLoader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using UnityEngine;
// This class is used to load a collection of illusion patterns

Expand All @@ -8,19 +9,36 @@ public class IllusionPatternLoader : MonoBehaviour
// a list of all the patterns
public List<abstractIllusionPattern> allPatterns = new List<abstractIllusionPattern>();
public abstractIllusionPattern currentPattern;
public GameObject RawImage;
private GameObject RawImage;

void Start()
{
RawImage = GameObject.Find("RawImage");
RawImage = GameObject.Find("IllusionCanvas").transform.Find("Canvas").transform.Find("RawImage").gameObject;

abstractIllusionPattern ouchiLength = new ouchiLength(stepSize: 0.1f);
abstractIllusionPattern ouchiColor = new ouchiColor(stepSize: 0.04f);

allPatterns.Add(ouchiLength);
allPatterns.Add(ouchiColor);

currentPattern = ouchiColor;
currentPattern = ouchiLength;
Debug.Log(" === Loading " + currentPattern + " === ");
}

public abstractIllusionPattern GetNextPattern()
{
int index = allPatterns.IndexOf(currentPattern);
if (index == allPatterns.Count - 1)
{
return null;
}
else
{
index++;
}
currentPattern = allPatterns[index];
Debug.Log(" === Loading" + currentPattern + " === ");
return currentPattern;
}

public void IncreasePatternRatio()
Expand Down
24 changes: 17 additions & 7 deletions Assets/Scripts/TimelineController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public class TimelineController : MonoBehaviour
private float startTime;
private int UID;
// Start is called before the first frame update
private Boolean isStationaryLoaded = false;
private Boolean isMovingLoaded = false;
public static Boolean isStationaryLoaded = false;
public static Boolean isMovingLoaded = false;
private GameObject timeline;

private void LoadStationaryScene()
{
Scene stationaryscene = SceneManager.GetSceneByBuildIndex(1);
SceneManager.LoadScene("IllusionStationaryScene");

}
Expand All @@ -35,7 +37,10 @@ IEnumerator LoadAsyncScene()

private void LoadMovingScene()
{
Scene motionscene = SceneManager.GetSceneByBuildIndex(2);
StartCoroutine(LoadAsyncScene());


}
private Boolean isMovingSceneLoaded()
{
Expand All @@ -50,35 +55,38 @@ public void GetNextScene()
{
// if both scenes are not loaded, randomly load one of them
if (UnityEngine.Random.Range(0, 2) == 0)
// if (false)
{
Debug.Log("Loading stationary scene");
Debug.Log(" === Loading stationary scene === ");
LoadStationaryScene();
isStationaryLoaded = true;
}
else
{
Debug.Log("Loading moving scene");
Debug.Log(" === Loading moving scene === ");
LoadMovingScene();
isMovingLoaded = true;
}
}
else if (isStationaryLoaded && !isMovingLoaded)
{
Debug.Log("Loading moving scene");
Debug.Log(" === Then Loading moving scene === ");
LoadMovingScene();
isMovingLoaded = true;

}
else if (!isStationaryLoaded && isMovingLoaded)
{
Debug.Log("Loading stationary scene");
Debug.Log(" === Then Loading stationary scene === ");
LoadStationaryScene();
isStationaryLoaded = true;
}
else
{
Debug.Log("Expereinment is over, both scenes are loaded.");
Debug.Log(" == Total Time: " + (Time.time - startTime) + " == ");
// quit the application
Application.Quit();
}

}
Expand All @@ -91,7 +99,9 @@ void Start()
{
Debug.Log(" == UID: " + UID + " == ");
}

timeline = GameObject.Find("TimelineController");
// check if this object is don't destroy on load
DontDestroyOnLoad(this.gameObject);

}

Expand Down
46 changes: 33 additions & 13 deletions Assets/Scripts/WelcomeCanvasController.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using Oculus.Interaction;
using UnityEditor;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class NextBtnController : MonoBehaviour
public class WelcomeCanvasController : MonoBehaviour
{
public GameObject WelcomePage;
public GameObject BeforeStartedPage;
public GameObject InstructionPage;
private GameObject MenuCanvas;
private GameObject WelcomePage;
private GameObject BeforeStartedPage;
private GameObject InstructionPage;
private GameObject currentPage;
public Button NxtButton;
// public InteractableUnityEventWrapper interactableUnityEventWrapper;

public Toggle BSPCheckBox1;
public Toggle BSPCheckBox2;
public Toggle BSPCheckBox3;
private GameObject NxtButton;
private Toggle BSPCheckBox1;
private Toggle BSPCheckBox2;
private Toggle BSPCheckBox3;
private GameObject TimelineController;
public void NextBtnClick()
{
Expand All @@ -38,8 +38,8 @@ public void NextBtnClick()
{
TimelineController.GetComponent<TimelineController>().GetNextScene();
}

NxtButton.interactable = false; // avoid double click
NxtButton.GetComponent<Button>().interactable = false; // avoid double click
// NxtButton.interactable = false; // avoid double click
}

public void WhenHover()
Expand All @@ -57,7 +57,27 @@ public void WhenUnhover()

void Start()
{
MenuCanvas = GameObject.Find("MenuCanvas");
WelcomePage = MenuCanvas.transform.Find("WelcomePage").gameObject;
BeforeStartedPage = MenuCanvas.transform.Find("BeforeStartedPage").gameObject;
InstructionPage = MenuCanvas.transform.Find("InstructionPage").gameObject;

TimelineController = GameObject.Find("TimelineController");
DontDestroyOnLoad(GameObject.Find("TimelineController"));
NxtButton = MenuCanvas.transform.Find("BtnInteractable").transform.Find("NextButton").gameObject;
BSPCheckBox1 = BeforeStartedPage.transform.Find("ckbox1").GetComponent<Toggle>();
BSPCheckBox2 = BeforeStartedPage.transform.Find("ckbox2").GetComponent<Toggle>();
BSPCheckBox3 = BeforeStartedPage.transform.Find("ckbox3").GetComponent<Toggle>();

Assert.IsNotNull(MenuCanvas, "MenuCanvas is not found");
Assert.IsNotNull(WelcomePage, "WelcomePage is not found");
Assert.IsNotNull(BeforeStartedPage, "BeforeStartedPage is not found");
Assert.IsNotNull(InstructionPage, "InstructionPage is not found");
Assert.IsNotNull(NxtButton, "Next Button is not found");
Assert.IsNotNull(BSPCheckBox1, "CheckBox1 is not found");
Assert.IsNotNull(BSPCheckBox2, "CheckBox2 is not found");
Assert.IsNotNull(BSPCheckBox3, "CheckBox3 is not found");



if (WelcomePage == null)
Expand Down Expand Up @@ -96,7 +116,7 @@ void Start()
// Update is called once per frame
void Update()
{
NxtButton.interactable = currentPage != BeforeStartedPage || (BSPCheckBox1.isOn && BSPCheckBox2.isOn && BSPCheckBox3.isOn);
NxtButton.GetComponent<Button>().interactable = currentPage != BeforeStartedPage || (BSPCheckBox1.isOn && BSPCheckBox2.isOn && BSPCheckBox3.isOn);


}
Expand Down
Loading

0 comments on commit ad039ec

Please sign in to comment.