Inheritance: IDisposable
示例#1
0
        void OnObjectGridGUI()
        {
            InitIfNeeded();

            // Initialize m_Styles
            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }

            if (m_EditorCache == null)
            {
                m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
            }

            // Handle window/preview stuff
            ResizeBottomPartOfWindow();

            Rect p = position;

            EditorPrefs.SetFloat("ObjectSelectorWidth", p.width);
            EditorPrefs.SetFloat("ObjectSelectorHeight", p.height);

            GUI.BeginGroup(new Rect(0, 0, position.width, position.height), GUIContent.none);

            // Let grid/list area take priority over search area on up/down arrow keys
            if (s_GridAreaPriorityKeyboardEvents.Contains(Event.current))
            {
                m_ListArea.HandleKeyboard(false);
            }

            SearchArea();

            // Let grid/list area handle any keyboard events not used by search area
            m_ListArea.HandleKeyboard(false);

            GridListArea();
            PreviewArea();

            GUI.EndGroup();

            // overlay preview resize widget
            GUI.Label(new Rect(position.width * .5f - 16, position.height - m_PreviewSize + 2, 32, m_Styles.bottomResize.fixedHeight), GUIContent.none, m_Styles.bottomResize);
        }
示例#2
0
        void OnObjectGridGUI()
        {
            InitIfNeeded();

            // Initialize m_Styles
            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }

            if (m_EditorCache == null)
            {
                m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
            }

            // Handle window/preview stuff
            ResizeBottomPartOfWindow();

            Rect p = position;

            EditorPrefs.SetFloat("ObjectSelectorWidth", p.width);
            EditorPrefs.SetFloat("ObjectSelectorHeight", p.height);

            GUI.BeginGroup(new Rect(0, 0, position.width, position.height), GUIContent.none);

            // We want to check for arrow key presses first of all to allow arrow navigation
            // of grid/list even when search field has focus (which it has when the window opens).
            // That means arrows won't affect the cursor position in the text field
            // but that's by design (was the same in 3.4).
            m_ListArea.HandleKeyboard(false);

            SearchArea();
            GridListArea();
            PreviewArea();

            GUI.EndGroup();

            // overlay preview resize widget
            GUI.Label(new Rect(position.width * .5f - 16, position.height - m_PreviewSize + 2, 32, m_Styles.bottomResize.fixedHeight), GUIContent.none, m_Styles.bottomResize);
        }
