コード例 #1
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry     = this.ValueEntry;
            var attribute = this.Attribute;

            EditorGUI.BeginChangeCheck();

            ObjectFieldAlignment alignment;

            if (attribute.AlignmentHasValue)
            {
                alignment = (ObjectFieldAlignment)attribute.Alignment;
            }
            else
            {
                alignment = GeneralDrawerConfig.Instance.SquareUnityObjectAlignment;
            }

            entry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(
                label,
                entry.WeakSmartValue as UnityEngine.Object,
                entry.BaseValueType,
                entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null,
                attribute.Height == 0 ? GeneralDrawerConfig.Instance.SquareUnityObjectFieldHeight : attribute.Height,
                alignment);

            if (EditorGUI.EndChangeCheck())
            {
                entry.Values.ForceMarkDirty();
            }
        }
コード例 #2
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry = this.ValueEntry;

            if (!drawAsPreview)
            {
                if (entry.BaseValueType.IsInterface)
                {
                    entry.WeakSmartValue = SirenixEditorFields.PolymorphicObjectField(
                        label,
                        entry.WeakSmartValue,
                        entry.BaseValueType,
                        entry.Property.GetAttribute <AssetsOnlyAttribute>() == null);
                }
                else
                {
                    entry.WeakSmartValue = SirenixEditorFields.UnityObjectField(
                        label,
                        entry.WeakSmartValue as UnityEngine.Object,
                        entry.BaseValueType,
                        entry.Property.GetAttribute <AssetsOnlyAttribute>() == null);
                }
            }
            else
            {
                entry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(
                    label,
                    entry.WeakSmartValue as UnityEngine.Object,
                    entry.BaseValueType,
                    entry.Property.GetAttribute <AssetsOnlyAttribute>() == null,
                    GeneralDrawerConfig.Instance.SquareUnityObjectFieldHeight,
                    GeneralDrawerConfig.Instance.SquareUnityObjectAlignment);
            }
        }
コード例 #3
0
ファイル: PawnCatalog.cs プロジェクト: RolandMQuiros/_banchou
        private static CatalogTuple DrawCell(Rect rect, CatalogTuple tuple)
        {
            tuple.Value = (GameObject)SirenixEditorFields.UnityPreviewObjectField(
                new Rect(rect)
            {
                x = rect.x - 8f, yMax = rect.yMax - 16f
            },
                tuple.Value,
                typeof(GameObject),
                dragOnly: false,
                allowMove: true,
                allowSwap: true,
                allowSceneObjects: false
                );

            tuple.Key = SirenixEditorFields.TextField(
                new Rect(rect)
            {
                yMin = rect.yMax - 16f
            },
                tuple.Key
                );

            return(tuple);
        }
コード例 #4
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label)
        {
            EditorGUI.BeginChangeCheck();
            var drawAsPreview = entry.Context.Get(this, "drawPreview", (bool?)null);

            if (drawAsPreview.Value == null)
            {
                var flags = GeneralDrawerConfig.Instance.SquareUnityObjectEnableFor;

                drawAsPreview.Value = (int)flags != 0 && (
                    (flags & GeneralDrawerConfig.UnityObjectType.Components) != 0 && typeof(Component).IsAssignableFrom(typeof(T)) ||
                    (flags & GeneralDrawerConfig.UnityObjectType.GameObjects) != 0 && typeof(GameObject).IsAssignableFrom(typeof(T)) ||
                    (flags & GeneralDrawerConfig.UnityObjectType.Materials) != 0 && typeof(Material).IsAssignableFrom(typeof(T)) ||
                    (flags & GeneralDrawerConfig.UnityObjectType.Sprites) != 0 && typeof(Sprite).IsAssignableFrom(typeof(T)) ||
                    (flags & GeneralDrawerConfig.UnityObjectType.Textures) != 0 && typeof(Texture).IsAssignableFrom(typeof(T)));

                if (!drawAsPreview.Value.Value && (flags & GeneralDrawerConfig.UnityObjectType.Others) != 0)
                {
                    bool isOther =
                        !typeof(Component).IsAssignableFrom(typeof(T)) &&
                        !typeof(GameObject).IsAssignableFrom(typeof(T)) &&
                        !typeof(Material).IsAssignableFrom(typeof(T)) &&
                        !typeof(Sprite).IsAssignableFrom(typeof(T)) &&
                        !typeof(Texture).IsAssignableFrom(typeof(T));

                    if (isOther)
                    {
                        drawAsPreview.Value = true;
                    }
                }
            }

            if (!drawAsPreview.Value.Value)
            {
                entry.WeakSmartValue = SirenixEditorFields.UnityObjectField(
                    label,
                    entry.WeakSmartValue as UnityEngine.Object,
                    entry.BaseValueType,
                    entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null);
            }
            else
            {
                entry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(
                    label,
                    entry.WeakSmartValue as UnityEngine.Object,
                    entry.BaseValueType,
                    entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null,
                    GeneralDrawerConfig.Instance.SquareUnityObjectFieldHeight,
                    GeneralDrawerConfig.Instance.SquareUnityObjectAlignment);
            }

            if (EditorGUI.EndChangeCheck())
            {
                entry.Values.ForceMarkDirty();
            }
        }
