Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Assets [Free][Open Source] Stackable Decorator - property drawer with multiple stackable decorator

Discussion in 'Works In Progress - Archive' started by lokinwai, Jan 30, 2018.

  1. lokinwai

    lokinwai

    Joined:
    Feb 11, 2015
    Posts:
    174
    Add RepeatValue:

    2018-03-23 07-20-30.gif

    Code (CSharp):
    1. [RepeatValue(5, 15)]
    2. [StackableField]
    3. public float num7;
     
  2. lokinwai

    lokinwai

    Joined:
    Feb 11, 2015
    Posts:
    174
    Add RadToDeg and DegToRad:

    2018-03-23 16-50-47.gif

    Code (CSharp):
    1. [Label(title = "$", order = 1)]
    2. [RadToDeg]
    3. [StackableField]
    4. public float rad;
    5.  
    6. [Label(title = "$", order = 1)]
    7. [DegToRad]
    8. [StackableField]
    9. public float deg;
     
  3. corintho

    corintho

    Joined:
    Oct 14, 2011
    Posts:
    10
    Thank you so much for this, it really helped me a lot during my current development of simple custom editors.

    I am currently using InlineProperty with Expandable to present inline data about some custom ScriptableObjects I created. What I am currently wondering is if it is possible to present some information when Expandable is collapsed.

    This is currently what I have:
    upload_2018-5-1_15-50-19.png

    What I would like to do is to have "Base Cost" in my sample above to show it's value in a custom String presentation (in my case a scientific notation: "1.0e005") is that currently possible? If not, would you be willing to accept a pull request with this kind of feature?

    Thanks,
    Corintho
     
  4. lokinwai

    lokinwai

    Joined:
    Feb 11, 2015
    Posts:
    174
    I think you need to modify the source yourself, I can give you some hint:

    Modify InlinePropertyAttribute.cs, in GetHeight()
    Code (CSharp):
    1. var result = InlineProperty.GetHeight(data.serializedObject, data.propertyHeights);
    Change to:
    Code (CSharp):
    1. var result = property.isExpanded ? InlineProperty.GetHeight(data.serializedObject, data.propertyHeights) : EditorGUIUtility.singleLineHeight;
    In BeforeGUI(), remove:
    Code (CSharp):
    1. if (!always && !property.isExpanded) return visible;
    In AfterGUI()
    Code (CSharp):
    1. InlineProperty.Draw(rect, data.serializedObject, false, data.propertyHeights);
    Change to:
    Code (CSharp):
    1. if (property.isExpanded)
    2.     InlineProperty.Draw(rect, data.serializedObject, false, data.propertyHeights);
    3. else
    4.     do something with rect and data.serializedObject
     
  5. FireMutant

    FireMutant

    Joined:
    Sep 2, 2013
    Posts:
    49
    Hi Lokinwai,
    I just stumbled onto this asset because I bought Hierarchy Plus (which is awesome!). Stackable Decorator is another great asset.

    Thanks for sharing it!
     
    lokinwai likes this.
  6. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
    Anyone got any clue how I make BIG label or header. style="BoldLabel" just isn't big enough for what I need. Thanks
     
  7. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
    Hi, I have a slightly more complex question. I have a LIST of which script is [ExecuteInEditMode]. Everything is working fine except that when I add this new component to my object inside the editor (drag and drop) I get errors because at first the List doesnt seem to exist. I am checking for the list in the OnGUI function of my script. If I add something to the list then the error goes away, (or if I recompile the code) but how do I stop the errors happening when I initially add the new script?

    Error: NullReferenceException: Object reference not set to an instance of an object
    at line: public List<Data> dataList { get { return m_DataList.list; } }

    Code (CSharp):
    1. void OnGUI()
    2.     {
    3.         if(dataList==null)
    4.         {
    5.             Debug.Log("NULL LIST");
    6.          
    7.         }
    8.         else
    9.         {
    10.             Debug.Log("VALID LIST");
    11.         }
    12.     }
    13.  
    14.     [List]
    15.     [SerializeField]
    16.     private DataList m_DataList;
    17.     public List<Data> dataList { get { return m_DataList.list; } }
     
  8. lokinwai

    lokinwai

    Joined:
    Feb 11, 2015
    Posts:
    174
  9. lokinwai

    lokinwai

    Joined:
    Feb 11, 2015
    Posts:
    174
    It looks like m_DataList is null, you can use:
    private DataList m_DataList = new DataList();
     
  10. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    227
    This is by far the most powerful editor helper I've ever used. Thanks for the great work!
     
  11. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    227
    @lokinwai There seems to be a tiny little error in the
    LayerPopupAttribute
    . It causes the build fail.

    Change
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditorInternal;
    3. using System.Linq;
    4. #if UNITY_EDITOR
    5. using UnityEditor;
    6. #endif
    7.  
    to

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Linq;
    3. #if UNITY_EDITOR
    4. using UnityEditorInternal;
    5. using UnityEditor;
    6. #endif
    7.  
     
  12. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    335
    Unity should hire you.
    Awesome work.
     
  13. Gohloum

    Gohloum

    Joined:
    Nov 29, 2018
    Posts:
    12
    I just posted a bug on your GitHub. Seems with the newer versions of Unity the DynamicMethod() no longer exists. Here is the error on the console after downloading and allowing Unity to recompile:

    Assets/StackableDecorator/Utils/ReflectionUtils.cs(52,30): error CS0246: The type or namespace name 'DynamicMethod' could not be found (are you missing a using directive or an assembly reference?)

    I'm running V 2019.x of unity, but while searching I have found a few details that suggest it was removed with the framework as far back as V 2018.