Skip to content

Commit

Permalink
Added end to test and fixed ghost screws
Browse files Browse the repository at this point in the history
  • Loading branch information
Farid Abdul committed Apr 18, 2022
1 parent bc6cd32 commit ec011c2
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 170 deletions.
100 changes: 91 additions & 9 deletions Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ MonoBehaviour:
- {fileID: 1397897912}
assess: {fileID: 633945419}
assessResult: {fileID: 8138523}
assessResultEnd: {fileID: 1014375559}
tolerancePercent: 0.95
assessLimit: 3
--- !u!1 &645346707
Expand Down Expand Up @@ -1580,6 +1581,85 @@ Transform:
m_Father: {fileID: 898938220}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: -270, z: 0}
--- !u!1 &1014375557
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1014375558}
- component: {fileID: 1014375560}
- component: {fileID: 1014375559}
m_Layer: 5
m_Name: AssessResultEnd
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1014375558
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1014375557}
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: 1889595016}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 366.3, y: -73.5}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1014375559
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1014375557}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Test is complete. Please return to the menu.
--- !u!222 &1014375560
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1014375557}
m_CullTransparentMesh: 1
--- !u!1 &1023171448
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2616,13 +2696,14 @@ MonoBehaviour:
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_VerticalOverflow: 1
m_LineSpacing: 1.25
m_Text: "Camera Controls:\n\nHold right-click and move mouse to rotate camera\n\nScrew
controls:\n\nLeft-click on a screw to see the gizmo\nLeft-click and hold on any
end of the gizmo to move the screw\nWhile the gizmo is visible:\n\tPress 1 to
see the transformation gizmo\n\tPress 2 to see the rotation gizmo\n\nPress ?
to hide these instructions"
m_Text: "Once you position your screws, click \"Assess\".\nYou have 3 attempts
in total.\n\nCamera Controls:\n\nHold right-click and move mouse to rotate camera\nUse
the mouse wheel to zoom in and out\n\nScrew controls:\n\nLeft-click on a screw
to see the gizmo\nLeft-click and hold on any end of the gizmo to move the screw\nWhile
the gizmo is visible:\n\tPress 1 to see the transformation gizmo\n\tPress 2 to
see the rotation gizmo\n\nPress ? to hide these instructions"
--- !u!222 &1664625518
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2761,7 +2842,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
target: {fileID: 422988318}
distance: 10
distance: 43
xSpeed: 250
ySpeed: 120
yMinLimit: -20
Expand Down Expand Up @@ -3097,6 +3178,7 @@ RectTransform:
- {fileID: 8138522}
- {fileID: 1664625516}
- {fileID: 1144104335}
- {fileID: 1014375558}
m_Father: {fileID: 1756550908}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -3142,7 +3224,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1977395832
RectTransform:
m_ObjectHideFlags: 0
Expand All @@ -3161,7 +3243,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 147.19989, y: 122.5}
m_AnchoredPosition: {x: -400, y: 122.5}
m_SizeDelta: {x: 160, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1977395833
Expand Down
75 changes: 33 additions & 42 deletions Assets/Scripts/AssessScrew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class AssessScrew : MonoBehaviour

public Text assessResult;

public Text assessResultEnd;

public float tolerancePercent;

public int assessLimit = 3;
Expand Down Expand Up @@ -84,58 +86,47 @@ private List<float> BoundsContainedPercentage( GameObject real_screw, GameObject

void TaskOnClick()
{

//if (!StartGame.isPreTest)
//{
assessCounter += 1;
//}
// Write to assessResult.txt
StreamWriter writer = new StreamWriter("Assets/assessResult.csv", true);
if (StartGame.isPreTest)
{ writer.WriteLine("PRE-TEST" + ",,"); }
else
{ writer.WriteLine("POST-TEST" + ",,"); }
writer.WriteLine("Assessment #" + assessCounter + "," + "Tolerance at " + tolerancePercent + ",");
int correct_screws = 0;
foreach(GameObject screw in real_screws)
{
writer.WriteLine(screw.name + "," + "Translational Accuracy" + "," + "Rotational Accuracy");
foreach(GameObject g_screw in ghost_screws)
// Write to assessResult.txt
StreamWriter writer = new StreamWriter((Application.dataPath + "/assessResult.csv"), true);
Debug.Log("Wrote to" + Application.dataPath + "/assessResult.csv");
if (StartGame.isPreTest)
{ writer.WriteLine("PRE-TEST" + ",,"); }
else
{ writer.WriteLine("POST-TEST" + ",,"); }
writer.WriteLine("Assessment #" + assessCounter + "," + "Tolerance at " + tolerancePercent + ",");
int correct_screws = 0;
foreach(GameObject screw in real_screws)
{
if (checkScrewInPlace(screw,g_screw))
writer.WriteLine(screw.name + "," + "Translational Accuracy" + "," + "Rotational Accuracy");
foreach(GameObject g_screw in ghost_screws)
{
if ((BoundsContainedPercentage(screw, g_screw)[0] >= tolerancePercent) && (BoundsContainedPercentage(screw, g_screw)[1] >= tolerancePercent))
if (checkScrewInPlace(screw,g_screw))
{
Debug.Log(g_screw.name + "," + BoundsContainedPercentage(screw, g_screw)[0] + "," + BoundsContainedPercentage(screw, g_screw)[1]);
correct_screws += 1;
if ((BoundsContainedPercentage(screw, g_screw)[0] >= tolerancePercent) && (BoundsContainedPercentage(screw, g_screw)[1] >= tolerancePercent))
{
Debug.Log(g_screw.name + "," + BoundsContainedPercentage(screw, g_screw)[0] + "," + BoundsContainedPercentage(screw, g_screw)[1]);
correct_screws += 1;
}
assessResult.text = (correct_screws + " out of 3 screws are correctly placed");
writer.WriteLine(g_screw.name + "," + BoundsContainedPercentage(screw, g_screw)[0] + "," + BoundsContainedPercentage(screw, g_screw)[1]);
continue;
}
assessResult.text = (correct_screws + " out of 3 screws are correctly placed");
writer.WriteLine(g_screw.name + "," + BoundsContainedPercentage(screw, g_screw)[0] + "," + BoundsContainedPercentage(screw, g_screw)[1]);
continue;
}
assessResult.text = (correct_screws + " out of 3 screws are correctly placed");
writer.WriteLine(g_screw.name + "," + BoundsContainedPercentage(screw, g_screw)[0] + "," + BoundsContainedPercentage(screw, g_screw)[1]);
}
}
writer.WriteLine(correct_screws + " out of 3 screws are correctly placed" + "," + ",");
writer.Close();
// End write

if (!StartGame.isPreTest)
writer.WriteLine(correct_screws + " out of 3 screws are correctly placed" + "," + ",");
writer.Close();
// End write
if (assessCounter >= assessLimit)
{
if (assessCounter >= assessLimit)
if (!StartGame.isPreTest)
{
foreach (GameObject g_screw in ghost_screws) {
g_screw.GetComponentInChildren<Renderer>().enabled=true;
//g_screw.gameObject.SetActive( false );
}
}
}
}

// Update is called once per frame
void Update()
{

foreach (GameObject g_screw in ghost_screws) { g_screw.GetComponentInChildren<Renderer>().enabled=true; };
};
assess.gameObject.SetActive(false);
assessResultEnd.gameObject.SetActive(true);
};
}
}
105 changes: 0 additions & 105 deletions Assets/assessResult.csv

This file was deleted.

7 changes: 0 additions & 7 deletions Assets/assessResult.csv.meta

This file was deleted.

7 changes: 0 additions & 7 deletions Assets/assessResult.txt.meta

This file was deleted.

0 comments on commit ec011c2

Please sign in to comment.