Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Plugins unification

Discussion in 'Assets and Asset Store' started by PrefabEvolution, Jan 31, 2015.

  1. PrefabEvolution

    PrefabEvolution

    Joined:
    Mar 27, 2014
    Posts:
    225
    Hi. Today i would like to discuss about plugins unification. It's very common case when two or even more plugins have conflicts with each other. And i would like to share some code, and try to solve this problem.
    And here is a code to solve hierarchy window conflicts. Fell free to include this code to your plugins.
    Code (csharp):
    1.  
    2. using UnityEditor;
    3. using UnityEngine;
    4. using System.Collections.Generic;
    5.  
    6. namespace PluginsShared
    7. {
    8.     static public class HierarchyDraw
    9.     {
    10.         //Must return non consumed rectangle to draw
    11.         public delegate Rect DrawCallBack(int instanceID, Rect itemRect);
    12.  
    13.         private static readonly SortedList<int, DrawCallBack> callbacks = new SortedList<int,DrawCallBack>();
    14.  
    15.         //Init
    16.         static HierarchyDraw()
    17.         {
    18.             EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemOnGui;
    19.         }
    20.  
    21.         //Add callback with priority
    22.         static public void RegisterCallBack(DrawCallBack callback, int priority)
    23.         {
    24.             callbacks.Add(priority, callback);
    25.         }
    26.  
    27.         //Remove call back
    28.         static public void RemoveCallBack(DrawCallBack callback)
    29.         {
    30.             callbacks.RemoveAt(callbacks.IndexOfValue(callback));
    31.         }
    32.  
    33.         //Call all registered callbacks
    34.         private static void HierarchyWindowItemOnGui(int instanceId, Rect selectionRect)
    35.         {
    36.             var rect = selectionRect;
    37.             foreach(var drawCallBack in callbacks)
    38.                 rect = drawCallBack.Value(instanceId, rect);
    39.         }
    40.     }
    41. }
    42.  
     
    Last edited: Jan 31, 2015
    tosiabunio and thienhaflash like this.
  2. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    512
    Seems promissing, I will absolutely update my Hierarchy2 to support this in the next update, but maybe you can give a static public link for the lastest release (.unitypackage) so we always point to the lastest version !

    I'm not sure how to do it yet but I also need the information about the lastest rect that does not has any icons overlay, after all icons being drawed (I need to overwrite the default context menu), so maybe you can have someway to retrieve that rect so I can check and show the context menu only when there are no icons behind my mouse.

    So, maybe a bitbucket / github source collaborate ?
     
    Last edited: Feb 1, 2015
  3. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    512
    Any update on the public repository and a direct link to import this thing, man ? I come to a point where I need to organize who come first and come last in the hierarchy drawing, maybe a priority or something, also the ability to tell other plugins to stop rendering icons by default and only render when I make a call ... I really want to contribute on this, but you need to create the repository first, man :) Looking forward to ...
     
unityunity