Git Product home page Git Product logo

mybox's Introduction

Hi there ๐Ÿ‘‹

mybox's People

Contributors

adamgryu avatar adrienvr avatar aminsojoudi avatar angelsalascalvo avatar causeless avatar crizgames avatar deadcows avatar derfium avatar favoyang avatar ijemin avatar j-jorge avatar jcs090218 avatar karsion avatar konfus-dev avatar novack avatar quriz avatar r1noff avatar r3dskjn avatar rfadeev avatar schodemeiss avatar snappedtogrid avatar thewalruzz avatar tonygiang avatar whaletee avatar wilsnat avatar wqyeo avatar yogurtthehorse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mybox's Issues

MustBeAssigned does not check for ConditionalAttribute [Bug, Minor]

A trivial, non-blocking bug where if MustBeAssigned attribute and Conditional attribute are applied to a property, they do not seem to 'sync' together.

(Aka even if Conditional attribute hides the property, MustBeAssigned still displays an error if the property was left empty)

To reproduce:

    [SerializeField]
    private bool showMustAssign;

    [MustBeAssigned, ConditionalField("showMustAssign", true), SerializeField]
    private Transform mustAssign;

Use this script on one of the game object, uncheck the showMustAssign on the inspector, and leave the mustAssign as null/empty. Click play and the error shows after the game runs.

ConditionalField attribute doesn't hide Arrays

ConditionalField attribute doesn't hide Arrays for built-in types and custom types. Here is what I tried.

    public bool showAges;
    [ConditionalField(nameof(showAges))] public int[] ageArray;

image

Add package.json so can use with Unity Package Manager

Cool toolbox, any chance of adding package.json so can be used with Unity's Package Manager?
Shows what Unity latest version is and any dependencies it has as well.

{
  "name": "com.mybox",
  "displayName": "MyBox",
  "version": "0.0.1",
  "unity": "2018.3",
  "description": "DeadCows My Box",
  "dependencies": {
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0"
  }
}

mob-sakai upm extension:
https://github.com/mob-sakai/UpmGitExtension/tree/upm
and his tutorial for the custom branch for upm, may be easier for maintaining:
https://www.patreon.com/posts/25070968

Toggle Enum Flags

Here is another idea for a cool attribute you could add. I would like to have an enum with a whole bunch of flags I could set by toggling them. I this looks really nice when I put it in my game however I am not exactly sure how to get any useful data out of it just yet. What I want to do with this is check if an enum is toggled and then perform an action, if multiple toggles are set I would like to know that as well. But right now I am getting weird results back from this.

https://forum.unity.com/threads/enum-flags-as-toggle-buttons.298723/

Also, this has some code to handle putting buttons on new lines when they stretch past what the inspector can handle.

Loopable animations not working with AnimationStateReference play extension

I'm using this code for previewing animation states out of playmode in the editor;

/// <summary>
/// Script to change animation states in editor to preview states in scene
/// </summary>

#if UNITY_EDITOR
[RequireComponent(typeof(Animator))]
[ExecuteInEditMode]
public class AnimationStateInEditor : MonoBehaviour
{
    [AutoProperty, ReadOnly, SerializeField]
    private Animator anim;
    
    public AnimationStateReference state;

    private void OnValidate()
    {
        anim = GetComponent<Animator>();
    }

    private void Update()
    {
        if (!Application.isPlaying)
        {
            //forces to play in edit mode
            anim.Update(Time.deltaTime);
            anim.Play(state);

        }
            
    }
}
#endif

While normal animations work fine, loopable animations only plays the first few frames over and over - not the entire animation. Am I doing something wrong here?

Lerp from RangedFloat/RangeInt

I wanted to calculate an intermediate value from a RangeFloat, and I wrote a simple 'Lerp' extension method.

image

And I thought it would be nice to have this right out of the box! ๐Ÿ˜

[ButtonMethod] on ScriptableObjects

[ButtonMethod] attribute doesn't seem to work on ScriptableObjects. Is this intentional or is there any technical limitation?

[ButtonMethod] on ScriptableObjects would be so helpful to configure ScriptableObjects with ease.

ConditionalField hide values of a Serializable Class on my inspector