示例#3
0
        private void OnObjectGridGUI()
        {
            this.InitIfNeeded();
            if (this.m_Styles == null)
            {
                this.m_Styles = new ObjectSelector.Styles();
            }
            if (this.m_EditorCache == null)
            {
                this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
            }
            this.ResizeBottomPartOfWindow();
            Rect position = base.position;

            EditorPrefs.SetFloat("ObjectSelectorWidth", position.width);
            EditorPrefs.SetFloat("ObjectSelectorHeight", position.height);
            GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), GUIContent.none);
            this.m_ListArea.HandleKeyboard(false);
            this.SearchArea();
            this.GridListArea();
            this.PreviewArea();
            GUI.EndGroup();
            GUI.Label(new Rect(base.position.width * 0.5f - 16f, base.position.height - this.m_PreviewSize + 2f, 32f, this.m_Styles.bottomResize.fixedHeight), GUIContent.none, this.m_Styles.bottomResize);
        }
 private void PreviewArea()
 {
   GUI.Box(new Rect(0.0f, this.m_TopSize, this.position.width, this.m_PreviewSize), string.Empty, this.m_Styles.previewBackground);
   if (this.m_ListArea.GetSelection().Length == 0)
     return;
   EditorWrapper p = (EditorWrapper) null;
   UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject();
   if ((double) this.m_PreviewSize < 75.0)
   {
     string s;
     if (currentObject != (UnityEngine.Object) null)
     {
       p = this.m_EditorCache[currentObject];
       string str = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
       s = (p == null ? currentObject.name + " (" + str + ")" : p.name + " (" + str + ")") + "      " + AssetDatabase.GetAssetPath(currentObject);
     }
     else
       s = "None";
     this.LinePreview(s, currentObject, p);
   }
   else
   {
     if (this.m_EditorCache == null)
       this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
     string s;
     if (currentObject != (UnityEngine.Object) null)
     {
       p = this.m_EditorCache[currentObject];
       string str1 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
       string str2;
       if (p != null)
       {
         string infoString = p.GetInfoString();
         if (infoString != string.Empty)
           str2 = p.name + "\n" + str1 + "\n" + infoString;
         else
           str2 = p.name + "\n" + str1;
       }
       else
         str2 = currentObject.name + "\n" + str1;
       s = str2 + "\n" + AssetDatabase.GetAssetPath(currentObject);
     }
     else
       s = "None";
     if ((double) this.m_ShowWidePreview.faded != 0.0)
     {
       GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded);
       this.WidePreview(this.m_PreviewSize, s, currentObject, p);
     }
     if ((double) this.m_ShowOverlapPreview.faded != 0.0)
     {
       GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded);
       this.OverlapPreview(this.m_PreviewSize, s, currentObject, p);
     }
     GUI.color = Color.white;
     this.m_EditorCache.CleanupUntouchedEditors();
   }
 }
        private void MaterialListing()
        {
            ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials();
            foreach (ProceduralMaterial material in sortedMaterials)
            {
                if (material.isProcessing)
                {
                    base.Repaint();
                    SceneView.RepaintAll();
                    GameView.RepaintAll();
                    break;
                }
            }
            int   length = sortedMaterials.Length;
            float num3   = ((GUIView.current.position.width - 16f) - 18f) - 2f;

            if ((num3 * 2f) < (length * 60f))
            {
                num3 -= 16f;
            }
            int  num4     = Mathf.Max(1, Mathf.FloorToInt(num3 / 60f));
            int  num5     = Mathf.CeilToInt(((float)length) / ((float)num4));
            Rect viewRect = new Rect(0f, 0f, num4 * 60f, num5 * 76f);
            Rect rect     = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f);
            Rect position = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f);

            GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground);
            GUI.Box(position, GUIContent.none, this.m_SubstanceStyles.background);
            this.m_ListScroll = GUI.BeginScrollView(position, this.m_ListScroll, viewRect, false, false);
            if (this.m_EditorCache == null)
            {
                this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
            }
            for (int i = 0; i < sortedMaterials.Length; i++)
            {
                ProceduralMaterial target = sortedMaterials[i];
                if (target != null)
                {
                    float x         = (i % num4) * 60f;
                    float y         = (i / num4) * 76f;
                    Rect  rect5     = new Rect(x, y, 60f, 76f);
                    bool  on        = target.name == this.m_SelectedMaterialInstanceName;
                    Event current   = Event.current;
                    int   controlID = GUIUtility.GetControlID(previewNoDragDropHash, FocusType.Passive, rect5);
                    switch (current.GetTypeForControl(controlID))
                    {
                    case EventType.Repaint:
                    {
                        Rect rect6 = rect5;
                        rect6.y      = rect5.yMax - 16f;
                        rect6.height = 16f;
                        this.m_SubstanceStyles.resultsGridLabel.Draw(rect6, EditorGUIUtility.TempContent(target.name), false, false, on, on);
                        break;
                    }

                    case EventType.MouseDown:
                        if ((current.button == 0) && rect5.Contains(current.mousePosition))
                        {
                            if (current.clickCount == 1)
                            {
                                this.m_SelectedMaterialInstanceName = target.name;
                                current.Use();
                            }
                            else if (current.clickCount == 2)
                            {
                                AssetDatabase.OpenAsset(target);
                                GUIUtility.ExitGUI();
                                current.Use();
                            }
                        }
                        break;
                    }
                    rect5.height -= 16f;
                    this.m_EditorCache[target].OnPreviewGUI(rect5, this.m_SubstanceStyles.background);
                }
            }
            GUI.EndScrollView();
        }
 private void MaterialListing()
 {
     ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials();
     foreach (ProceduralMaterial material in sortedMaterials)
     {
         if (material.isProcessing)
         {
             base.Repaint();
             SceneView.RepaintAll();
             GameView.RepaintAll();
             break;
         }
     }
     int length = sortedMaterials.Length;
     float num3 = ((GUIView.current.position.width - 16f) - 18f) - 2f;
     if ((num3 * 2f) < (length * 60f))
     {
         num3 -= 16f;
     }
     int num4 = Mathf.Max(1, Mathf.FloorToInt(num3 / 60f));
     int num5 = Mathf.CeilToInt(((float) length) / ((float) num4));
     Rect viewRect = new Rect(0f, 0f, num4 * 60f, num5 * 76f);
     Rect rect = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f);
     Rect position = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f);
     GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground);
     GUI.Box(position, GUIContent.none, this.m_SubstanceStyles.background);
     this.m_ListScroll = GUI.BeginScrollView(position, this.m_ListScroll, viewRect, false, false);
     if (this.m_EditorCache == null)
     {
         this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
     }
     for (int i = 0; i < sortedMaterials.Length; i++)
     {
         ProceduralMaterial target = sortedMaterials[i];
         if (target != null)
         {
             float x = (i % num4) * 60f;
             float y = (i / num4) * 76f;
             Rect rect5 = new Rect(x, y, 60f, 76f);
             bool on = target.name == this.m_SelectedMaterialInstanceName;
             Event current = Event.current;
             int controlID = GUIUtility.GetControlID(previewNoDragDropHash, FocusType.Passive, rect5);
             switch (current.GetTypeForControl(controlID))
             {
                 case EventType.Repaint:
                 {
                     Rect rect6 = rect5;
                     rect6.y = rect5.yMax - 16f;
                     rect6.height = 16f;
                     this.m_SubstanceStyles.resultsGridLabel.Draw(rect6, EditorGUIUtility.TempContent(target.name), false, false, on, on);
                     break;
                 }
                 case EventType.MouseDown:
                     if ((current.button == 0) && rect5.Contains(current.mousePosition))
                     {
                         if (current.clickCount == 1)
                         {
                             this.m_SelectedMaterialInstanceName = target.name;
                             current.Use();
                         }
                         else if (current.clickCount == 2)
                         {
                             AssetDatabase.OpenAsset(target);
                             GUIUtility.ExitGUI();
                             current.Use();
                         }
                     }
                     break;
             }
             rect5.height -= 16f;
             this.m_EditorCache[target].OnPreviewGUI(rect5, this.m_SubstanceStyles.background);
         }
     }
     GUI.EndScrollView();
 }
