Exemplo n.º 1
0
    static void RenderInjection <T, U>(int instanceID, Rect selectionRect, ComponentCache cache, string title, List <T> list) where U : UnityEngine.Object
    {
        if (cache == null || list == null)
        {
            return;
        }
        for (int j = 0; j < list.Count; j++)
        {
            var injection = list[j] as ComponentCache.Injection <U>;
            if (injection == null || injection.value == null)
            {
                continue;
            }

            if (injection.value.GetInstanceID() != instanceID)
            {
                var com = injection.value as Component;
                if (com == null)
                {
                    continue;
                }
                var go = com.gameObject;
                if (go == null)
                {
                    continue;
                }
                if (go.GetInstanceID() != instanceID)
                {
                    continue;
                }
            }


            // Draw button that will ping the state switcher
            if (GUI.Button(selectionRect, new GUIContent("cc", string.Format("cached for {0}", title)), EditorStyles.label))
            {
                //EditorGUIUtility.PingObject(injection.value.GetInstanceID());
                EditorGUIUtility.PingObject(cache.GetInstanceID());
            }
        }
    }