This is my code
[ConditionalField("NeedRotation")] public RotationCore Rotation;

And NeedRotation is a bool value, but when is it activated,it show me the class, but do not show me values of the same class, and without this conditional i can see the values without problems, my class have a [System.Serializable] on the top

Reorderable Colections

Dose MyBox have the ability to create reorderable lists, arrays, or any other collection I want? I have been trying to create one of these for myself but am having trouble. I found your project very useful and was wondering if you had implemented this sort of system.

image

I have added your conditional fields with an enum dropdown to an array of type T and it works the way I want it to. But now I would like to use a list where I can simply press a button to add and remove the items as well as reorder them as seen in the image above.

No License File

This looks useful, but you've not provided any LICENSE file. Would you mind adding one?

OpenUPM package

Since this package already supported installation via Unity Package Manager, it'd be great to have it registered on OpenUPM as well.

Incompatibility with PixeyeHQ's InspectorFoldoutGroup

This package is causing InspectorFoldoutGroup to not have any effect as soon as it is imported. I'm not sure this issue is caused by this package or InspectorFoldoutGroup, I'm just going to bring it up here first and if nothing can be done on this end, I'll bring this issue to InspectorFoldoutGroup repo.

Side note: I think InspectorFoldoutGroup is a good fit within this package. If this issue ever gets resolved, I think you should consider including it.

ConditionalFieldAttribute does not hide HeaderAttribute [Bug]

Yet another trivial and minor bug where ConditionalFieldAttribute does not hide HeaderAttribute, as shown in both of these screenshots:

Codes used when encountering this:

    [Separator("Shooter Targetting properties", true)]

    [SerializeField, Tooltip("True if this shooter locks on to an enemy")]
    private bool lockOn;

    [ConditionalField("lockOn", false), SerializeField, Tooltip("Where this shot is angled towards."), Range(0f, 360f)]
    private float shootingAngle;
    
    [MustBeAssigned, ConditionalField("lockOn", true), SerializeField, Tooltip("The target this shooter is locking on to. (Play if null.)")]
    private Transform targetTransform;

    [Header("Angle Rotating Options")]

    [SerializeField, ConditionalField("lockOn", false), Tooltip("The rotational speed applied to the shooting angle.")]
    private float shootAngleRotationSpeed;

Though I can see the design idea in not fixing this. (Where there might be more than 1 field below the header, and it would look weird/bad if we hid the header at that situation.)

Maybe a parameter in the attribute that removes the header(if exists) when hidden? Or some checking to see if there is some fields below that doesn't have a header before hiding the header.

RequireTag attribute

Would be nice if we had a RequireTag attribute that functions similar to RequireComponent attribute.

Example:

    [RequireTag("Enemy")]
    public class Enemy : MonoBehaviour {
    }

And if someone tries to attach this component to a game-object that does not have the tag set as Enemy, it will log a warn/error in the inspector.

(Could also make a RequireLayer attribute too.)

Getting some NullRefferenceExeptions form MyBox and I don't know why

So I just started getting these NullRefferenceExeptions and I am not exactly sure why. I am not sure when this first started but even after updating I still get these when I run my game. Fortunately, these don't seem to prevent me from playing my game but it is quite annoying to have these errors always in my console while debugging my own code.

NullReferenceException: Object reference not set to an instance of an object
MyBox.Internal.UnityObjectEditor.OnDisable () (at Library/PackageCache/com.mybox@c0a62452d5e378136d87ee7c052906bf370e6fcf/Tools/Internal/UnityObjectEditor.cs:21)

NullReferenceException: Object reference not set to an instance of an object
MyBox.Internal.UnityObjectEditor.OnDisable () (at Library/PackageCache/com.mybox@c0a62452d5e378136d87ee7c052906bf370e6fcf/Tools/Internal/UnityObjectEditor.cs:21)
UnityEditor.AssetDatabase:SaveAssets()
XNodeEditor.NodeEditorWindow:OnFocus() (at Library/PackageCache/com.github.siccity.xnode@7e93ffe4b75a6cab453223d20c5e03f4d7c57f7f/Scripts/Editor/NodeEditorWindow.cs:80)
UnityEditor.DockArea:OnEnable()