コード例 #5
0
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var rect = EditorGUILayout.GetControlRect(label != null, 45);

            rect = EditorGUI.IndentedRect(rect);

            PlayerUnitData playerUnit = ValueEntry.SmartValue;
            Texture        texture    = null;

            if (playerUnit)
            {
                texture = GUIHelper.GetAssetThumbnail(playerUnit.icon, typeof(TPlayerUnitData), true);
                GUI.Label(rect.AddXMin(50).AlignMiddle(16), EditorGUI.showMixedValue ? "-" : playerUnit.Name + "  " +
                          $"[ AP:{playerUnit.stats.Ap} HP:{playerUnit.stats.Hp} DMG:{playerUnit.stats.Dmg} DEF:{playerUnit.stats.Def} ]");
            }

            ValueEntry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(rect.AlignLeft(45), playerUnit, texture, ValueEntry.BaseValueType);
        }
コード例 #6
0
        protected override CellContent DrawElement(Rect rect, CellContent value)
        {
            EditorGUI.DrawRect(rect, Level.CellTypeToColor(value.cellStruct.cellType));

            if (value.unitData != null)
            {
                // Item count
                var countRect = rect.Padding(2).AlignBottom(16);
                EditorGUI.DrawRect(countRect, new Color(0.0f, 0.0f, 0.0f, 0.5f));
                GUI.Label(countRect, VEntityComponentSystemManager.GetVComponent <NameComponent>(value.unitData.entity).name, SirenixGUIStyles.CenteredGreyMiniLabel);
            }

            Texture texture = null;

            if (value.unitData != null && VEntityComponentSystemManager.HasVComponent <UnitDisplayComponent>(value.unitData.entity))
            {
                texture = GUIHelper.GetAssetThumbnail(VEntityComponentSystemManager.GetVComponent <UnitDisplayComponent>(value.unitData.entity).displaySprite, typeof(EntityScriptableObject), true);
            }

            value.unitData = (EntityScriptableObject)SirenixEditorFields.UnityPreviewObjectField(rect.Padding(16), value.unitData, texture, typeof(EntityScriptableObject));
            return(value);
        }
コード例 #7
0
        protected override void DrawPropertyLayout(GUIContent label)
        {
            ICustomPreview item = this.ValueEntry.SmartValue;

            if (item == null || item.EditorObject == null)
            {
                return;
            }
            var rect = EditorGUILayout.GetControlRect(label != null, 45);

            if (label != null)
            {
                rect.xMin = EditorGUI.PrefixLabel(rect.AlignCenterY(15), label).xMin;
            }
            else
            {
                rect = EditorGUI.IndentedRect(rect);
            }
            var texture = GUIHelper.GetAssetThumbnail(item.Preview, typeof(Sprite), true);

            GUI.Label(rect.AddXMin(50).AlignMiddle(16), EditorGUI.showMixedValue ? "-" : item.EditorObject.name);
            ValueEntry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(rect.AlignLeft(45), item.EditorObject, texture, ValueEntry.BaseValueType);
        }
