Search Unity

[Open Source] VFW (135): Drawers. Save System and full exposure

Discussion in 'Assets and Asset Store' started by vexe, Sep 2, 2014.

  1. dtaralla

    dtaralla

    Joined:
    Jan 1, 2016
    Posts:
    16
    Difficult to say what I mean I think :p Let's talk in code and you will see:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Reflection;
    4. using System.Collections.Generic;
    5. using Vexe.Editor.GUIs;
    6. using Vexe.Editor.Visibility;
    7. using Vexe.Runtime.Types;
    8. using System;
    9.  
    10. public class CoinGeneratorEditor : EditorWindow {
    11.     private BaseGUI gui;
    12.     private List<MemberInfo> members;
    13.     private int id;
    14.  
    15.     public Generator generator;
    16.  
    17.     private void OnEnable() {
    18.         id = Guid.NewGuid().GetHashCode();
    19.         members = VisibilityLogic.CachedGetVisibleMembers(GetType());
    20.     }
    21.  
    22.     private void OnGUI() {
    23.         if (gui == null) {
    24.             gui = BaseGUI.Create(typeof(RabbitGUI));
    25.             Repaint();
    26.         }
    27.  
    28.         gui.OnGUI(GUICode, new Vector2(5f, 5f), id);
    29.     }
    30.  
    31.     private void GUICode() {
    32.         foreach (var member in members)
    33.             gui.Member(
    34.                 member, // the member that we're drawing
    35.                 this,   // the unity target object, used for undo
    36.                 this,   // the object that the members belong to, in this case its the same object
    37.                 id,     // a unique id. used for foldout values and hash codes
    38.                 false); // whether we want to ignore composite drawers for our members or not
    39.     }
    40.  
    41.     [Serializable]
    42.     public abstract class Generator {
    43.         protected Stack<List<GameObject>> mHistory = new Stack<List<GameObject>>();
    44.  
    45.         public abstract void Generate();
    46.  
    47.         void UndoGeneration() {
    48.             ...
    49.         }
    50.     }
    51.  
    52.     [Serializable]
    53.     public class GenerateQuadratic : Generator {
    54.         public override void Generate() {
    55.             ...
    56.         }
    57.     }
    58.  
    59.     [Serializable]
    60.     public class GenerateCircle : Generator {
    61.         public Vector2 CenterOffset;
    62.  
    63.         public override void Generate() {
    64.             ...
    65.         }
    66.     }
    67. }
    68.  
    When I do this, I would like the clickable circle next to the "generator" field to let me select, under System Type tab, between GenerateQuadratic and GenerateCircle. And once this is done, showing the public fields of the selected implementer (GenerateQuadratic or GenerateCircle) so that I can parametrize it, a bit like what I think you meant to demonstrate with your interface field "Itface" "in the DrawersInEditorExample.cs.
     
  2. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @dtaralla Seems like I have to give this drawer a revamp when I have some free time (always a tricky caveat)...
    Again, similar to ShowType, it seems that I F*ed something up in those GetAllUserTypesOf calls doing fancy caching refactoring at some point... Apologies.

    Anyway, around line ~111 the 'var systemTypes = ...' line, replace it with (for now):
    Code (csharp):
    1.  
    2. var systemTypes = AppDomain.CurrentDomain.GetAssemblies()
    3.   .SelectMany(x => x.GetTypes())
    4.   .Where(t => t.IsA(memberType) && !t.IsA<UnityObject>() && !t.IsAbstract)
    5.   .ToArray();
    6.  
     
  3. dtaralla

    dtaralla

    Joined:
    Jan 1, 2016
    Posts:
    16
    Awesome, it works now :)
    Thank you again for your fast answers!
     
  4. Cupal

    Cupal

    Joined:
    Jan 2, 2015
    Posts:
    2
  5. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @Cupal Yes I found the solution. The solution is to use BaseBehaviour instead of BetterBehaviour, forget about custom serialization and stick to what you get with Unity's serialization, or pick a data-driven approach like I mentioned above in my titanic post and you could forget about serialization all together. BaseBehaviour: Trust me you'll save yourself a ton of headaches.
     
  6. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Is there an attribute to initialize POCO properties (that is, non-monobehaviours with default constructors)? Or should I overload the Default attribute?
     
  7. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @duke sorry I'm not sure what you mean exactly. Could you give an example of what you're trying to achieve?
     
  8. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    What I was looking for was [Default(Instantiate = true)].
     
  9. varunvp

    varunvp

    Joined:
    Jul 11, 2014
    Posts:
    57
    Hey Vexe, I got the following error when I opened your project.



    I tried doing this


    I got this
     
    Last edited: Feb 27, 2016
  10. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I've got a problem. When I import another plugin and the API Updater of Unity wants to update this happens:

    Failed to run script updater.
    Please, report a bug to Unity with these details


    System.UnauthorizedAccessException: Access to the path 'Assets/Plugins/Vexe' is denied.
    at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
    at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
    at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    at Mono.Cecil.ModuleDefinition.GetFileStream (System.String fileName, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00000] in <filename unknown>:0
    at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName) [0x00000] in <filename unknown>:0
    at APIUpdater.Framework.Util.StringExtensions+<CollectAssemblyReferencesAndDependencies>c__Iterator0`1[Mono.Cecil.AssemblyDefinition].MoveNext () [0x00000] in <filename unknown>:0
    at CSharpUpdater.Core.CSharpProjectHelper.ProjectFor (System.Collections.Generic.List`1 sources, IEnumerable`1 references) [0x00000] in <filename unknown>:0
    at CSharpUpdater.CSharpUpdater.RunUpdater (APIUpdater.Framework.Core.SourceFile[] inputs, IEnumerable`1 defines, IEnumerable`1 references) [0x00000] in <filename unknown>:0
    at APIUpdater.Framework.Core.APIUpdaterBase.Update (APIUpdater.Framework.Core.SourceFile[] inputs, IEnumerable`1 defines, IEnumerable`1 references) [0x00000] in <filename unknown>:0
    at ScriptUpdater.Program.UpdateLanguage (IScriptUpdater updater, APIUpdater.Framework.Configuration.CompilerResponseFile responseFile, System.String unityDataPath, System.String outputPath) [0x00000] in <filename unknown>:0
    at ScriptUpdater.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
    UnityEditor.Scripting.Compilers.ScriptCompilerBase:BeginCompiling()
     
  11. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @varunvp Check your build settings? It might be turned on to WebPlayer. How are you importing the package? via the .unitypackage or just download the zip and extracting from github?

    @BTStone No idea why would it give you an access defined. Try importing to a new project see if it causes the same issue? If so, report that new project along with VFW to Unity.

    Full-time job here, I'll try to find some time to do an update, it's been a while.
     
  12. varunvp

    varunvp

    Joined:
    Jul 11, 2014
    Posts:
    57
    Yup, it's on webplayer. And I extracted the .zip directly and opened it as a new project. Did I do something wrong?
     
  13. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Yeah sorry seems it's not playing super well with WebPlayer. Will address that in next update. For now you could probably wrap the calls with #if !UNITY_WEBPLAYER or something.

    Usually I recommend users to import the .unitypackage in the zip, but it's been a while since that's been updated and people have been making pull request and adding features to the framework without actually having to update that .unitypackage, so yeah for now .zip is the latest I think. Will try my best to find time to do the update this week.
     
  14. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Doing some updates. Deprecated a lot of stuff, mostly the runtime seiralization stuff. @varunvp fixed WebPlayer issue.

    I was just wondering if anyone used FastSave, if so, what was your experience? Would love to hear some feedback.

    As it currently stands, it uses fast reflection to do stuff, and I've been experimenting a lot lately with meta-programmed serializers, so far they seem to work the best, simplest and fastest, no reflection, no dynamic IL, no nothing. That way I could move a lot of the reflection extensions and helpers from the runtime side to the editor folders, cause that's where they're mostly used.
     
  15. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Pushed 1.3.5

    Runtime serialization features have all been deprecated (BetterBehaviour/BetterScriptableObject). There will be no more support to them, and will probably be completely removed in VFW 1.4

    VFW is back to its roots, being an editor-only extension package with major focus on drawers and attributes.

    Fast Save is still there and supported, it has nothing to do with the custom serialization stuff BetterBehaviour had.

    Me and many users had tons of issues regarding hacking Unity to make custom serialization work to serialize generics, interfaces, properties, delegates etc. I've ranted about this a lot (#441, #351), all of these features are not worth the trouble. Stick to simple data types and public fields and you should be OK.

    Also note there's no more .unitypackage included when you download the zip from github, there's no point to it. There's now "Plugins", "VFW Examples" and "VFW Deprecated". All you need is the "Plugins" folder.
     
    Last edited: Mar 6, 2016
  16. varunvp

    varunvp

    Joined:
    Jul 11, 2014
    Posts:
    57
    Thanks for the update. I will download and try out the new version today!
     
  17. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @varunvp You're welcome. Take note though, the fix I added was just #if !UNITY_WEBPLAYER around that code.
    So if you do need to use those functions in the editor you have to switch to PC build temporarily, make your edits etc and switch back to WebPlayer when you want to build. I hope that's OK and not super inconvenient, if it is let me know.

    PS: you do know that Unity deprecated WebPlayer right?
     
  18. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    OK, so for anyone who used BetterBehaviour and custom serialization extensively in their projects and don't want/like the feature downgrade in 1.3.5. before you get pissed and start swearing. First, all the features are still there, they're just under the deprecated folder. Second, you could still reliably use 1.3.4, it's fully-featured and robust. In fact I would recommend that if you're deep into your project. You could make the switch later in another project.

    Unity's serialization is fundamentally broken. Working around to hack ads more broken to broken. I will try to focus more and bring user attention to more data-driven approaches which makes Unity's serialization totally obsolete. At work, we don't have a single serialized field or type. Combined with meta-programming techniques and VFW editor power, you could do whatever it is that you want. So I'm NOT leaving you behind. Deprecating that stuff is the first step to get to that.

    I will try to find more free time for a more detailed write-up about those alternatives.
     
    BTStone likes this.
  19. varunvp

    varunvp

    Joined:
    Jul 11, 2014
    Posts:
    57
    I was playing around with your system yesterday, and I found that you have 2 features in Fast Save - one is Save Marked. other is Save Hierarchy. Problem with save marked is that if you mark the children of an object and save it, the child objects' local transform is stored. When you load it back, it loads it as a world transform with respect to the root game object(Can't correctly describe it, but you get the idea. Ex- I created a vehicle with a turret attached on it. All the turret''s components were marked, and the root's too. I saved it, moved the vehicle some distance and loaded it back. The turret was disjointed from the vehicle)

    So I will have to remove the Transform object from all the children's FS Marker scripts that I have marked(which is inconvenient). Maybe Save Hierarchy was created for this purpose? Anyway, wanted to bring this to your attention so that you could fix this, if you consider this a bug. My suggestion is to let the user have an option to mark the Transforms, if he wants to.

    Thanks!
     
    Last edited: Apr 4, 2016
  20. mruce

    mruce

    Joined:
    Jul 23, 2012
    Posts:
    28
    Hi @vexe, I'm using VFW in my latest projects and it's great. I'm stuck on one issue though - in my component I have a ScriptableObject field; I'd like to edit it's internals directly in a parent component inspector (default behavior is that I see only name of a ScriptableObject and it's internals are revealed after double clicking on it - as a separate Inspector view). Perfect solution would be to have o fold-out with all the details hidden inside. How can I achieve this? Tried different approaches already, but no luck so far.
     
  21. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @mruce there's [Inline] attribute which does exactly what you describe (works on Components and GameObjects), but I'm not exactly sure it's tested with ScriptableObjects, I might need to add support for that.

    @varunvp Yeah I was originally saving local position/rotation, but I remember having a problem that lead me to store world position/rotation, I'll look into it whenever I get the chance. Sorry for the late reply but I'm barely getting any free time to do stuff. The code should be straight-forward for users to jump in and modify/tweak to their liking/fix bugs so you could give that shot too!
     
  22. sanchoflat

    sanchoflat

    Joined:
    Jun 9, 2013
    Posts:
    14
    hey @vexe, thanks for awasome tool! I'm interested, is it avaliable to do this:

    Code (CSharp):
    1. public enum TestEnum {
    2.     /// <summary>
    3.     /// Description 1
    4.     /// </summary>
    5.     One,
    6.  
    7.     /// <summary>
    8.     /// Description 2
    9.     /// </summary>  
    10.     Two,
    11.  
    12.     /// <summary>
    13.     /// Description 3
    14.     /// </summary>
    15.     Three
    16. }
    And in inspector i will see Description 1, Description 2, Description 3 instead of One, Two, Three.
    Thanks for answer.
     
  23. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @sanchoflat Currently no. But it wouldn't be hard to add support for it. Instead of the comments, you would annotate with an attribute. Something like this:

    Code (csharp):
    1.  
    2. public enum Test
    3. {
    4.     [Desc("Description 1")] One,
    5.     etc...
    6. }
    7.  
    You need to modify the enum drawer for that. I'll see if I have free time to do it this weekend.
     
  24. sanchoflat

    sanchoflat

    Joined:
    Jun 9, 2013
    Posts:
    14
    @vexe, wow, really thanks. It.s awasome!
     
  25. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Heye @vexe
    So lately I get these error-messages with BetterBehaviours, like this:




    I also experienced some weird "S***" happening. A big bunch of my objects in my scenes which also were prefabs changed specific values of specific scripts. I don't know when and how this happene,d but for certain reasons I couldn't use "Revert" on all of the objects, so I had to go through them manually, which was a bit of a pain in the ass.

    As of now it happened once, to be fair, but boy was it nasty :p

    I'm assuming it's connected to these issues in a way that the serializer didn't do as expected. But I had the impression that we didn't used your serialzer at all (if so, how can we change that?)

    That being said: is there away to fix these errors?

    We're on Unity 5.3 and on VFW 1.1.0, at least that's what the License-Doc tells me
     
  26. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hmpf, as of yesterday I get these errors all the time when starting up Unity, playing a scene and stop playing a scene in the Editor :/
     
  27. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I've read your post about OOP... and I have to say I quite disagree.

    OOP is like any other tool of a language; a tool. If you try to use it everywhere, it sucks. If you don't use it at all, it sucks. You don't hammer down a screw... You can, but it will suck. Each tool have its purpose, and should be use in the situation where that tool is the best solution.

    In short, if you try to OOP/Interface/Uncouple everything, you're a moron. If you don't OOP/Interface/Uncouple anything, you're also a moron. In both case you fail to understand the proper usage of your tools.
     
  28. WolveX

    WolveX

    Joined:
    May 31, 2016
    Posts:
    49
    Hello @vexe
    In the latest version I am getting this error when open an EditroWindow:
    Window => Vexe => Examples => DrawersInEditorWindow

    Code (CSharp):
    1. Exception: Generating constructor for type: Vexe.Editor.GUIs.RabbitGUINo empty constructor found!
    2. Vexe.Runtime.Extensions.FastReflection.GenCtor[Object] (System.Type type, System.Type[] paramTypes) (at Assets/Plugins/Vexe/Runtime/Libs/Extensions/FastReflection.cs:322)
    3. Vexe.Runtime.Extensions.FastReflection.DelegateForCtor[Object] (System.Type type, System.Type[] paramTypes) (at Assets/Plugins/Vexe/Runtime/Libs/Extensions/FastReflection.cs:49)
    4. Vexe.Runtime.Extensions.TypeExtensions.Instance[BaseGUI] (System.Type type, System.Type[] paramTypes) (at Assets/Plugins/Vexe/Runtime/Libs/Extensions/TypeExtensions.cs:57)
    5. Vexe.Runtime.Extensions.TypeExtensions.Instance[BaseGUI] (System.Type type) (at Assets/Plugins/Vexe/Runtime/Libs/Extensions/TypeExtensions.cs:52)
    6. Vexe.Editor.GUIs.BaseGUI.Create (System.Type guiType) (at Assets/Plugins/Editor/Vexe/GUIs/BaseGUI/BaseGUI.cs:185)
    7. VFWExamples.DrawersInEditorWindowExample.OnGUI () (at Assets/VFW Examples/Editor/DrawersInEditorWindowExample.cs:50)
    8. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  29. markoal

    markoal

    Joined:
    Aug 31, 2015
    Posts:
    30
    Hi, I was wondering if I could achieve something like this:
    • I Have multiple classes that inherit from Base Class
    • When I use "public Base base;" I can select from dropdown One of inherited classes I want, and set their properties.
    • When I chose (see code) BaseA class, it should draw me two more selections to choose from,
    I tried to achieve it without this plugin, simply by using helper class like "AllBases" and just show which one I want, but there is a problem with composition.

    Code (CSharp):
    1. public class Base
    2. {
    3.     protected virtual bool Test() { return false; }
    4. }
    5. public class BaseA:Base
    6. {
    7.     public Base A;
    8.     public Base B;
    9.     protected override bool Test()
    10.     {
    11.         //Custom Test
    12.         return base.Test();
    13.     }
    14. }
    15.  
    16. public class BaseC:Base
    17. {
    18.     public int number;
    19.     protected override bool Test()
    20.     {
    21.         //Custom Test
    22.         return number>0;
    23.     }
    24. }
     
  30. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    865
    Hi! Is it possible to have Dictionary where value is float but with slider?
    Dictionary<int,float> DifficultyFactor = new Dictionary<int,float>();

    Thanks!
     
  31. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    865
    Hi I have one more question, is it possible that when value in slot for some component (Transform, GameObject or something else) is changed in inspector how to get the callback. Tag "OnChanged" doesn't seem to work here
     
  32. Edvard-D

    Edvard-D

    Joined:
    Jun 14, 2012
    Posts:
    129
    Hey, thanks for putting this together. Glad I came across it when I did since it's saved me a huge headache!

    One clarification: #10 of the FAQ on Github says you should use [Serialize] rather than [SerializeField]. When I try to use [Serialize] it doesn't appear to be implemented. Is this possibly out of date info in the FAQ, or am I maybe missing something?

    Thanks again for the work you've put into this :)

    EDIT: Wanted to clarify that I am using Vexe.Runtime.Types.

    EDIT 2: It seems that interface fields made public using [SerializeField] are being wiped on play. Possible bug?
     
    Last edited: Sep 11, 2016
  33. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    865
    Hi! Can somebody help me with this

    I have this line
    Code (CSharp):
    1.  [Comment("Lorem ipsum dolor sit amet, mea at civibus euripidis. Quot electram sadipscing ea sea, ad ius verterem pericula adversarium")
    2.         ,OnChanged("OnStringsChanged"),
    3.         Display(Seq.Advanced | Seq.PerItemDuplicate | Seq.Filter | Seq.GuiBox | Seq.LineNumbers)]
    4.     [PerItem, Button("Add")]
    5.     public List<string> Strings = new List<string>();
    but it seems that comment is put on every item i add in the list, i need just comment,how to do that?
     
  34. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    Everything I set on inspector that this plugin exposes gets viped out when I hit play. If it doesn't save the values, what is the point of exposing them in inspector? Am I missing something?
     
  35. FBones

    FBones

    Joined:
    Aug 28, 2016
    Posts:
    73
    Question: does this allow properties to be saved?

    In particular, if I have properties on a scriptableObject that I change in the editor, will those properties persist from one session to another? Currently they don't because Unity does not serialize properties.
     
  36. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    402
    Fbones, have you tried making those properties and their backing fields public?
     
  37. FBones

    FBones

    Joined:
    Aug 28, 2016
    Posts:
    73
    Sure, if I create a backing field, then the backing field will be serialized and saved... but I was hoping not to create backing fields for all my auto-implemented properties just for the sake of persistence. I'm to avoid having a bunch of public variables, but I also have lots of components that need to talk to one another, so that means lots of properties.
     
  38. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    402
    No way around it, really.
     
  39. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    Thanks for the great asset, the [show] tag really saves a lot of time when debugging methods ( you don't have to write some code or create gui to call the new method to test it)
     
  40. xarismax

    xarismax

    Joined:
    Jul 22, 2015
    Posts:
    11
    hi vexe, Are you still alive ?

    I think creating BetterBehavior was the correctiest decision of your life.
    1) It serialises 1.000.000% more correctly than Unity serialiser. I can serialize interfaces and create subclasses, with custom values fine, they are even saved by value when you hit play mode. No changes happen to them while playing.
    2) It creates good habbits, unity becomes as easy as modding warcraft3 and starcraft. No need to write code.
    3) it promises you, and delivers its promise, 100%. Not a single time did BetterBehavior got data damaged. In contrast evil unity loses your data if you dare rename a field. Except if you use [FormerlySerializedAsAttribute]
    4) you can implement VexeFTW to save scene to scriptableobject instead a .scene file. So your corruption concern is nonexistent.

    Conclusion:
    5) i dont understand any of your "Just forget about it, just forget about it...", nope i will still remember it and use BetterBehaviour, afterall it is BETTER.
    6) The decision to depracate BetterBehaviour was invalid, until proven otherwise.
    7) You mentioned speed. Spending a week, copy pasting your entire codebase, creating implicit operators, having 4 times defined the same class just for unity to serialise it is dumb. I am sure BetterBehavior is FASTER than Redudancy, Evil Generics, and all the luggage unity brings. Did i mention x4 "assembly" projectes caused by EviloBehaviours?
     
  41. varunvp

    varunvp

    Joined:
    Jul 11, 2014
    Posts:
    57
    I'm getting the following error, when I load a hierarchy from a file, in a particular scene:

    I don't know what I'm doing wrong. It works perfectly in the example scene. Is it because the amount of data being stored is huge? This is the code I'm using to load data:

    Code (CSharp):
    1.             Load.HierarchyFromFile(Application.dataPath + "/Resources/Saved Data/SavedAI.gd", AI);
    2.  
     
  42. varunvp

    varunvp

    Joined:
    Jul 11, 2014
    Posts:
    57
    OK, this is a new error I'm getting now. Was fine until I screwed up something, but even after reverting the changes, it shows this now.

    I have commented out the following code for now, from where it originates

    Code (CSharp):
    1. if (add)
    2.                     throw new ArgumentException("Key already exists: " + key);
    in SerializableDictionary.cs

    It's just a quick fix though, and it gives me another problem.

    Bring up the context menu by right clicking the component, click on save behaviour and then load behaviour. That solved the problem for me, very recently.
     
  43. gooopil

    gooopil

    Joined:
    Jul 16, 2015
    Posts:
    4
    Hi vexe (and other readers!),

    I wanted to use the VisibleWhen attribute in combination with an Enum field to only show relevant fields in a custom class (not a monobhaviour), depending on the selected value.
    - First hurdle: seems I can't test for an enum value directly in a VisibleWhen attribute, and the test has to be done on a boolean or parameterless call backs. It's OK I guess, but it means I have to keep a giant switch up-to-date with the possible enum values.
    - Second hurdle: with the structure explained above, only when the enum is changed are the booleans refreshed. Meaning that none of the fields show up when the inspector is displayed a second time (for instance, after closing Unity). To see these fields, I would have to change the enum value back and forth. Not very practical to edit data.

    Any tips?
    Thanks :)
     
    Last edited: May 22, 2017
  44. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    Hi folks,

    Can this framework be used with FullSerializer ?

    Do they have any known problems working together?

    Thanks.