/// <summary>
        /// Position windows in scene view and assign window ids.
        /// </summary>
        private static void UpdateLayout()
        {
            float   maxWidth = 0f;
            Vector2 position = new Vector2(10, 25);

            // Find max width across all windows
            foreach (SceneWindow window in m_windows)
            {
                if (window.Size.x > maxWidth)
                {
                    maxWidth = window.Size.x;
                }
            }

            // Iterate over windows, assign window id, position and width
            for (int i = 0; i < m_windows.Count; i++)
            {
                SceneWindow window = m_windows [i];

                window.Id   = i;
                window.Rect = new Rect(position.x, position.y, maxWidth, window.Size.y);

                position.y += window.Size.y + 10;
            }

            SceneView.RepaintAll();
        }
Example #2
0
        /// <summary>
        /// Initialize the scene window toggle.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="label">The button label and tooltip.</param>
        /// <param name="order">The order of the toggle in toolbar, 99 by default.</param>
        /// <param name="group">The toolbar group, ToolbarGroup.Any by default.</param>
        public void Init(string path, Type type, string name, string tooltip, int order, ToolbarGroup group)
        {
            m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/Icon" + name + ".png") as Texture;

            if (m_icon == null)
            {
                m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/IconDefault.png") as Texture;
            }

            m_order = order;
            m_group = group;
            m_label = new GUIContent(m_icon, tooltip);

            hideFlags          = HideFlags.HideAndDontSave;
            m_window           = (SceneWindow)CreateInstance(type);
            m_window.hideFlags = HideFlags.HideAndDontSave;
        }
 /// <summary>
 /// Removes the specified SceneWindow from the layout.
 /// </summary>
 /// <param name="window"></param>
 public static void Remove(SceneWindow window)
 {
     m_windows.Remove(window);
     UpdateLayout();
 }
 /// <summary>
 /// Add the specified SceneWindow to the layout.
 /// </summary>
 /// <param name="window"></param>
 public static void Add(SceneWindow window)
 {
     m_windows.Add(window);
     UpdateLayout();
 }
Example #5
0
 /// <summary>
 /// Handles the object destruction, close the window and cleanup.
 /// </summary>
 private void OnDestroy()
 {
     DestroyImmediate(m_window);
     m_window = null;
 }