Example #1
0
        public void OnGUI()
        {
            showTypeOption = EditorGUILayout.Foldout(showTypeOption, new GUIContent(titleTypeOption, descriptionTypeOption));

            if (showTypeOption)
            {
                GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

                float height =
                    LudiqGUI.GetInspectorHeight(null, typeOptionsMetadata, Styles.optionsWidth, GUIContent.none);

                EditorGUI.BeginChangeCheck();

                var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

                LudiqGUI.Inspector(typeOptionsMetadata, position, GUIContent.none);

                if (EditorGUI.EndChangeCheck())
                {
                    typeOptionsMetadata.Save();
                    Codebase.UpdateSettings();
                }

                if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
                {
                    typeOptionsMetadata.Reset(true);
                    typeOptionsMetadata.Save();
                }

                LudiqGUI.EndVertical();
            }
        }
 protected override float GetHeight(float width, GUIContent label)
 {
     if (hasType)
     {
         return(LudiqGUI.GetInspectorHeight(this, typedValueMetadata, width, label));
     }
     else
     {
         return(LudiqGUI.GetInspectorHeight(this, typeMetadata, width, label));
     }
 }
Example #3
0
        public float GetHeight(float width, GUIContent label)
        {
            if (!ResolveType())
            {
                return(0f);
            }

            var height = LudiqGUI.GetInspectorHeight(parent, parent.metadata.Cast(parent.type), width, GUIContent.none);

            return(Inspector.HeightWithLabel(parent.metadata, width, height, label));
        }
Example #4
0
        protected override void OnGUIBlock(Rect position, GUIContent label)
        {
            if (accessor != null && accessor.value != null)
            {
                var typePosition = position;
                typePosition.height = 16;

                var valuePosition = typePosition;
                valuePosition.y += 20;

                UnityEditor.EditorGUI.BeginDisabledGroup(!(bool)accessor["canChangeType"].value);
                LudiqGUI.Inspector(typeMeta, typePosition, GUIContent.none);
                UnityEditor.EditorGUI.EndDisabledGroup();

                if (accessor["value"].value != null)
                {
                    LudiqGUI.Inspector(accessor["value"].Cast(typeMeta.value as System.Type), valuePosition, GUIContent.none);
                }
                else
                {
                    if (((System.Type)typeMeta.value).GetType() == typeof(UnityEngine.Object))
                    {
                        accessor["value"].value = UnityEditor.EditorGUI.ObjectField(valuePosition, (UnityEngine.Object)accessor["value"].value, typeMeta.value as System.Type, false);
                    }
                    else
                    {
                        if (typeMeta.value.GetType().CSharpName() == "object")
                        {
                            LudiqGUI.Inspector(accessor["value"].Cast(typeMeta.value as System.Type), valuePosition, GUIContent.none);
                        }
                        else
                        {
                            accessor["value"].value = ((System.Type)typeMeta.value).Instantiate();
                        }
                    }
                }
            }
            else
            {
                accessor.value = new TypeValue {
                    type = typeof(int), value = 0
                };
            }

            height = LudiqGUI.GetInspectorHeight(accessor.Inspector(), accessor["value"].Cast(typeMeta.value as System.Type), position.width, GUIContent.none) + 40;
        }
