Esempio n. 1
0
        // =================================================================================
        // DISPLAY OPTION PANEL
        // ---------------------------------------------------------------------------------
        void General()
        {
            // -- Label column --
            var pos = GetLabelColumnPositions(6);

            GUI.Label(pos[0], "Type Name");
            GUI.Label(pos[2], "Is Editor Script");
            GUI.Label(pos[3], "Base Type Name");
            EditorGUI.BeginDisabledGroup(true);
            GUI.Label(pos[5], "Namespace");
            EditorGUI.EndDisabledGroup();

            // -- Value column --
            pos = GetValueColumnPositions(6);
            iStorage.TypeName = EditorGUI.TextField(pos[0], iStorage.TypeName);
            var savedGuiChanged = GUI.changed;

            GUI.changed             = false;
            iStorage.IsEditorScript = EditorGUI.Toggle(pos[2], iStorage.IsEditorScript);
            if (GUI.changed)
            {
                UpdateEditorScriptOption();
            }
            GUI.changed      |= savedGuiChanged;
            iStorage.BaseType = EditorGUI.TextField(pos[3], iStorage.BaseType);
            GUI.Label(pos[4], "<i>(format: namespace.type)</i>");
            EditorGUI.BeginDisabledGroup(true);
            EditorGUI.TextField(pos[5], iStorage.Namespace);
            EditorGUI.EndDisabledGroup();

            // -- Reset button --
            if (GUI.Button(new Rect(kColumn2X + kMargin, position.height - kMargin - 20.0f, 0.75f * kColumn2Width, 20.0f), "Use Defaults"))
            {
                iStorage.TypeName       = iStorage.EditorObjects[0].CodeName;
                iStorage.IsEditorScript = false;
                iStorage.BaseType       = CodeGenerationUtility.DefaultEngineBaseTypeString;
            }

            // -- Save changes --
            if (GUI.changed)
            {
                iStorage.SaveStorage();
            }

            // -- Validate user entries --
            var message = Sanity.ValidateVisualScriptBaseType(iStorage);

            if (message != null)
            {
                DisplayError(pos[4], message);
                return;
            }
            message = Sanity.ValidateVisualScriptTypeName(iStorage, /*shortFormat=*/ true);
            if (message != null)
            {
                DisplayError(pos[0], message);
                return;
            }
        }
Esempio n. 2
0
        // ----------------------------------------------------------------------
        /// Ask each object to perform their own sanity check.
        public void SanityCheck()
        {
            // -- Don't perform sanity check on transient data --
            if (!LibraryController.IsLibraryLoaded)
            {
                return;
            }
            if (!IsRootObjectAType)
            {
                return;
            }

            // -- Validate user inputs --
            var kSanityCheckServiceKey = "SanityCheck";

            ErrorController.Clear(kSanityCheckServiceKey);

            // -- Validate visual script type name --
            var message = Sanity.ValidateVisualScriptTypeName(this);

            if (message != null)
            {
                ErrorController.AddError(kSanityCheckServiceKey, message, VisualScript, 0);
            }

            // -- Validate CSharpFileName --
            if (CSharpFileName != TypeName)
            {
                message = "CSharp file name: <b><color=red>" + CSharpFileName + "</color></b> doesn't match the type name: <b><color=red>" + TypeName + "</color></b>";
            }

            // -- Verify base types --
            message = Sanity.ValidateVisualScriptBaseType(this);
            if (message != null)
            {
                ErrorController.AddError(kSanityCheckServiceKey, message, VisualScript, 0);
            }

            // -- Ask each object to perform their own sanity check --
            ForEach(o => o.SanityCheck(kSanityCheckServiceKey));
        }