ConditionalFieldTabAttribute

So I was going to modify your ConditionalFieldAttribute and split it into ConditionalFieldDropDownAttribute and ConditionalFieldTabAttribute and do a pull request but oh my God I have no idea what is going on in that class. I followed this tutorial and got tabs working much like your CinditionalFieldAttribute except it is not an attribute which I would like it to be. I like how your ConditionalFieldAttributes work. Would you be able to implement this?

https://www.youtube.com/watch?v=vAi7-unj1Ww&app=desktop

RangedInt inspector breaks multi-object editing

For some reason, the newly implemented RangedInt inspector breaks the multi-object editing when multiple instances of a ScriptableObject are selected.

Maybe that's because we are using a FLOAT MinMaxRangeAttribute class for an INT field.

image

SetValueOnBuild attribute; Sets to a value when building

Would be nice if it was possible to have an attribute that will automatically set a variable's value when building, like so:

// Will be automatically set to false when building.
[SetValueOnBuild(false)]
public bool isGodMode;

//...

Would help a lot when creating debugging-related values in the inspector; It removes the need of checking those debug-related values before building the application and publishing.

I saw an answer in the post here that might help when implementing.

If it is not possible to set the value, then maybe log a warn/error to the user about the value instead?

NullRefException in MyBoxUpdateWindow.cs

I love these tools, and recently just attempted to add them to a project (Unity 2018.3.0f2, via grabbing as a zip off Git) but after putting them in the project I began getting the following error whenever I hit Play in the editor.
This is without me even utilizing any of the MyBox stuff yet in code. Not sure what todo exactly.

NullReferenceException: Object reference not set to an instance of an object
MyBox.Internal.MyBoxUpdateWindow+d__17.MoveNext () (at Assets/Extensions/MyBox/Tools/Internal/MyBoxUpdateWindow.cs:131)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at :0)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) (at :0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnitySynchronizationContext.cs:111)
UnityEngine.UnitySynchronizationContext.Exec () (at C:/buildslave/unity/build/Runtime/Export/UnitySynchronizationContext.cs:72)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at C:/buildslave/unity/build/Runtime/Export/UnitySynchronizationContext.cs:93)

Dictionary fields in inspector

Would be nice if it was possible to expose Dictionary to the inspector, rather than having to use structs (or other methods) as work-around.

MyExtensions.HasComponent<T> arbitrarily has a stricter type constraint than GameObject.GetComponent<T>

The built-in method GameObject.GetComponent<T> has no type constraint to serve a specific use case: To get all components on a GameObject that are subtypes of an interface passed as T. The MyExtensions.HasComponent<T> method in this package should remove the type constraint so that it can check every type that GameObject.GetComponent<T> can get, especially since the current implementation of MyExtensions.HasComponent<T> is just
return gameObject.GetComponent<T>() != null;

OptionalMinMax not displaying properly in nested inspector

When OptionalMinMax is not serialized directly into the inspector, the display becomes weird:

Link to image of the weird display

More importantly, the check-boxes becomes uninteractable too. Making it unusable in the inspector. ๐Ÿ˜“

The code that I used which made this occur:

        [System.Serializable]
        private struct SpawnInterval {
            [SerializeField, Tooltip("The min and max waiting time before an enemy is generated.")]
            private OptionalMinMax minMaxSpawnInterval;

            public float MaxWaitingTime { get => minMaxSpawnInterval.Max;  }

            public float MinWaitingTime { get => minMaxSpawnInterval.Min; }

            public float GenerateWaitingTime() {
                return Random.Range(MinWaitingTime, MaxWaitingTime);
            }
        }

        [SerializeField, Tooltip("The random interval between each enemy spawn"), MustBeAssigned]
        private SpawnInterval enemySpawnInterval;

I am guessing that this occurs due to the inspector not having enough horizontal space.
We can probably place the check boxes and the field-boxes in separate horizontal-lines if needed.

Question about MonoBehaviourPool in TODO

(Not really an issue, but rather a question. But posted it here since there is no where else to ask it ๐Ÿ˜… )

I recently noticed a TODO and wanted to help-out if possible. And then realized there is a MonoBehaviourPool in one of the lists.