示例#7
0
 private void CallEditorDragFunctions()
 {
   Event current = Event.current;
   SpriteUtility.OnSceneDrag(this);
   if (current.type == EventType.Used || DragAndDrop.objectReferences.Length == 0)
     return;
   if (this.m_DragEditorCache == null)
     this.m_DragEditorCache = new EditorCache(EditorFeatures.OnSceneDrag);
   foreach (UnityEngine.Object objectReference in DragAndDrop.objectReferences)
   {
     if (!(objectReference == (UnityEngine.Object) null))
     {
       EditorWrapper editorWrapper = this.m_DragEditorCache[objectReference];
       if (editorWrapper != null)
         editorWrapper.OnSceneDrag(this);
       if (current.type == EventType.Used)
         break;
     }
   }
 }
		private void PreviewArea()
		{
			GUI.Box(new Rect(0f, this.m_TopSize, base.position.width, this.m_PreviewSize), string.Empty, this.m_Styles.previewBackground);
			if (this.m_ListArea.GetSelection().Length == 0)
			{
				return;
			}
			EditorWrapper editorWrapper = null;
			UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject();
			if (this.m_PreviewSize < 75f)
			{
				string text;
				if (currentObject != null)
				{
					editorWrapper = this.m_EditorCache[currentObject];
					string str = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
					if (editorWrapper != null)
					{
						text = editorWrapper.name + " (" + str + ")";
					}
					else
					{
						text = currentObject.name + " (" + str + ")";
					}
					text = text + "      " + AssetDatabase.GetAssetPath(currentObject);
				}
				else
				{
					text = "None";
				}
				this.LinePreview(text, currentObject, editorWrapper);
			}
			else
			{
				if (this.m_EditorCache == null)
				{
					this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
				}
				string text3;
				if (currentObject != null)
				{
					editorWrapper = this.m_EditorCache[currentObject];
					string text2 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
					if (editorWrapper != null)
					{
						text3 = editorWrapper.GetInfoString();
						if (text3 != string.Empty)
						{
							text3 = string.Concat(new string[]
							{
								editorWrapper.name,
								"\n",
								text2,
								"\n",
								text3
							});
						}
						else
						{
							text3 = editorWrapper.name + "\n" + text2;
						}
					}
					else
					{
						text3 = currentObject.name + "\n" + text2;
					}
					text3 = text3 + "\n" + AssetDatabase.GetAssetPath(currentObject);
				}
				else
				{
					text3 = "None";
				}
				if (this.m_ShowWidePreview.faded != 0f)
				{
					GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded);
					this.WidePreview(this.m_PreviewSize, text3, currentObject, editorWrapper);
				}
				if (this.m_ShowOverlapPreview.faded != 0f)
				{
					GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded);
					this.OverlapPreview(this.m_PreviewSize, text3, currentObject, editorWrapper);
				}
				GUI.color = Color.white;
				this.m_EditorCache.CleanupUntouchedEditors();
			}
		}
        private void PreviewArea()
        {
            GUI.Box(new Rect(0.0f, this.m_TopSize, this.position.width, this.m_PreviewSize), string.Empty, this.m_Styles.previewBackground);
            if (this.m_ListArea.GetSelection().Length == 0)
            {
                return;
            }
            EditorWrapper p = (EditorWrapper)null;

            UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject();
            if ((double)this.m_PreviewSize < 75.0)
            {
                string s;
                if (currentObject != (UnityEngine.Object)null)
                {
                    p = this.m_EditorCache[currentObject];
                    string str = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                    s = (p == null ? currentObject.name + " (" + str + ")" : p.name + " (" + str + ")") + "      " + AssetDatabase.GetAssetPath(currentObject);
                }
                else
                {
                    s = "None";
                }
                this.LinePreview(s, currentObject, p);
            }
            else
            {
                if (this.m_EditorCache == null)
                {
                    this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
                }
                string s;
                if (currentObject != (UnityEngine.Object)null)
                {
                    p = this.m_EditorCache[currentObject];
                    string str1 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                    string str2;
                    if (p != null)
                    {
                        string infoString = p.GetInfoString();
                        if (infoString != string.Empty)
                        {
                            str2 = p.name + "\n" + str1 + "\n" + infoString;
                        }
                        else
                        {
                            str2 = p.name + "\n" + str1;
                        }
                    }
                    else
                    {
                        str2 = currentObject.name + "\n" + str1;
                    }
                    s = str2 + "\n" + AssetDatabase.GetAssetPath(currentObject);
                }
                else
                {
                    s = "None";
                }
                if ((double)this.m_ShowWidePreview.faded != 0.0)
                {
                    GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded);
                    this.WidePreview(this.m_PreviewSize, s, currentObject, p);
                }
                if ((double)this.m_ShowOverlapPreview.faded != 0.0)
                {
                    GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded);
                    this.OverlapPreview(this.m_PreviewSize, s, currentObject, p);
                }
                GUI.color = Color.white;
                this.m_EditorCache.CleanupUntouchedEditors();
            }
        }