コード例 #8
0
        protected override void DrawPropertyLayout(IPropertyValueEntry <TItem> entry, GUIContent label)
        {
            var rect = EditorGUILayout.GetControlRect(label != null, 45);

            if (label != null)
            {
                rect.xMin = EditorGUI.PrefixLabel(rect.AlignCenterY(15), label).xMin;
            }
            else
            {
                rect = EditorGUI.IndentedRect(rect);
            }

            Item    item    = entry.SmartValue;
            Texture texture = null;

            if (item)
            {
                texture = GUIHelper.GetAssetThumbnail(item.Icon, typeof(TItem), true);
                GUI.Label(rect.AddXMin(50).AlignMiddle(16), EditorGUI.showMixedValue ? "-" : item.Name);
            }

            entry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(rect.AlignLeft(45), item, texture, entry.BaseValueType);
        }
コード例 #9
0
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var rect = EditorGUILayout.GetControlRect(label != null, 45);

            if (label != null)
            {
                rect.xMin = EditorGUI.PrefixLabel(rect.AlignCenterY(15), label).xMin;
            }
            else
            {
                rect = EditorGUI.IndentedRect(rect);
            }

            Ability ability = ValueEntry.SmartValue;
            Texture texture = null;

            if (ability)
            {
                texture = GUIHelper.GetAssetThumbnail(ability.icon, typeof(TAbility), true);
                GUI.Label(rect.AddXMin(50).AlignMiddle(16), EditorGUI.showMixedValue ? "-" : ability.Name.ToString());
            }

            ValueEntry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(rect.AlignLeft(45), ability, texture, ValueEntry.BaseValueType);
        }
コード例 #10
0
        public override void OnInspectorGUI()
        {
            var tree = Tree;

            InspectorUtilities.BeginDrawPropertyTree(tree, true);

            var size = (EditorGUIUtility.fieldWidth / 16) * 9 * 3.3f;

            EditorGUIUtility.labelWidth = size + 75;

            language = (Language)EditorGUILayout.EnumPopup(new GUIContent($"Language {languageIndex + 1}/{languagesCount}"), language);
            GUILayout.Space(10);

            DrawLanguageSpecificInfo(new GUIContent("<b>Title</b>"), 0, 20);
            DrawLanguageSpecificInfo(new GUIContent("<b>Action Verb</b>"), 2, 25);
            DrawLanguageSpecificInfo(new GUIContent("<b>Description</b>"), 1, 180, true);

            var rect = GUILayoutUtility.GetRect(1, size);

            var thumbnailRect     = new Rect(rect.x, rect.y, size, rect.height);
            var thumbnailProperty = tree.GetPropertyAtPath("thumbnail");

            thumbnailProperty.ValueEntry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(thumbnailRect,
                                                                                                      GUIContent.none, (Sprite)thumbnailProperty.ValueEntry.WeakSmartValue, typeof(Sprite),
                                                                                                      false, ObjectFieldAlignment.Left);

            EditorGUIUtility.labelWidth = 75;

            var sceneRect = new Rect(thumbnailRect.xMax + 3, thumbnailRect.y - 7, rect.width - thumbnailRect.width, EditorGUIUtility.singleLineHeight + 9);

            EditorGUI.PropertyField(sceneRect, serializedObject.FindProperty("scene"), new GUIContent("Scene"));

            var inputsRect = new Rect(sceneRect.x, sceneRect.yMax - 5, sceneRect.width - 2, EditorGUIUtility.singleLineHeight);

            EditorGUI.PropertyField(inputsRect, serializedObject.FindProperty("inputs"), new GUIContent("Inputs"));

            var rythmRect = new Rect(inputsRect.x, inputsRect.yMax + 11, inputsRect.width, inputsRect.height);

            EditorGUI.PropertyField(rythmRect, serializedObject.FindProperty("rythmConstraints"), new GUIContent("Constraints"));

            var rivalsRect = DrawRivals(rythmRect);

            var themeRect = new Rect(rythmRect.x, rivalsRect.yMax + 3, rythmRect.width, rythmRect.height);

            EditorGUI.PropertyField(themeRect, serializedObject.FindProperty("theme"), new GUIContent("Theme"));

            EditorGUIUtility.labelWidth = size;
            EditorGUILayout.Separator();

            var designerRect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);

            DrawAuthor(designerRect, designerProperty, new GUIContent("Designer"));

            GUILayout.Space(2);

            var developerRect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);

            DrawAuthor(developerRect, developerProperty, new GUIContent("Developer"));

            InspectorUtilities.EndDrawPropertyTree(tree);
        }