Example #5
0
        public float GetHeight(float width, GUIContent label)
        {
            var height = 0f;

            if (parent.chooseType)
            {
                height += EditorGUIUtility.singleLineHeight;
            }

            if (parent.chooseType && parent.showValue)
            {
                height += SystemObjectInspector.Styles.spaceBetweenTypeAndValue;
            }

            if (parent.showValue)
            {
                height += LudiqGUI.GetInspectorHeight(parent, parent.metadata.Cast(parent.type), width, GUIContent.none);
            }

            return(Inspector.HeightWithLabel(parent.metadata, width, height, label));
        }
        protected override float GetHeight(float width, GUIContent label)
        {
            var height = 0f;

            if (chooseType)
            {
                height += EditorGUIUtility.singleLineHeight;
            }

            if (chooseType && showValue)
            {
                height += Styles.spaceBetweenTypeAndValue;
            }

            if (showValue)
            {
                height += LudiqGUI.GetInspectorHeight(this, metadata.Cast(type), width, GUIContent.none);
            }

            return(HeightWithLabel(metadata, width, height, label));
        }
        public void OnGUI()
        {
            showAssembly = EditorGUILayout.Foldout(showAssembly, new GUIContent(titleAssembly, descriptionAssembly));

            if (showAssembly)
            {
                GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

                float height = LudiqGUI.GetInspectorHeight(null, assemblyOptionsMetadata, Styles.optionsWidth, GUIContent.none);

                EditorGUI.BeginChangeCheck();

                var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

                LudiqGUI.Inspector(assemblyOptionsMetadata, position, GUIContent.none);

                if (EditorGUI.EndChangeCheck())
                {
                    assemblyOptionsMetadata.Save();
                    Codebase.UpdateSettings();
                }

                if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
                {
                    assemblyOptionsMetadata.Reset(true);
                    assemblyOptionsMetadata.Save();
                }

                LudiqGUI.EndVertical();
            }

            if (GUILayout.Button(completeLabel, Styles.defaultsButton))
            {
                UnitBase.Rebuild();

                EditorUtility.DisplayDialog("Visual Script", "Regenerate Nodes completed", "OK");
            }
        }
 private float GetValueHeight(Metadata valueMetadata, float valueWidth)
 {
     return(LudiqGUI.GetInspectorHeight(parentInspector, valueMetadata, valueWidth, GUIContent.none));
 }
 private float GetImplementationHeight(float implementationWidth)
 {
     return(LudiqGUI.GetInspectorHeight(this, implementationMetadata, implementationWidth, GUIContent.none));
 }
Example #10
0
 private float GetValueHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, valueMetadata, width));
 }
Example #11
0
 protected virtual float GetInspectorHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, metadata, width, GUIContent.none));
 }
 protected float GetTypeHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, typeMetadata, width));
 }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the types you want to use for variables and units.\n"
                       + "MonoBehaviour types are always included.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, typeOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(typeOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                typeOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                typeOptionsMetadata.Reset(true);
                typeOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Generate", Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Example #14
0
 protected float GetHideLabelHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, hideLabelMetadata, width));
 }
Example #15
0
 protected float GetDescriptionHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, descriptionMetadata, width));
 }