示例#10
0
 private void CleanupEditorDragFunctions()
 {
     if (this.m_DragEditorCache != null)
     {
         this.m_DragEditorCache.Dispose();
     }
     this.m_DragEditorCache = null;
 }
示例#11
0
 private void CallEditorDragFunctions()
 {
     Event current = Event.current;
     SpriteUtility.OnSceneDrag(this);
     if ((current.type != EventType.Used) && (DragAndDrop.objectReferences.Length != 0))
     {
         if (this.m_DragEditorCache == null)
         {
             this.m_DragEditorCache = new EditorCache(EditorFeatures.OnSceneDrag);
         }
         foreach (UnityEngine.Object obj2 in DragAndDrop.objectReferences)
         {
             if (obj2 != null)
             {
                 EditorWrapper wrapper = this.m_DragEditorCache[obj2];
                 if (wrapper != null)
                 {
                     wrapper.OnSceneDrag(this);
                 }
                 if (current.type == EventType.Used)
                 {
                     return;
                 }
             }
         }
     }
 }
示例#12
0
 private void PreviewArea()
 {
     GUI.Box(new Rect(0f, this.m_TopSize, base.position.width, this.m_PreviewSize), "", this.m_Styles.previewBackground);
     if (this.m_ListArea.GetSelection().Length != 0)
     {
         EditorWrapper p = null;
         Object currentObject = GetCurrentObject();
         if (this.m_PreviewSize < 75f)
         {
             string str;
             if (currentObject != null)
             {
                 p = this.m_EditorCache[currentObject];
                 string str2 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                 if (p != null)
                 {
                     str = p.name + " (" + str2 + ")";
                 }
                 else
                 {
                     str = currentObject.name + " (" + str2 + ")";
                 }
                 str = str + "      " + AssetDatabase.GetAssetPath(currentObject);
             }
             else
             {
                 str = "None";
             }
             this.LinePreview(str, currentObject, p);
         }
         else
         {
             string infoString;
             if (this.m_EditorCache == null)
             {
                 this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
             }
             if (currentObject != null)
             {
                 p = this.m_EditorCache[currentObject];
                 string str4 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                 if (p != null)
                 {
                     infoString = p.GetInfoString();
                     if (infoString != "")
                     {
                         string[] textArray1 = new string[] { p.name, "\n", str4, "\n", infoString };
                         infoString = string.Concat(textArray1);
                     }
                     else
                     {
                         infoString = p.name + "\n" + str4;
                     }
                 }
                 else
                 {
                     infoString = currentObject.name + "\n" + str4;
                 }
                 infoString = infoString + "\n" + AssetDatabase.GetAssetPath(currentObject);
             }
             else
             {
                 infoString = "None";
             }
             if (this.m_ShowWidePreview.faded != 0f)
             {
                 GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded);
                 this.WidePreview(this.m_PreviewSize, infoString, currentObject, p);
             }
             if (this.m_ShowOverlapPreview.faded != 0f)
             {
                 GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded);
                 this.OverlapPreview(this.m_PreviewSize, infoString, currentObject, p);
             }
             GUI.color = Color.white;
             this.m_EditorCache.CleanupUntouchedEditors();
         }
     }
 }
