@@ -47,25 +47,28 @@ public class UIController : MonoBehaviour
4747 public Dropdown exs ;
4848 public Button savedata , newex , saveex , deleteex ;
4949 public Text startstoptext , pauseresumetext , version ;
50+
51+ // The managers for the panels on the Scene
5052 public NetManager netmanager ;
5153 public ExperimentManager exmanager ;
5254 public AnalysisManager alsmanager ;
53- public ControlManager ctrlmanager ;
54- public ControlPanel controlpanel ;
55+ public ControlManager ctrlmanager ;
56+
57+ // The Panels Physically created on the scene
58+ public ControlPanel controlpanel ;
5559 public ExperimentPanel expanel ;
5660 public EnvironmentPanel envpanel ;
5761 public ViewPanel viewpanel ;
5862 public ConsolePanel consolepanel ;
5963 public ConditionPanel condpanel ;
6064 public ConditionTestPanel ctpanel ;
6165
62- /* Awake() -----------------------------------------------------------------------------
63- Description: Awake is called when the script instance is being loaded. Awake is called only
64- a single time. See the following URL for more information:
65- https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html
66-
67- Loads a configmanger object from the configmanager path, then loads the config object.
68- ----------------------------------------------------------------------------------------*/
66+ /// <summary>
67+ /// Awake is called when the script instance is being loaded. Awake is called only
68+ /// a single time.See the following URL for more information:
69+ /// https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html
70+ /// Loads a configmanger object from the configmanager path variable, then loads the config object.
71+ /// </summary>
6972 void Awake ( )
7073 {
7174 // Check for CommandConfigManager.yaml existance
@@ -85,23 +88,25 @@ void Awake()
8588 }
8689 }
8790
88- /* LoadConfig() -----------------------------------------------------------------------------
89- Description: Loads in and returns a CommandConfig object from configfilepath. Creates A new
90- config object if it can't be loaded
91-
92- Parameters:
93- configfilepath - The config file path to the CommandConfig object
94- otherwisedefault - create a new CommandConfig object to use instead.
95- ----------------------------------------------------------------------------------------*/
91+ /// <summary>
92+ /// Loads in and returns a CommandConfig object from configfilepath. Creates A new
93+ /// config object if it can't be loaded
94+ /// </summary>
95+ /// <param name="configfilepath">The config file path to the CommandConfig object</param>
96+ /// <param name="otherwisedefault">create a new CommandConfig object to use instead.</param>
97+ /// <returns>The loaded/deault CommandConfig object</returns>
9698 public CommandConfig LoadConfig ( string configfilepath , bool otherwisedefault = true )
9799 {
98100 CommandConfig cfg = null ;
99101
100102 // Check if the file exists at the specified path, if so, load it.
101103 if ( File . Exists ( configfilepath ) )
102104 {
105+ // Deserialize the text using extension method.
103106 cfg = configfilepath . ReadYamlFile < CommandConfig > ( ) ;
104107 }
108+
109+ // Use default config settings
105110 if ( cfg == null )
106111 {
107112 configmanager . LastConfigFilePath = null ;
@@ -154,6 +159,12 @@ public static Dictionary<string, Dictionary<string, List<string>>> ValidateEnvCr
154159 return rule ;
155160 }
156161
162+ /// <summary>
163+ /// Sets the version number and starts the application.
164+ /// Start is called on the frame when a script is enabled just before any of the
165+ /// Update methods are called the first time.See the URL below for more information:
166+ /// https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html
167+ /// </summary>
157168 void Start ( )
158169 {
159170 version . text = $ "Version { Application . version } \n Unity { Application . unityVersion } ";
@@ -162,6 +173,7 @@ void Start()
162173
163174 public void PushConfig ( )
164175 {
176+ // Grab settings from Experiement Yaml files, and update the scene
165177 exmanager . GetExFiles ( ) ;
166178 UpdateExDropdown ( ) ;
167179 savedata . interactable = ! config . AutoSaveData ;
@@ -294,6 +306,11 @@ public void OnAspectRatioMessage(float ratio)
294306 exmanager . el . envmanager . SetParam ( "ScreenAspect" , ratio , true ) ;
295307 }
296308
309+ /// <summary>
310+ /// Called on the server when a scene is completed loaded, when the scene load was
311+ /// initiated by the server with ServerChangeScene().
312+ /// </summary>
313+ /// <param name="sceneName">The scene that changed</param>
297314 public void OnServerSceneChanged ( string sceneName )
298315 {
299316 exmanager . PrepareEnv ( sceneName ) ;
@@ -514,7 +531,13 @@ public void ToggleExInherit(string name, bool isinherit)
514531 }
515532 }
516533 }
517-
534+
535+ /// <summary>
536+ ///
537+ /// </summary>
538+ /// <param name="fullname"></param>
539+ /// <param name="paramname"></param>
540+ /// <param name="isinherit"></param>
518541 public void ToggleEnvInherit ( string fullname , string paramname , bool isinherit )
519542 {
520543 var ip = exmanager . el . ex . EnvInheritParam ;
@@ -544,16 +567,26 @@ public void ToggleEnvInherit(string fullname, string paramname, bool isinherit)
544567 }
545568 }
546569
570+ /// <summary>
571+ /// Function called for when the 'Save' button in the Control panel is pressed.
572+ /// </summary>
547573 public void SaveEx ( )
548574 {
549575 exmanager . SaveEx ( exs . captionText . text ) ;
550576 }
551577
578+ /// <summary>
579+ /// Script for when the 'X' button in the Control panel is clicked to delete an experiment
580+ /// </summary>
552581 public void DeleteEx ( )
553582 {
583+ // Delete the file
554584 var i = exmanager . DeleteEx ( exs . captionText . text ) ;
585+
586+ // If sucessfully deleted
555587 if ( i >= 0 )
556588 {
589+ // Remove option from dropdown and update dropdown
557590 exs . options . RemoveAt ( i ) ;
558591 var exn = exs . options . Count ;
559592 if ( exn > 0 )
@@ -571,46 +604,67 @@ public void DeleteEx()
571604 }
572605 }
573606
607+ /// <summary>
608+ /// This function is called when 'Host' button in Control Panel is pressed. Signals
609+ /// to the network manager to start hosting.
610+ /// </summary>
611+ /// <param name="ison">True when the toggle is now down, else false</param>
574612 public void ToggleHost ( bool ison )
575613 {
614+ // Toggle is now down / on
576615 if ( ison )
577616 {
617+ // Start hosting. Host is both a server and client in one.
578618 netmanager . StartHost ( ) ;
579619 ChangeScene ( ) ;
580620 }
621+ // Toggle is now unpressed / off
581622 else
582623 {
624+ // When there was an experiment running, stop the experiment
583625 if ( start . isOn )
584626 {
585627 ToggleStartStopExperiment ( false ) ;
586628 start . isOn = false ;
587629 }
630+ // Quit hosting
588631 netmanager . StopHost ( ) ;
589632 }
633+ // Turn server button active, and start button inactive
590634 server . interactable = ! ison ;
591635 start . interactable = ison ;
592636 }
593637
638+ /// <summary>
639+ /// This function is called when 'Server' button in Control Panel is pressed. Signals
640+ /// to the network manager to start up a server.
641+ /// </summary>
642+ /// <param name="ison">True when the toggle is now down, else false</param>
594643 public void ToggleServer ( bool ison )
595644 {
645+ // Toggle is now down / on
596646 if ( ison )
597647 {
598648 netmanager . StartServer ( ) ;
599649 ChangeScene ( ) ;
600650 }
651+ // Toggle is now up / off
601652 else
602653 {
654+ // Stop an experiment if there is one, and stop the server
603655 if ( start . isOn )
604656 {
605657 ToggleStartStopExperiment ( false ) ;
606658 start . isOn = false ;
607659 }
608660 netmanager . StopServer ( ) ;
609661 }
662+ // host button is interactable, start button isn't
610663 host . interactable = ! ison ;
611664 start . interactable = ison ;
612665 }
613666
667+
614668 public void ChangeScene ( )
615669 {
616670 if ( exmanager . el != null )
@@ -623,6 +677,7 @@ public void ChangeScene()
623677 }
624678 if ( NetworkServer . active )
625679 {
680+ // causes the server to switch scenes to the specified scene
626681 netmanager . ServerChangeScene ( scene ) ;
627682 }
628683 }
0 commit comments