Example #16
0
 protected float GetKeyHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, keyMetadata, width));
 }
        protected override void OnGUI(Rect position, GUIContent label)
        {
            // Super hacky hotfix:
            // If the value changes in between OnGUI calls,
            // the OnValueChange event will not be called, because
            // we don't even look at the value until showField is true.
            // For example, an object that was null and becomes non-null
            // will be reset to null by the inspector unless this line is here,
            // because type will be null and showField will thus be false.
            var haxHotfix = metadata.value;
            // TL;DR: storing a local private type field that does not
            // take the actual, current variable type into consideration is a
            // very bad idea and will inevitably cause inspector v. codebase fighting
            // or inspector v. inspector fighting.

            var showLabels = !adaptiveWidth && position.width >= 120;

            BeginBlock(metadata, position, GUIContent.none);

            if (chooseType)
            {
                var x = position.x;
                var remainingWidth = position.width;

                if (showLabels)
                {
                    var typeLabel = label == GUIContent.none ? new GUIContent("Type") : new GUIContent(label.text + " Type");

                    var typeLabelPosition = new Rect
                                            (
                        x,
                        y,
                        Styles.labelWidth,
                        EditorGUIUtility.singleLineHeight
                                            );

                    GUI.Label(typeLabelPosition, typeLabel, ProcessLabelStyle(metadata, null));

                    x += typeLabelPosition.width;
                    remainingWidth -= typeLabelPosition.width;
                }

                var typePosition = new Rect
                                   (
                    x,
                    y,
                    remainingWidth,
                    EditorGUIUtility.singleLineHeight
                                   );

                EditorGUI.BeginChangeCheck();

                var newType = LudiqGUI.TypeField(typePosition, GUIContent.none, type, GetTypeOptions, new GUIContent("(Null)"));

                if (EditorGUI.EndChangeCheck())
                {
                    metadata.RecordUndo();
                    type = newType;
                    EnforceType();
                    SetHeightDirty();
                }

                y += typePosition.height;
            }

            if (chooseType && showValue)
            {
                y += Styles.spaceBetweenTypeAndValue;
            }

            if (showValue)
            {
                Rect valuePosition;

                if (chooseType)
                {
                    var x = position.x;
                    var remainingWidth = position.width;

                    if (showLabels)
                    {
                        var valueLabel = label == GUIContent.none ? new GUIContent("Value") : new GUIContent(label.text + " Value");

                        var valueLabelPosition = new Rect
                                                 (
                            x,
                            y,
                            Styles.labelWidth,
                            EditorGUIUtility.singleLineHeight
                                                 );

                        GUI.Label(valueLabelPosition, valueLabel, ProcessLabelStyle(metadata, null));

                        x += valueLabelPosition.width;
                        remainingWidth -= valueLabelPosition.width;
                    }

                    valuePosition = new Rect
                                    (
                        x,
                        y,
                        remainingWidth,
                        EditorGUIUtility.singleLineHeight
                                    );

                    LudiqGUI.Inspector(metadata.Cast(type), valuePosition, GUIContent.none);
                }
                else
                {
                    valuePosition = new Rect
                                    (
                        position.x,
                        y,
                        position.width,
                        LudiqGUI.GetInspectorHeight(this, metadata.Cast(type), position.width, label)
                                    );

                    LudiqGUI.Inspector(metadata.Cast(type), valuePosition, label);
                }

                y += valuePosition.height;
            }
            else
            {
                metadata.value = null;
            }

            EndBlock(metadata);
        }
 protected override float GetHeight(float width, GUIContent label)
 {
     return(LudiqGUI.GetInspectorHeight(this, declarationsMetadata, width, GUIContent.none));
 }
Example #19
0
        public void OnGUI(Rect position, GUIContent label, bool showLabels, ref float y)
        {
            if (parent.chooseType)
            {
                var x = position.x;
                var remainingWidth = position.width;

                if (showLabels)
                {
                    var typeLabel = label == GUIContent.none ? new GUIContent("Type") : new GUIContent(label.text + " Type");

                    var typeLabelPosition = new Rect
                                            (
                        x,
                        y,
                        SystemObjectInspector.Styles.labelWidth,
                        EditorGUIUtility.singleLineHeight
                                            );

                    GUI.Label(typeLabelPosition, typeLabel, Inspector.ProcessLabelStyle(parent.metadata, null));

                    x += typeLabelPosition.width;
                    remainingWidth -= typeLabelPosition.width;
                }

                var typePosition = new Rect
                                   (
                    x,
                    y,
                    remainingWidth,
                    EditorGUIUtility.singleLineHeight
                                   );

                EditorGUI.BeginChangeCheck();

                var newType = LudiqGUI.TypeField(typePosition, GUIContent.none, parent.type, GetTypeOptions, new GUIContent("(Null)"));

                if (EditorGUI.EndChangeCheck())
                {
                    parent.metadata.RecordUndo();
                    parent.type = newType;
                    parent.SetValue();
                    parent.SetHeightDirty();
                }

                y += typePosition.height;
            }

            if (parent.chooseType && parent.showValue)
            {
                y += SystemObjectInspector.Styles.spaceBetweenTypeAndValue;
            }

            if (parent.showValue)
            {
                Rect valuePosition;

                if (parent.chooseType)
                {
                    var x = position.x;
                    var remainingWidth = position.width;

                    if (showLabels)
                    {
                        var valueLabel = label == GUIContent.none ? new GUIContent("Value") : new GUIContent(label.text + " Value");

                        var valueLabelPosition = new Rect
                                                 (
                            x,
                            y,
                            SystemObjectInspector.Styles.labelWidth,
                            EditorGUIUtility.singleLineHeight
                                                 );

                        GUI.Label(valueLabelPosition, valueLabel, Inspector.ProcessLabelStyle(parent.metadata, null));

                        x += valueLabelPosition.width;
                        remainingWidth -= valueLabelPosition.width;
                    }

                    valuePosition = new Rect
                                    (
                        x,
                        y,
                        remainingWidth,
                        EditorGUIUtility.singleLineHeight
                                    );

                    LudiqGUI.Inspector(parent.metadata.Cast(parent.type), valuePosition, GUIContent.none);
                }
                else
                {
                    valuePosition = new Rect
                                    (
                        position.x,
                        y,
                        position.width,
                        LudiqGUI.GetInspectorHeight(parent, parent.metadata.Cast(parent.type), position.width, label)
                                    );

                    LudiqGUI.Inspector(parent.metadata.Cast(parent.type), valuePosition, label);
                }

                y += valuePosition.height;
            }
            else
            {
                parent.metadata.value = null;
            }
        }