示例#13
0
		private void CallEditorDragFunctions()
		{
			if (DragAndDrop.objectReferences.Length == 0)
			{
				return;
			}
			if (this.m_DragEditorCache == null)
			{
				this.m_DragEditorCache = new EditorCache(EditorFeatures.OnSceneDrag);
			}
			UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
			for (int i = 0; i < objectReferences.Length; i++)
			{
				UnityEngine.Object @object = objectReferences[i];
				if (!(@object == null))
				{
					EditorWrapper editorWrapper = this.m_DragEditorCache[@object];
					if (editorWrapper != null)
					{
						editorWrapper.OnSceneDrag(this);
					}
					if (Event.current.type == EventType.Used)
					{
						return;
					}
				}
			}
		}
		private void MaterialListing()
		{
			ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials();
			ProceduralMaterial[] array = sortedMaterials;
			for (int i = 0; i < array.Length; i++)
			{
				ProceduralMaterial proceduralMaterial = array[i];
				if (proceduralMaterial.isProcessing)
				{
					base.Repaint();
					SceneView.RepaintAll();
					GameView.RepaintAll();
					break;
				}
			}
			int num = sortedMaterials.Length;
			float num2 = GUIView.current.position.width - 16f - 18f - 2f;
			if (num2 * 2f < (float)num * 60f)
			{
				num2 -= 16f;
			}
			int num3 = Mathf.Max(1, Mathf.FloorToInt(num2 / 60f));
			int num4 = Mathf.CeilToInt((float)num / (float)num3);
			Rect viewRect = new Rect(0f, 0f, (float)num3 * 60f, (float)num4 * 76f);
			Rect rect = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f);
			Rect position = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f);
			GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground);
			GUI.Box(position, GUIContent.none, this.m_SubstanceStyles.background);
			this.m_ListScroll = GUI.BeginScrollView(position, this.m_ListScroll, viewRect, false, false);
			if (this.m_EditorCache == null)
			{
				this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
			}
			for (int j = 0; j < sortedMaterials.Length; j++)
			{
				ProceduralMaterial proceduralMaterial2 = sortedMaterials[j];
				if (!(proceduralMaterial2 == null))
				{
					float left = (float)(j % num3) * 60f;
					float top = (float)(j / num3) * 76f;
					Rect rect2 = new Rect(left, top, 60f, 76f);
					bool flag = proceduralMaterial2.name == this.m_SelectedMaterialInstanceName;
					Event current = Event.current;
					int controlID = GUIUtility.GetControlID(SubstanceImporterInspector.previewNoDragDropHash, FocusType.Native, rect2);
					EventType typeForControl = current.GetTypeForControl(controlID);
					if (typeForControl != EventType.MouseDown)
					{
						if (typeForControl == EventType.Repaint)
						{
							Rect position2 = rect2;
							position2.y = rect2.yMax - 16f;
							position2.height = 16f;
							this.m_SubstanceStyles.resultsGridLabel.Draw(position2, EditorGUIUtility.TempContent(proceduralMaterial2.name), false, false, flag, flag);
						}
					}
					else
					{
						if (current.button == 0)
						{
							if (rect2.Contains(current.mousePosition))
							{
								if (current.clickCount == 1)
								{
									this.m_SelectedMaterialInstanceName = proceduralMaterial2.name;
									current.Use();
								}
								else
								{
									if (current.clickCount == 2)
									{
										AssetDatabase.OpenAsset(proceduralMaterial2);
										GUIUtility.ExitGUI();
										current.Use();
									}
								}
							}
						}
					}
					rect2.height -= 16f;
					EditorWrapper editorWrapper = this.m_EditorCache[proceduralMaterial2];
					editorWrapper.OnPreviewGUI(rect2, this.m_SubstanceStyles.background);
				}
			}
			GUI.EndScrollView();
		}
