deadcows / mybox Goto Github PK
View Code? Open in Web Editor NEWMyBox is a set of attributes, tools and extensions for Unity
Home Page: http://deadcow.ru
License: MIT License
MyBox is a set of attributes, tools and extensions for Unity
Home Page: http://deadcow.ru
License: MIT License
When I'm building for android, this error emerges.
Text version of the error: https://pastebin.com/xp9Xgxk9
I had to create the "\Assets\Misc\Configs" path, and a dummy file to prevent it from being auto removed.
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.
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.
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.
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)
[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.
This looks useful, but you've not provided any LICENSE file. Would you mind adding one?
RangedFloat inspector is a really useful editor utility. Same way, can we have a RangedInt inspector? Is it possible to implement the range slider for a discrete value range?
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.
Since this package already supported installation via Unity Package Manager, it'd be great to have it registered on OpenUPM as well.
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.
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:
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.
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.)
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.
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.
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.
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.
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.
As the title says - would be nice implementation :)
It's showing the same code sample as for the ReadOnly attribute.
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
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.
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:
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!
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
ConditionalFieldAttribute
.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.
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()
Would be nice to make more complex conditional fields, including AND OR operators. :)
It doesn't seem like this is currently included.
(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?
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.
https://github.com/Deadcows/MyBox/wiki/Tools-and-Features#iprepare
Both code snippets have typos in function name FindObhectsOfType<Waypoint>()
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?
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?
Yet another trivial and minor bug where ConditionalFieldAttribute
does not hide HeaderAttribute
, as shown in both of these screenshots:
ShootAngleRotationSpeed
is shown, true)ShootAngleRotationSpeed
is hidden, but the header attribute is not.) [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.
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 ifInstantiateLevelPrefab
is true show option 1 and if it is false to show option 2.
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
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.
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)
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!
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;
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.
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.
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
Hello I've read your comment in this thread
https://answers.unity.com/questions/192895/hideshow-properties-dynamically-in-inspector.html
Somehow your method is more flexible and when I look for the drawer script it send me to an error 404 since I think you've replaced it with another code or decided to put an all in one solution on GUI Drawer.
I was wondering what is the script your are using right now for the conditionalfield drawer
Thank you.
[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.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.