Example #20
0
 private float GetSourceHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, sourceMetadata, width));
 }
 protected virtual float GetMemberHeight(Metadata member, float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, member, width));
 }
Example #22
0
 private float GetMacroHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, macroMetadata, width));
 }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the assemblies in which you want to look for units.\n"
                       + "By default, all project and Unity assemblies are included.\n"
                       + "Unless you use a third-party plugin distributed as a DLL, you shouldn't need to change this.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, assemblyOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(assemblyOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                assemblyOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                assemblyOptionsMetadata.Reset(true);
                assemblyOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Example #24
0
        private void OpenContents(Rect position, Rect container)
        {
            if ((bool)isOpenMeta.value)
            {
                var typeHeight  = LudiqGUI.GetInspectorHeight(typeMeta.Inspector(), typeMeta["type"], position.width, GUIContent.none);
                var valueHeight = LudiqGUI.GetInspectorHeight(typeMeta.Inspector(), typeMeta["value"], position.width, GUIContent.none);
                var typeLabel   = new Rect(container.x + 5, container.y + y + 10, 60, 16);
                var typeRect    = new Rect(container.x + 50, container.y + typeLabel.height + 16, container.width - 60, typeHeight);
                var defaultRect = new Rect(container.x + 50, typeRect.y + typeRect.height + 4, container.width - 60, typeHeight);
                var valueRect   = new Rect(container.x + 10, typeRect.y + typeRect.height + defaultRect.height + 8, container.width - 20, valueHeight + 8);
                EditorGUI.LabelField(typeLabel, new GUIContent("Type"));
                LudiqGUI.Inspector(typeMeta["type"], typeRect, GUIContent.none);

                var addedHeight = 0;

                if (!((System.Type)typeMeta["type"].value).InheritsType(typeof(UnityEngine.Object)))
                {
                    addedHeight += 16;

                    LudiqGUI.Inspector(typeMeta["hasDefault"], defaultRect, new GUIContent("Default"));

                    if ((bool)typeMeta["hasDefault"].value)
                    {
                        UtilityGUI.Container(valueRect, Color.black, 0.7f.Grey(), 1, 4, (valueContainer) =>
                        {
                            if (typeMeta["value"].value != null || ((System.Type)typeMeta["type"].value).InheritsType(typeof(UnityEngine.Object)))
                            {
                                LudiqGUI.Inspector(typeMeta["value"], valueContainer, GUIContent.none);

                                if ((System.Type)typeMeta["type"].value == typeof(bool))
                                {
                                    var boolLabel = valueContainer;
                                    boolLabel.x  += 18;
                                    GUI.Label(boolLabel, (nameMeta.value as string).Prettify());
                                }
                            }
                        });

                        addedHeight += (int)valueRect.height + 10;
                    }
                }

                var optionsRect    = Options(typeLabel, typeRect, addedHeight + defaultRect.height);
                var propertiesRect = optionsRect;
                propertiesRect.width  = typeLabel.width + typeRect.width;
                propertiesRect.x     -= 20;
                propertiesRect.y     += 86;
                propertiesRect.height = 56;
                var propertyHeight = propertyMeta.Inspector().GetCachedHeight(lastPosition.width, GUIContent.none, accessor.Inspector()) + addedHeight;

                var prop     = ((Property)propertyMeta.value);
                var propName = string.Empty;

                UAliveGUI.NestedSection(propertiesRect, e, "Property", UAliveResources.properties, addedHeight, (propertiesContainer) =>
                {
                    LudiqGUI.Inspector(propertyMeta, new Rect(propertiesContainer.x, propertiesContainer.y, propertiesContainer.width - 40, propertyHeight));
                }, isPropertyMeta);

                addedHeight += 30;

                y += typeHeight + defaultRect.height + optionsRect.height + propertiesRect.height + addedHeight + 4;
            }
        }