示例#15
0
        private void MaterialListing()
        {
            ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials();
            ProceduralMaterial[] array           = sortedMaterials;
            for (int i = 0; i < array.Length; i++)
            {
                ProceduralMaterial proceduralMaterial = array[i];
                if (proceduralMaterial.isProcessing)
                {
                    base.Repaint();
                    SceneView.RepaintAll();
                    GameView.RepaintAll();
                    break;
                }
            }
            int   num  = sortedMaterials.Length;
            float num2 = GUIView.current.position.width - 16f - 18f - 2f;

            if (num2 * 2f < (float)num * 60f)
            {
                num2 -= 16f;
            }
            int  num3     = Mathf.Max(1, Mathf.FloorToInt(num2 / 60f));
            int  num4     = Mathf.CeilToInt((float)num / (float)num3);
            Rect viewRect = new Rect(0f, 0f, (float)num3 * 60f, (float)num4 * 76f);
            Rect rect     = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f);
            Rect position = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f);

            GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground);
            GUI.Box(position, GUIContent.none, this.m_SubstanceStyles.background);
            this.m_ListScroll = GUI.BeginScrollView(position, this.m_ListScroll, viewRect, false, false);
            if (this.m_EditorCache == null)
            {
                this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
            }
            for (int j = 0; j < sortedMaterials.Length; j++)
            {
                ProceduralMaterial proceduralMaterial2 = sortedMaterials[j];
                if (!(proceduralMaterial2 == null))
                {
                    float     x              = (float)(j % num3) * 60f;
                    float     y              = (float)(j / num3) * 76f;
                    Rect      rect2          = new Rect(x, y, 60f, 76f);
                    bool      flag           = proceduralMaterial2.name == this.m_SelectedMaterialInstanceName;
                    Event     current        = Event.current;
                    int       controlID      = GUIUtility.GetControlID(SubstanceImporterInspector.previewNoDragDropHash, FocusType.Passive, rect2);
                    EventType typeForControl = current.GetTypeForControl(controlID);
                    if (typeForControl != EventType.Repaint)
                    {
                        if (typeForControl == EventType.MouseDown)
                        {
                            if (current.button == 0)
                            {
                                if (rect2.Contains(current.mousePosition))
                                {
                                    if (current.clickCount == 1)
                                    {
                                        this.m_SelectedMaterialInstanceName = proceduralMaterial2.name;
                                        current.Use();
                                    }
                                    else if (current.clickCount == 2)
                                    {
                                        AssetDatabase.OpenAsset(proceduralMaterial2);
                                        GUIUtility.ExitGUI();
                                        current.Use();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Rect position2 = rect2;
                        position2.y      = rect2.yMax - 16f;
                        position2.height = 16f;
                        this.m_SubstanceStyles.resultsGridLabel.Draw(position2, EditorGUIUtility.TempContent(proceduralMaterial2.name), false, false, flag, flag);
                    }
                    rect2.height -= 16f;
                    EditorWrapper editorWrapper = this.m_EditorCache[proceduralMaterial2];
                    editorWrapper.OnPreviewGUI(rect2, this.m_SubstanceStyles.background);
                }
            }
            GUI.EndScrollView();
        }
示例#16
0
        private void PreviewArea()
        {
            GUI.Box(new Rect(0f, this.m_TopSize, base.position.width, this.m_PreviewSize), string.Empty, this.m_Styles.previewBackground);
            if (this.m_ListArea.GetSelection().Length == 0)
            {
                return;
            }
            EditorWrapper editorWrapper = null;

            UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject();
            if (this.m_PreviewSize < 75f)
            {
                string text;
                if (currentObject != null)
                {
                    editorWrapper = this.m_EditorCache[currentObject];
                    string str = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                    if (editorWrapper != null)
                    {
                        text = editorWrapper.name + " (" + str + ")";
                    }
                    else
                    {
                        text = currentObject.name + " (" + str + ")";
                    }
                    text = text + "      " + AssetDatabase.GetAssetPath(currentObject);
                }
                else
                {
                    text = "None";
                }
                this.LinePreview(text, currentObject, editorWrapper);
            }
            else
            {
                if (this.m_EditorCache == null)
                {
                    this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
                }
                string text3;
                if (currentObject != null)
                {
                    editorWrapper = this.m_EditorCache[currentObject];
                    string text2 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                    if (editorWrapper != null)
                    {
                        text3 = editorWrapper.GetInfoString();
                        if (text3 != string.Empty)
                        {
                            text3 = string.Concat(new string[]
                            {
                                editorWrapper.name,
                                "\n",
                                text2,
                                "\n",
                                text3
                            });
                        }
                        else
                        {
                            text3 = editorWrapper.name + "\n" + text2;
                        }
                    }
                    else
                    {
                        text3 = currentObject.name + "\n" + text2;
                    }
                    text3 = text3 + "\n" + AssetDatabase.GetAssetPath(currentObject);
                }
                else
                {
                    text3 = "None";
                }
                if (this.m_ShowWidePreview.faded != 0f)
                {
                    GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded);
                    this.WidePreview(this.m_PreviewSize, text3, currentObject, editorWrapper);
                }
                if (this.m_ShowOverlapPreview.faded != 0f)
                {
                    GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded);
                    this.OverlapPreview(this.m_PreviewSize, text3, currentObject, editorWrapper);
                }
                GUI.color = Color.white;
                this.m_EditorCache.CleanupUntouchedEditors();
            }
        }
示例#17
0
 private void PreviewArea()
 {
     GUI.Box(new Rect(0f, this.m_TopSize, base.position.width, this.m_PreviewSize), string.Empty, this.m_Styles.previewBackground);
     if (this.m_ListArea.GetSelection().Length != 0)
     {
         EditorWrapper      p             = null;
         UnityEngine.Object currentObject = GetCurrentObject();
         if (this.m_PreviewSize < 75f)
         {
             string str;
             if (currentObject != null)
             {
                 p = this.m_EditorCache[currentObject];
                 string str2 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                 if (p != null)
                 {
                     str = p.name + " (" + str2 + ")";
                 }
                 else
                 {
                     str = currentObject.name + " (" + str2 + ")";
                 }
                 str = str + "      " + AssetDatabase.GetAssetPath(currentObject);
             }
             else
             {
                 str = "None";
             }
             this.LinePreview(str, currentObject, p);
         }
         else
         {
             string infoString;
             if (this.m_EditorCache == null)
             {
                 this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
             }
             if (currentObject != null)
             {
                 p = this.m_EditorCache[currentObject];
                 string str4 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                 if (p != null)
                 {
                     infoString = p.GetInfoString();
                     if (infoString != string.Empty)
                     {
                         string[] textArray1 = new string[] { p.name, "\n", str4, "\n", infoString };
                         infoString = string.Concat(textArray1);
                     }
                     else
                     {
                         infoString = p.name + "\n" + str4;
                     }
                 }
                 else
                 {
                     infoString = currentObject.name + "\n" + str4;
                 }
                 infoString = infoString + "\n" + AssetDatabase.GetAssetPath(currentObject);
             }
             else
             {
                 infoString = "None";
             }
             if (this.m_ShowWidePreview.faded != 0f)
             {
                 GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded);
                 this.WidePreview(this.m_PreviewSize, infoString, currentObject, p);
             }
             if (this.m_ShowOverlapPreview.faded != 0f)
             {
                 GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded);
                 this.OverlapPreview(this.m_PreviewSize, infoString, currentObject, p);
             }
             GUI.color = Color.white;
             this.m_EditorCache.CleanupUntouchedEditors();
         }
     }
 }
        // This is the preview area at the bottom of the screen
        void PreviewArea()
        {
            GUI.Box(new Rect(0, m_TopSize, position.width, m_PreviewSize), "", Styles.previewBackground);

            if (m_ListArea.GetSelection().Length == 0)
            {
                return;
            }

            EditorWrapper p = null;
            UnityObject   selectedObject = GetCurrentObject();

            if (m_PreviewSize < kPreviewExpandedAreaHeight)
            {
                // Get info string
                string s;
                if (selectedObject != null)
                {
                    p = m_EditorCache[selectedObject];
                    string typeName = ObjectNames.NicifyVariableName(selectedObject.GetType().Name);
                    if (p != null)
                    {
                        s = p.name + " (" + typeName + ")";
                    }
                    else
                    {
                        s = selectedObject.name + " (" + typeName + ")";
                    }

                    s += "      " + AssetDatabase.GetAssetPath(selectedObject);
                }
                else
                {
                    s = "None";
                }

                LinePreview(s, selectedObject, p);
            }
            else
            {
                if (m_EditorCache == null)
                {
                    m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
                }

                // Get info string
                string s;
                if (selectedObject != null)
                {
                    p = m_EditorCache[selectedObject];
                    string typeName = ObjectNames.NicifyVariableName(selectedObject.GetType().Name);
                    if (p != null)
                    {
                        s = p.GetInfoString();
                        if (s != "")
                        {
                            s = p.name + "\n" + typeName + "\n" + s;
                        }
                        else
                        {
                            s = p.name + "\n" + typeName;
                        }
                    }
                    else
                    {
                        s = selectedObject.name + "\n" + typeName;
                    }

                    s += "\n" + AssetDatabase.GetAssetPath(selectedObject);
                }
                else
                {
                    s = "None";
                }

                // Make previews
                if (m_ShowWidePreview.faded != 0.0f)
                {
                    GUI.color = new Color(1, 1, 1, m_ShowWidePreview.faded);
                    WidePreview(m_PreviewSize, s, selectedObject, p);
                }
                if (m_ShowOverlapPreview.faded != 0.0f)
                {
                    GUI.color = new Color(1, 1, 1, m_ShowOverlapPreview.faded);
                    OverlapPreview(m_PreviewSize, s, selectedObject, p);
                }
                GUI.color = Color.white;
                m_EditorCache.CleanupUntouchedEditors();
            }
        }
 private void MaterialListing()
 {
   ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials();
   foreach (ProceduralMaterial proceduralMaterial in sortedMaterials)
   {
     if (proceduralMaterial.isProcessing)
     {
       this.Repaint();
       SceneView.RepaintAll();
       GameView.RepaintAll();
       break;
     }
   }
   int length = sortedMaterials.Length;
   float num1 = (float) ((double) GUIView.current.position.width - 16.0 - 18.0 - 2.0);
   if ((double) num1 * 2.0 < (double) length * 60.0)
     num1 -= 16f;
   int num2 = Mathf.Max(1, Mathf.FloorToInt(num1 / 60f));
   int num3 = Mathf.CeilToInt((float) length / (float) num2);
   Rect viewRect = new Rect(0.0f, 0.0f, (float) num2 * 60f, (float) num3 * 76f);
   Rect rect = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f);
   Rect position1 = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f);
   GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground);
   GUI.Box(position1, GUIContent.none, this.m_SubstanceStyles.background);
   this.m_ListScroll = GUI.BeginScrollView(position1, this.m_ListScroll, viewRect, false, false);
   if (this.m_EditorCache == null)
     this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
   for (int index = 0; index < sortedMaterials.Length; ++index)
   {
     ProceduralMaterial proceduralMaterial = sortedMaterials[index];
     if (!((UnityEngine.Object) proceduralMaterial == (UnityEngine.Object) null))
     {
       Rect position2 = new Rect((float) (index % num2) * 60f, (float) (index / num2) * 76f, 60f, 76f);
       bool flag = proceduralMaterial.name == this.m_SelectedMaterialInstanceName;
       Event current = Event.current;
       int controlId = GUIUtility.GetControlID(SubstanceImporterInspector.previewNoDragDropHash, FocusType.Native, position2);
       switch (current.GetTypeForControl(controlId))
       {
         case EventType.MouseDown:
           if (current.button == 0 && position2.Contains(current.mousePosition))
           {
             if (current.clickCount == 1)
             {
               this.m_SelectedMaterialInstanceName = proceduralMaterial.name;
               current.Use();
               break;
             }
             if (current.clickCount == 2)
             {
               AssetDatabase.OpenAsset((UnityEngine.Object) proceduralMaterial);
               GUIUtility.ExitGUI();
               current.Use();
               break;
             }
             break;
           }
           break;
         case EventType.Repaint:
           Rect position3 = position2;
           position3.y = position2.yMax - 16f;
           position3.height = 16f;
           this.m_SubstanceStyles.resultsGridLabel.Draw(position3, EditorGUIUtility.TempContent(proceduralMaterial.name), false, false, flag, flag);
           break;
       }
       position2.height -= 16f;
       this.m_EditorCache[(UnityEngine.Object) proceduralMaterial].OnPreviewGUI(position2, this.m_SubstanceStyles.background);
     }
   }
   GUI.EndScrollView();
 }
