/// <summary> 
        /// Draw the variables of a blackboard in the GUI.
        /// <param name="position">The position in the GUI to draw the variables.</param>
        /// <param name="blackboard">The blackboard to be drawn.</param>
        /// </summary>
        public static void DrawVariables (Rect position, InternalBlackboard blackboard) {
            if (blackboard == null)
                return;

            // Create styles
            if (s_Styles == null)
                s_Styles = new BlackboardGUIUtility.Styles();

            // Update variable to remove
            s_VariableToRemove = null;

            // Is asset?
            bool isAsset = AssetDatabase.Contains(blackboard.gameObject);

            // Save GUI.changed
            EditorGUI.BeginChangeCheck();

            // FloatVar
            position.height = c_OneLineHeight;
            foreach (var floatVar in blackboard.floatVars) {
                DrawFloatVar(position, floatVar);
                position.y += position.height;
            }
            // IntVar
            foreach (var intVar in blackboard.intVars) {
                DrawIntVar(position, intVar);
                position.y += position.height;
            }
            // BoolVar
            foreach (var boolVar in blackboard.boolVars) {
                DrawBoolVar(position, boolVar);
                position.y += position.height;
            }
            // StringVar
            foreach (var stringVar in blackboard.stringVars) {
                DrawStringVar(position, stringVar);
                position.y += position.height;
            }
            // Vector3Var
            foreach (var vector3Var in blackboard.vector3Vars) {
                DrawVector3Var(position, vector3Var);
                position.y += position.height;
            }
            // positionVar
            position.height = c_TwoLinesHeight;
            foreach (var rectVar in blackboard.rectVars) {
                DrawRectVar(position, rectVar);
                position.y += position.height;
            }
            // ColorVar
            position.height = c_OneLineHeight;
            foreach (var colorVar in blackboard.colorVars) {
                DrawColorVar(position, colorVar);
                position.y += position.height;
            }
            // QuaternionVar
            foreach (var quaternionVar in blackboard.quaternionVars) {
                DrawQuaternionVar(position, quaternionVar);
                position.y += position.height;
            }
            // GameObjectVar
            foreach (var gameObjectVar in blackboard.gameObjectVars) {
                DrawGameObjectVar(position, gameObjectVar, isAsset);
                position.y += position.height;
            }
            // TextureVar
            foreach (var textureVar in blackboard.textureVars) {
                DrawTextureVar(position, textureVar);
                position.y += position.height;
            }
            // MaterialVar
            foreach (var materialVar in blackboard.materialVars) {
                DrawMaterialVar(position, materialVar);
                position.y += position.height;
            }
            // ObjectVar
            position.height = c_TwoLinesHeight;
            foreach (var objectVar in blackboard.objectVars) {
                DrawObjectVar(position, objectVar, isAsset);
                position.y += position.height;
            }
            // DynamicList
            position.height = c_OneLineHeight;
            foreach (var dynamicList in blackboard.dynamicLists) {
                DrawDynamicList(position, dynamicList);
                position.y += position.height;
            }
            // FsmEvent
            foreach (var fsmEvent in blackboard.fsmEvents) {
                DrawFsmEvent(position, fsmEvent);
                position.y += position.height;
            }

            // Restore old GUI.changed
            EditorGUI.EndChangeCheck();

            // Delete variable?
            if (s_VariableToRemove != null) {
                GUIUtility.hotControl = 0;
                GUIUtility.keyboardControl = 0;

                BlackboardUtility.RemoveVariable(s_VariableToRemove);
                s_VariableToRemove = null;
            }
        }
Exemple #2
0
        /// <summary>
        /// Draw the variables of a blackboard in the GUI.
        /// <param name="position">The position in the GUI to draw the variables.</param>
        /// <param name="blackboard">The blackboard to be drawn.</param>
        /// </summary>
        public static void DrawVariables(Rect position, InternalBlackboard blackboard)
        {
            if (blackboard == null)
            {
                return;
            }

            // Create styles
            if (s_Styles == null)
            {
                s_Styles = new BlackboardGUIUtility.Styles();
            }

            // Update variable to remove
            s_VariableToRemove = null;

            // Is asset?
            bool isAsset = AssetDatabase.Contains(blackboard.gameObject);

            // Save GUI.changed
            EditorGUI.BeginChangeCheck();

            // FloatVar
            position.height = c_OneLineHeight;
            foreach (var floatVar in blackboard.floatVars)
            {
                DrawFloatVar(position, floatVar);
                position.y += position.height;
            }
            // IntVar
            foreach (var intVar in blackboard.intVars)
            {
                DrawIntVar(position, intVar);
                position.y += position.height;
            }
            // BoolVar
            foreach (var boolVar in blackboard.boolVars)
            {
                DrawBoolVar(position, boolVar);
                position.y += position.height;
            }
            // StringVar
            foreach (var stringVar in blackboard.stringVars)
            {
                DrawStringVar(position, stringVar);
                position.y += position.height;
            }
            // Vector3Var
            foreach (var vector3Var in blackboard.vector3Vars)
            {
                DrawVector3Var(position, vector3Var);
                position.y += position.height;
            }
            // positionVar
            position.height = c_TwoLinesHeight;
            foreach (var rectVar in blackboard.rectVars)
            {
                DrawRectVar(position, rectVar);
                position.y += position.height;
            }
            // ColorVar
            position.height = c_OneLineHeight;
            foreach (var colorVar in blackboard.colorVars)
            {
                DrawColorVar(position, colorVar);
                position.y += position.height;
            }
            // QuaternionVar
            foreach (var quaternionVar in blackboard.quaternionVars)
            {
                DrawQuaternionVar(position, quaternionVar);
                position.y += position.height;
            }
            // GameObjectVar
            foreach (var gameObjectVar in blackboard.gameObjectVars)
            {
                DrawGameObjectVar(position, gameObjectVar, isAsset);
                position.y += position.height;
            }
            // TextureVar
            foreach (var textureVar in blackboard.textureVars)
            {
                DrawTextureVar(position, textureVar);
                position.y += position.height;
            }
            // MaterialVar
            foreach (var materialVar in blackboard.materialVars)
            {
                DrawMaterialVar(position, materialVar);
                position.y += position.height;
            }
            // ObjectVar
            position.height = c_TwoLinesHeight;
            foreach (var objectVar in blackboard.objectVars)
            {
                DrawObjectVar(position, objectVar, isAsset);
                position.y += position.height;
            }
            // DynamicList
            position.height = c_OneLineHeight;
            foreach (var dynamicList in blackboard.dynamicLists)
            {
                DrawDynamicList(position, dynamicList);
                position.y += position.height;
            }
            // FsmEvent
            foreach (var fsmEvent in blackboard.fsmEvents)
            {
                DrawFsmEvent(position, fsmEvent);
                position.y += position.height;
            }

            // Restore old GUI.changed
            EditorGUI.EndChangeCheck();

            // Delete variable?
            if (s_VariableToRemove != null)
            {
                GUIUtility.hotControl      = 0;
                GUIUtility.keyboardControl = 0;

                BlackboardUtility.RemoveVariable(s_VariableToRemove);
                s_VariableToRemove = null;
            }
        }