Example #25
0
 protected override float GetHeaderAddonHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(null, metadata, width, GUIContent.none));
 }
 private float GetControlInputDefinitionsHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, controlInputDefinitionsMetadata, width));
 }
 private float GetKeyHeight(Metadata keyMetadata, float keyWidth)
 {
     return(LudiqGUI.GetInspectorHeight(parentInspector, keyMetadata, keyWidth, GUIContent.none));
 }
Example #28
0
        public override void CachePosition()
        {
            // Width

            var inputsWidth  = 0f;
            var outputsWidth = 0f;

            foreach (var input in inputs)
            {
                inputsWidth = Mathf.Max(inputsWidth, input.GetInnerWidth());
            }

            foreach (var output in outputs)
            {
                outputsWidth = Mathf.Max(outputsWidth, output.GetInnerWidth());
            }

            var portsWidth = 0f;

            portsWidth += inputsWidth;
            portsWidth += Styles.spaceBetweenInputsAndOutputs;
            portsWidth += outputsWidth;

            settingsPositions.Clear();

            var settingsWidth = 0f;

            if (showSettings)
            {
                foreach (var setting in settings)
                {
                    var settingWidth = 0f;

                    var settingLabelContent = settingLabelsContents[setting];

                    if (settingLabelContent != null)
                    {
                        settingWidth += Styles.settingLabel.CalcSize(settingLabelContent).x;
                    }

                    settingWidth += setting.Inspector().GetAdaptiveWidth();

                    settingWidth = Mathf.Min(settingWidth, Styles.maxSettingsWidth);

                    settingsPositions.Add(setting, new Rect(0, 0, settingWidth, 0));

                    settingsWidth = Mathf.Max(settingsWidth, settingWidth);
                }
            }

            var headerAddonWidth = 0f;

            if (showHeaderAddon)
            {
                headerAddonWidth = GetHeaderAddonWidth();
            }

            var titleWidth = Styles.title.CalcSize(titleContent).x;

            var headerTextWidth = titleWidth;

            var surtitleWidth = 0f;

            if (showSurtitle)
            {
                surtitleWidth   = Styles.surtitle.CalcSize(surtitleContent).x;
                headerTextWidth = Mathf.Max(headerTextWidth, surtitleWidth);
            }

            var subtitleWidth = 0f;

            if (showSubtitle)
            {
                subtitleWidth   = Styles.subtitle.CalcSize(subtitleContent).x;
                headerTextWidth = Mathf.Max(headerTextWidth, subtitleWidth);
            }

            var iconsWidth = 0f;

            if (showIcons)
            {
                var iconsColumns = Mathf.Ceil((float)description.icons.Length / Styles.iconsPerColumn);
                iconsWidth = iconsColumns * Styles.iconsSize + ((iconsColumns - 1) * Styles.iconsSpacing);
            }

            var headerWidth = Mathf.Max(headerTextWidth + iconsWidth, Mathf.Max(settingsWidth, headerAddonWidth)) + Styles.iconSize + Styles.spaceAfterIcon;

            var innerWidth = Mathf.Max(portsWidth, headerWidth);

            var edgeWidth = InnerToEdgePosition(new Rect(0, 0, innerWidth, 0)).width;

            // Height & Positioning

            var edgeOrigin  = unit.position;
            var edgeX       = edgeOrigin.x;
            var edgeY       = edgeOrigin.y;
            var innerOrigin = EdgeToInnerPosition(new Rect(edgeOrigin, Vector2.zero)).position;
            var innerX      = innerOrigin.x;
            var innerY      = innerOrigin.y;

            iconPosition = new Rect
                           (
                innerX,
                innerY,
                Styles.iconSize,
                Styles.iconSize
                           );

            var headerTextX = iconPosition.xMax + Styles.spaceAfterIcon;

            var y = innerY;

            var headerHeight = 0f;

            var surtitleHeight = 0f;

            if (showSurtitle)
            {
                surtitleHeight = Styles.surtitle.CalcHeight(surtitleContent, headerTextWidth);

                surtitlePosition = new Rect
                                   (
                    headerTextX,
                    y,
                    headerTextWidth,
                    surtitleHeight
                                   );

                headerHeight += surtitleHeight;
                y            += surtitleHeight;

                headerHeight += Styles.spaceAfterSurtitle;
                y            += Styles.spaceAfterSurtitle;
            }

            var titleHeight = 0f;

            if (showTitle)
            {
                titleHeight = Styles.title.CalcHeight(titleContent, headerTextWidth);

                titlePosition = new Rect
                                (
                    headerTextX,
                    y,
                    headerTextWidth,
                    titleHeight
                                );

                headerHeight += titleHeight;
                y            += titleHeight;
            }

            var subtitleHeight = 0f;

            if (showSubtitle)
            {
                headerHeight += Styles.spaceBeforeSubtitle;
                y            += Styles.spaceBeforeSubtitle;

                subtitleHeight = Styles.subtitle.CalcHeight(subtitleContent, headerTextWidth);

                subtitlePosition = new Rect
                                   (
                    headerTextX,
                    y,
                    headerTextWidth,
                    subtitleHeight
                                   );

                headerHeight += subtitleHeight;
                y            += subtitleHeight;
            }

            iconsPositions.Clear();

            if (showIcons)
            {
                var iconRow = 0;
                var iconCol = 0;

                for (int i = 0; i < description.icons.Length; i++)
                {
                    var iconPosition = new Rect
                                       (
                        innerX + innerWidth - ((iconCol + 1) * Styles.iconsSize) - ((iconCol) * Styles.iconsSpacing),
                        innerY + (iconRow * (Styles.iconsSize + Styles.iconsSpacing)),
                        Styles.iconsSize,
                        Styles.iconsSize
                                       );

                    iconsPositions.Add(iconPosition);

                    iconRow++;

                    if (iconRow % Styles.iconsPerColumn == 0)
                    {
                        iconCol++;
                        iconRow = 0;
                    }
                }
            }

            var settingsHeight = 0f;

            if (showSettings)
            {
                headerHeight += Styles.spaceBeforeSettings;

                foreach (var setting in settings)
                {
                    var settingWidth = settingsPositions[setting].width;

                    using (LudiqGUIUtility.currentInspectorWidth.Override(settingWidth))
                    {
                        var settingHeight = LudiqGUI.GetInspectorHeight(null, setting, settingWidth, settingLabelsContents[setting] ?? GUIContent.none);

                        var settingPosition = new Rect
                                              (
                            headerTextX,
                            y,
                            settingWidth,
                            settingHeight
                                              );

                        settingsPositions[setting] = settingPosition;

                        settingsHeight += settingHeight;
                        y += settingHeight;

                        settingsHeight += Styles.spaceBetweenSettings;
                        y += Styles.spaceBetweenSettings;
                    }
                }

                settingsHeight -= Styles.spaceBetweenSettings;
                y -= Styles.spaceBetweenSettings;

                headerHeight += settingsHeight;

                headerHeight += Styles.spaceAfterSettings;
                y            += Styles.spaceAfterSettings;
            }

            if (showHeaderAddon)
            {
                var headerAddonHeight = GetHeaderAddonHeight(headerAddonWidth);

                headerAddonPosition = new Rect
                                      (
                    headerTextX,
                    y,
                    headerAddonWidth,
                    headerAddonHeight
                                      );

                headerHeight += headerAddonHeight;
                y            += headerAddonHeight;
            }

            if (headerHeight < Styles.iconSize)
            {
                var difference      = Styles.iconSize - headerHeight;
                var centeringOffset = difference / 2;

                if (showTitle)
                {
                    var _titlePosition = titlePosition;
                    _titlePosition.y += centeringOffset;
                    titlePosition     = _titlePosition;
                }

                if (showSubtitle)
                {
                    var _subtitlePosition = subtitlePosition;
                    _subtitlePosition.y += centeringOffset;
                    subtitlePosition     = _subtitlePosition;
                }

                if (showSettings)
                {
                    foreach (var setting in settings)
                    {
                        var _settingPosition = settingsPositions[setting];
                        _settingPosition.y        += centeringOffset;
                        settingsPositions[setting] = _settingPosition;
                    }
                }

                if (showHeaderAddon)
                {
                    var _headerAddonPosition = headerAddonPosition;
                    _headerAddonPosition.y += centeringOffset;
                    headerAddonPosition     = _headerAddonPosition;
                }

                headerHeight = Styles.iconSize;
            }

            y = innerY + headerHeight;

            var innerHeight = 0f;

            innerHeight += headerHeight;

            if (showPorts)
            {
                innerHeight += Styles.spaceBeforePorts;
                y           += Styles.spaceBeforePorts;

                var portsBackgroundY      = y;
                var portsBackgroundHeight = 0f;

                portsBackgroundHeight += Styles.portsBackground.padding.top;
                innerHeight           += Styles.portsBackground.padding.top;
                y += Styles.portsBackground.padding.top;

                var portStartY = y;

                var inputsHeight  = 0f;
                var outputsHeight = 0f;

                foreach (var input in inputs)
                {
                    input.y = y;

                    var inputHeight = input.GetHeight();

                    inputsHeight += inputHeight;
                    y            += inputHeight;

                    inputsHeight += Styles.spaceBetweenPorts;
                    y            += Styles.spaceBetweenPorts;
                }

                if (inputs.Count > 0)
                {
                    inputsHeight -= Styles.spaceBetweenPorts;
                    y            -= Styles.spaceBetweenPorts;
                }

                y = portStartY;

                foreach (var output in outputs)
                {
                    output.y = y;

                    var outputHeight = output.GetHeight();

                    outputsHeight += outputHeight;
                    y             += outputHeight;

                    outputsHeight += Styles.spaceBetweenPorts;
                    y             += Styles.spaceBetweenPorts;
                }

                if (outputs.Count > 0)
                {
                    outputsHeight -= Styles.spaceBetweenPorts;
                    y             -= Styles.spaceBetweenPorts;
                }

                var portsHeight = Math.Max(inputsHeight, outputsHeight);

                portsBackgroundHeight += portsHeight;
                innerHeight           += portsHeight;
                y = portStartY + portsHeight;

                portsBackgroundHeight += Styles.portsBackground.padding.bottom;
                innerHeight           += Styles.portsBackground.padding.bottom;
                y += Styles.portsBackground.padding.bottom;

                portsBackgroundPosition = new Rect
                                          (
                    edgeX,
                    portsBackgroundY,
                    edgeWidth,
                    portsBackgroundHeight
                                          );
            }

            var edgeHeight = InnerToEdgePosition(new Rect(0, 0, 0, innerHeight)).height;

            _position = new Rect
                        (
                edgeX,
                edgeY,
                edgeWidth,
                edgeHeight
                        );
        }
Example #29
0
 private float GetValueOutputDefinitionsHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, valueOutputDefinitionsMetadata, width));
 }
Example #30
0
 private float GetValueHeight(float width)
 {
     return(LudiqGUI.GetInspectorHeight(this, metadata["Value"], width, GUIContent.none));
 }