示例#20
0
		private void OnObjectGridGUI()
		{
			this.InitIfNeeded();
			if (this.m_Styles == null)
			{
				this.m_Styles = new ObjectSelector.Styles();
			}
			if (this.m_EditorCache == null)
			{
				this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
			}
			this.ResizeBottomPartOfWindow();
			Rect position = base.position;
			EditorPrefs.SetFloat("ObjectSelectorWidth", position.width);
			EditorPrefs.SetFloat("ObjectSelectorHeight", position.height);
			GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), GUIContent.none);
			this.m_ListArea.HandleKeyboard(false);
			this.SearchArea();
			this.GridListArea();
			this.PreviewArea();
			GUI.EndGroup();
			GUI.Label(new Rect(base.position.width * 0.5f - 16f, base.position.height - this.m_PreviewSize + 2f, 32f, this.m_Styles.bottomResize.fixedHeight), GUIContent.none, this.m_Styles.bottomResize);
		}
        private void MaterialListing()
        {
            ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials();
            foreach (ProceduralMaterial proceduralMaterial in sortedMaterials)
            {
                if (proceduralMaterial.isProcessing)
                {
                    this.Repaint();
                    SceneView.RepaintAll();
                    GameView.RepaintAll();
                    break;
                }
            }
            int   length = sortedMaterials.Length;
            float num1   = (float)((double)GUIView.current.position.width - 16.0 - 18.0 - 2.0);

            if ((double)num1 * 2.0 < (double)length * 60.0)
            {
                num1 -= 16f;
            }
            int  num2      = Mathf.Max(1, Mathf.FloorToInt(num1 / 60f));
            int  num3      = Mathf.CeilToInt((float)length / (float)num2);
            Rect viewRect  = new Rect(0.0f, 0.0f, (float)num2 * 60f, (float)num3 * 76f);
            Rect rect      = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f);
            Rect position1 = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f);

            GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground);
            GUI.Box(position1, GUIContent.none, this.m_SubstanceStyles.background);
            this.m_ListScroll = GUI.BeginScrollView(position1, this.m_ListScroll, viewRect, false, false);
            if (this.m_EditorCache == null)
            {
                this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
            }
            for (int index = 0; index < sortedMaterials.Length; ++index)
            {
                ProceduralMaterial proceduralMaterial = sortedMaterials[index];
                if (!((UnityEngine.Object)proceduralMaterial == (UnityEngine.Object)null))
                {
                    Rect  position2 = new Rect((float)(index % num2) * 60f, (float)(index / num2) * 76f, 60f, 76f);
                    bool  flag      = proceduralMaterial.name == this.m_SelectedMaterialInstanceName;
                    Event current   = Event.current;
                    int   controlId = GUIUtility.GetControlID(SubstanceImporterInspector.previewNoDragDropHash, FocusType.Native, position2);
                    switch (current.GetTypeForControl(controlId))
                    {
                    case EventType.MouseDown:
                        if (current.button == 0 && position2.Contains(current.mousePosition))
                        {
                            if (current.clickCount == 1)
                            {
                                this.m_SelectedMaterialInstanceName = proceduralMaterial.name;
                                current.Use();
                                break;
                            }
                            if (current.clickCount == 2)
                            {
                                AssetDatabase.OpenAsset((UnityEngine.Object)proceduralMaterial);
                                GUIUtility.ExitGUI();
                                current.Use();
                                break;
                            }
                            break;
                        }
                        break;

                    case EventType.Repaint:
                        Rect position3 = position2;
                        position3.y      = position2.yMax - 16f;
                        position3.height = 16f;
                        this.m_SubstanceStyles.resultsGridLabel.Draw(position3, EditorGUIUtility.TempContent(proceduralMaterial.name), false, false, flag, flag);
                        break;
                    }
                    position2.height -= 16f;
                    this.m_EditorCache[(UnityEngine.Object)proceduralMaterial].OnPreviewGUI(position2, this.m_SubstanceStyles.background);
                }
            }
            GUI.EndScrollView();
        }