May I ask what is that feature about?

ReorderableColections can not have a ConditionalField attribute.

Hello I was playing round with the following code when I found out that ReorderableLists can not have the ConditionalField attribute. Bellow is a bit of code that I was trying to use. Yes, I know that I have a ReorderableList inside my ListReorderable. If I comment out the ConditionalField attribute then this will work having a list within a list.

[System.Serializable]
public class ReorderableList : ReorderableList<ListReorderable> {}

[System.Serializable]
public class ListReorderable : IHasItems
{
    public DescriptionType type = DescriptionType.Description;

    [ConditionalField(nameof(type), false, DescriptionType.Description)]
    public string description;

    [ConditionalField(nameof(type), false, DescriptionType.Container)]
    public ListReorderable container;
}

public enum ListType { Description, Image, Character, DarkRoom, Item, Switch, Exit, Container }

Also, I noticed that the conditional fields within the new list do not appear as they should. Below is an image showing what I am seeing. What I expected was to see a dropdown within the container list that should default to description and have a text area below it just like the RoomDescription list does.

image

Feature Request: InitializationField

It would be nice to have an attribute that makes fields grayed out on runtime (so you can't edit them). I am currently in need of something like that, because code that uses some fields only runs once and it could confuse other people.

ConditionalField does not interact well with arrays

I am the one that asked for performance improvement on ConditionalField, thanks again for delivering :)

I have found a bug: turns out that if you have an array of elements and you want to conditionally hide some fields, it stops working after the first element. Example:

VSr0WUw08R

In that example, the fields are defined as such:

public class CinematicSequence 

(...)

[Separator("Background Music")]
[SerializeField] bool _initialBackgroundMusic;
[ConditionalField("_initialBackgroundMusic")]
[SerializeField] AudioClip _initialBackgroundMusicToPlay;

Excellent plugin and excellent developer support so far! Thank you!

Updates don't work

I just got the message in my log to update MyBox. So I followed the instructions and the update button no longer seems to work. So I just took the latest commit hash from GitHub and replaced that in my manifest.json in my packages folder.

Vector3 ConditionalField warning

Hi, and thanks for these additional attributes.
I am using ConditionalAttribute to show Vector3 fields based on a boolean property. Although this seems to work correctly, I receive this warning every time tick/unitick the attribute.

Property _maxRotationLimits on behaviour GyroObject caused: [ConditionalField] does not work with UnityEngine.Vector3. Unable to find property drawer from the Type

I am using Unity 2019.3. Is there anything we can do to remove these warnings?
Where are the Drawers?

Thanks again.

Creating a prefab in an empty directory

A prefab cannot be created in a newly created empty directory. When I drag the gameobject into the directory, the directory is already gone, cleaned up by the empty dir remover.
Unity gives me an error saying dir not found.

I use Unity 2018.3.7f1

ConditionalField breaks multi-editing in inspector

As I just discovered, [ConditionalField] breaks the multi-object editing when multiple instances of a ScriptableObject are selected. And this is a crucial feature to have when dealing with a lot of ScriptableObjects.

Can you please take a look? I myself is following some editor tips to amend this behavior, if I find a solution or a workaround (e.g. hiding only the unsupported fields when multi-selected), I'll let you know.

Using two ConditionalFields for two fields.

Hello,
Would it be possible to do something like:

public bool InstantiateLevelPrefab;
[ConditionalField("InstantiateLevelPrefab",true)]
public int StartFromLevel = 0;
[ConditionalField("InstantiateLevelPrefab", false)]
public GameObject PrefabLevelToDebug;

Like ifInstantiateLevelPrefabis true show option 1 and if it is false to show option 2.

Dependency between imported asset and Preset asset.

Hey there!
I've found your project on the Preset blog post on Unity's website, glad that people are looking into it and doing some nice custom stuff with it!

