private void DrawMaterials(List <int> materials) { this.Hierarchy.LoadResources(typeof(Material)); for (int i = 0; i < materials.Count; i++) { this.r.height = ClientMaterial.GetHeight(this.Hierarchy, materials[i]); ClientMaterial.Draw(this.r, this.Hierarchy, materials[i]); this.r.y += this.r.height; } }
protected override void OnGUIConnected() { if (this.Hierarchy.Client.batchMode == Client.BatchMode.On && this.selectedWindow == 1) { this.DrawBatch(); return; } if (this.isLock == false) { ClientGameObject[] selection = this.Hierarchy.GetSelectedGameObjects(); if (selection.Length > 0) { if (this.target != selection[0]) { this.target = selection[0]; this.target.RequestComponents(this.Hierarchy.Client); this.Hierarchy.WatchGameObject(this, this.target); } } else { if (this.target != null) { this.target = null; this.Hierarchy.WatchGameObject(this, null); } } } if (NGLicensesManager.IsPro(NGTools.NGRemoteScene.NGAssemblyInfo.Name + " Pro") == false) { EditorGUILayout.HelpBox("NG Remote Inspector is read-only. You can only toggle the GameObject's active state below.", MessageType.Info); } if (this.target == null) { return; } this.DrawHeader(); if (this.target.components == null) { EditorGUILayout.LabelField(LC.G("NGInspector_ComponentNotLoadedYet")); return; } this.bodyRect.y = GUILayoutUtility.GetLastRect().yMax + NGRemoteInspectorWindow.ComponentSpacing; this.bodyRect.width = this.position.width; this.bodyRect.height = this.position.height - this.bodyRect.y; this.viewRect.height = NGRemoteInspectorWindow.AddComponentButtonHeight; for (int i = 0; i < this.target.components.Count; i++) { try { this.viewRect.height += this.target.components[i].GetHeight(this) + NGRemoteInspectorWindow.ComponentSpacing; } catch { this.viewRect.height += 16F + NGRemoteInspectorWindow.ComponentSpacing; } } this.PopulateMaterials(this.renderingMaterials); for (int i = 0; i < this.renderingMaterials.Count; i++) { this.viewRect.height += ClientMaterial.GetHeight(this.Hierarchy, this.renderingMaterials[i]); } this.scrollPosition = GUI.BeginScrollView(this.bodyRect, this.scrollPosition, this.viewRect); { this.r = this.bodyRect; this.r.y = 0F; if (this.viewRect.height >= this.bodyRect.height) { this.r.width -= 15F; } for (int i = 0; i < this.target.components.Count; i++) { try { float height = this.target.components[i].GetHeight(this); this.r.height = height; if (this.r.y + height <= this.scrollPosition.y) { continue; } this.target.components[i].OnGUI(this.r, this); } catch (Exception ex) { if (Event.current.type == EventType.Repaint) { EditorGUI.DrawRect(this.r, Color.red * .5F); } this.errorPopup.exception = ex; this.errorPopup.customMessage = "Component " + this.target.components[i].name + " (" + i + ") failed to render."; } finally { this.r.y += this.r.height + NGRemoteInspectorWindow.ComponentSpacing; } if (this.r.y - this.scrollPosition.y > this.bodyRect.height) { break; } } if (this.renderingMaterials.Count > 0 && this.r.y - this.scrollPosition.y < this.bodyRect.height) { this.DrawMaterials(this.renderingMaterials); } this.r.height = 1F; this.r.y += 1F; EditorGUI.DrawRect(this.r, Color.black); this.r.y += 14F; this.r.height = 24F; this.r.x += this.r.width * .5F - NGRemoteInspectorWindow.AddComponentButtonWidth * .5F; this.r.width = NGRemoteInspectorWindow.AddComponentButtonWidth; if (GUI.Button(this.r, "Add Component") == true) { PopupWindow.Show(this.r, new ComponentsBrowserWindow(this.Hierarchy, this.target.instanceID)); } } GUI.EndScrollView(); int hash = 0; for (int i = 0; i < this.renderingMaterials.Count; i++) { hash += this.renderingMaterials[i]; } if (hash != this.lastMaterialsHash) { this.lastMaterialsHash = hash; this.Hierarchy.WatchMaterials(this, this.renderingMaterials.ToArray()); } }