/// <summary>
        /// Checks if the num of output features differ from what we last know to show warnings
        /// </summary>
        private void CheckOutputFeaturesChanges()
        {
            // Get current number of input features
            TrainingExamplesNode trainingExamplesNode = target as TrainingExamplesNode;
            int currentNumFeatures = trainingExamplesNode.DesiredOutputsConfig.Count;

            // Show debug info
            //EditorGUILayout.LabelField("LastKnownOutputFeatures: " + m_LastKnownNumOutputFeatures);

            // Style for warning box
            GUIStyle tableStyle = new GUIStyle("box");

            tableStyle.padding     = new RectOffset(24, 10, 10, 10);
            tableStyle.margin.left = 10;


            // If we have no knowledge of output features
            if (m_LastKnownNumOutputFeatures == 0)
            {
                m_LastKnownNumOutputFeatures = currentNumFeatures;
            }
            // Warning for feature removed
            else if (currentNumFeatures < m_LastKnownNumOutputFeatures)
            {
                EditorGUILayout.BeginVertical(tableStyle);
                EditorGUILayout.HelpBox("Deleting a Input/Output Feature deletes all the data recorded with it in all the Examples in this node!", MessageType.Warning);
                if (GUILayout.Button("Undo Action"))
                {
                    m_LastKnownNumOutputFeatures = currentNumFeatures;
                }
                EditorGUILayout.EndVertical();
            }
            // Warning for feature added
            else if (currentNumFeatures > m_LastKnownNumOutputFeatures)
            {
                EditorGUILayout.BeginVertical(tableStyle);
                EditorGUILayout.HelpBox("Adding a new Output Feature deletes all the previous Examples recorded in this node.", MessageType.Warning);
                if (GUILayout.Button("Undo Action"))
                {
                    m_LastKnownNumOutputFeatures = currentNumFeatures;
                }
                EditorGUILayout.EndVertical();
            }
            // If there is no change performed
            else
            {
                // Update value of lasknown input features
                m_LastKnownNumOutputFeatures = currentNumFeatures;
            }
        }
        public override void OnBodyGUI()
        {
            // Override label width for this node (since some names are quite long)
            LabelWidth = 184;

            base.OnBodyGUI();

            // Get reference to the current node
            m_TrainingExamplesNode = (target as TrainingExamplesNode);

            // TOTAL NUMBER OF TRAINING EXAMPLES
            ShowTotalNumberOfTrainingData();

            // DESIRED OUTPUT CONFIG AND BUILD OUTPUT LIST
            EditorGUILayout.Space();
            ShowDesiredOutputFeaturesLogic();
            EditorGUILayout.Space();

            // RECORD EXAMPLES BUTTON
            ShowRecordExamplesButton();

            // RECORD ONE SINGLE EXAMPLE BUTTON
            ShowRecordOneExampleButton();

            // CLEAR ALL TRAINING EXAMPLES BUTTON
            ShowClearAllExamplesButton();

            // Debug buttons loading stuff
            if (GUILayout.Button("Load All Data From Disk"))
            {
                m_TrainingExamplesNode.LoadDataFromDisk();
            }

            // WARNINGS IF FEATURES CHANGE
            CheckInputFeaturesChanges();
            CheckOutputFeaturesChanges();

            // TRAINING DATA DROPDOWN
            ShowDataDropdown();

            // Error with output configuration
            var nodeTraining = target as TrainingExamplesNode;

            if (nodeTraining.DesiredOutputsConfig.Count == 0)
            {
                EditorGUILayout.HelpBox("There are no Desired Outputs Configured!", MessageType.Error);
            }
        }
Exemplo n.º 3
0
        // Return the correct value of an output port when requested
        public override object GetValue(NodePort port)
        {
            TrainingExamplesNodeToOutput = this;

            return(this);
        }
        public override void OnBodyGUI()
        {
            // Override label width for this node (since some names are quite long)
            LabelWidth = 184;

            base.OnBodyGUI();

            // Get reference to the current node
            m_TrainingExamplesNode = (target as TrainingExamplesNode);

            // SHOW KEYBOARD SHORTCUTS
            // Show information about runtime keys for interaction
            GUIStyle styleGUIBox = new GUIStyle(GUI.skin.box);

            styleGUIBox.richText = true;
            if (m_TrainingExamplesNode.EnableKeyboardControl)
            {
                GUILayout.Box("<b>Keyboard Shortcuts:</b>\n <b>Record:</b> " + m_TrainingExamplesNode.RecordDataKey.ToString(),
                              styleGUIBox);

                // Show key configs
                m_TrainingExamplesNode.RecordDataKey = (KeyCode)EditorGUILayout.EnumFlagsField(m_TrainingExamplesNode.RecordDataKey);
                EditorGUILayout.Space();
            }



            // SHOW INPUT CONFIG
            ShowDesiredInputsConfigLogic();
            EditorGUILayout.Space();

            // SHOW OUTPUT CONFIG
            ShowDesiredOutputsConfigLogic();
            EditorGUILayout.Space();

            // TOTAL NUMBER OF TRAINING EXAMPLES
            ShowTotalNumberOfTrainingData();

            // DESIRED OUTPUT CONFIG AND BUILD OUTPUT LIST
            EditorGUILayout.Space();
            ShowDesiredOutputFeaturesLogic();
            EditorGUILayout.Space();

            // RECORD EXAMPLES BUTTON
            ShowRecordExamplesButton();

            // RECORD ONE SINGLE EXAMPLE BUTTON
            ShowRecordOneExampleButton();

            // CLEAR ALL TRAINING EXAMPLES BUTTON
            ShowClearAllExamplesButton();

            // Debug buttons loading stuff
            if (GUILayout.Button("Load All Data From Disk"))
            {
                m_TrainingExamplesNode.LoadDataFromDisk();
            }

            // WARNINGS IF FEATURES CHANGE
            CheckInputFeaturesChanges();
            CheckOutputFeaturesChanges();

            // TRAINING DATA DROPDOWN
            ShowDataDropdown();

            // Error with output configuration
            var nodeTraining = target as TrainingExamplesNode;

            if (nodeTraining.DesiredOutputsConfig.Count == 0)
            {
                EditorGUILayout.HelpBox("There are no Desired Outputs Configured!", MessageType.Error);
            }
        }