I got one comment for you regarding this file: Tools/AssetPresetPreprocessor/AssetPresetPreprocessor.cs
When applying a Preset to an asset, you probably want that asset to be re-imported whenever the Preset used to enforce the settings get changed, and this is possible starting in 2019.3 and using asset database v2.
You have to call context.DependsOnSourceAsset(AssetDatabase.GetAssetPath(preset)) before applying the preset to the importer. This way you get assured of two things:

  • Your asset will not be imported before the Preset is discovered by the asset database (or if it does, it will stop importing at that point and will wait for the Preset asset to be imported first).
  • Your asset will trigger a re-import automatically to use the new Preset setting whenever the Preset asset is changed on disk (when updating your project from a VCS or changing the Preset values and using Save Assets).

We also have a bunch of improvements coming in 2020.1 for presets, including the PresetManager being able to handle folders and any naming convention you want, along with Partial Preset that allows you to exclude properties from the Preset directly in the Preset or its inspector. You may want to have an early look at that as you're a doing a bunch of stuff that may not be necessary anymore after this release.

ConditionalField performance issue

Super useful repo! Thank you for sharing it ๐Ÿ‘

I have been using the ConditionalField attribute and, while very powerful, it is giving me performance issues. Even with the basic "bool" condition mode, if causes significant hiccups on the editor. This happens when when enabling/disabling the target bool OR whenever I interact in any other way with the script.

Is there anything that could be done to fix it, or at least to limit the lag/hiccup to happen only whenever we enable/disable the bool ?

Thanks!

ConditionalFieldAttribute aligns improperly as array elements [Bug]

A bug, where creating an array property that contains ConditionalFieldAttribute fields for the inspector, it can often get misaligned when showing/hiding fields as shown in these screenshots below:
FirstScreenshot_bug, SecondScreenshot_bug, ThirdScreenshot_bug

To reproduce:

  1. Create a Serializable class.
  2. Put some fields inside the Serializable class, with some of them containing a ConditionalFieldAttribute.
  3. Create a MonoBehaviour script, and have it take in an array of the created class in the inspector.
  4. Configure around with the inspector to hide/unhide fields, and bug will appear.

Script used when encountering this bug (If the above was didn't work)

using UnityEngine;

[System.Serializable]
public class SpellOption {
    [Header("Base Spell Options")]

    [Tooltip("The shooter(s) this spell has.")]
    public BaseShooter[] shooters; //BaseShooter is a mono-behaviour script

    [Tooltip("The fire-rate of this spell.")]
    public float fireRate;

    [Tooltip("The delay before activating this spell.")]
    public float activationDelay;

    [Header("Scaling Options")]

    [Tooltip("True to scale this spell as the boss's health drops.")]
    public bool scaleByHealth;

    [ConditionalField("scaleByHealth", true), Tooltip("The firerate scale as the boss health drops.")]
    public float fireRateScale;

    [ConditionalField("scaleByHealth", true), Tooltip("The speed of the bullet to scale as the boss health drops.")]
    public float bulletSpeedScale;

    [ConditionalField("scaleByHealth", true), Tooltip("The acceleration of the bullet to scale as the boss health drops.")]
    public float bulletAccelerationScale;
}
/// Somewhere over the rainbow...
    [Separator("Spell Card Properties", true)]

    [SearchableEnum, SerializeField, Tooltip("The name of this spell card")]
    private SpellCardName spellCardName;

    [SerializeField, Tooltip("The spell options for this spellcard")]
    private SpellOption[] spellOptions;
    // More stuff

Though I might add that the fields in the inspector seems to align correctly when all conditional fields are either shown or hidden.

Null Reference error when using Conditional Field

For some reason sometimes when I use the Conditional field I get a null reference error. I have no idea why besides it has something to do with the if statement on line 78 of the conditional field attribute script. If I am reading it right it is checking if I have more than one condition attached to the variable, which I do not. If I am reading it wrong than my bad. But when I comment out line 78 it works perfectly fine.
Screen Shot 2020-02-06 at 3 32 51 PM
If I have a bunch of variables with a conditional field attached to each the first one with a conditional field will sometimes get the null reference exception.
Screen Shot 2020-02-06 at 3 34 06 PM
The variables under base stats work perfectly fine. The variables under specific body stats work fine except the first variable. It throws this null reference error.
Screen Shot 2020-02-06 at 3 35 26 PM

Conditional based on not null property

Is it possible to use the ConditionalField attribute to only show a field if another field is not null? For example, only show a quantity Int field if a quantityText GameObject field is not null.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.