public float GetHeight() { int count = 0; Stack <ClientGameObject> parents = new Stack <ClientGameObject>(); parents.Push(this.gameObject); while (parents.Count > 0) { ClientGameObject parent = parents.Pop(); for (int i = 0; i < parent.children.Count; i++) { if (parent.children[i].children.Count > 0) { parents.Push(parent.children[i]); } else { ++count; } } ++count; } return(count * Constants.SingleLineHeight); }
public PrefabGameObject(ClientGameObject gameObject) { this.gameObject = gameObject; this.children = new PrefabGameObject[gameObject.children.Count]; for (int i = 0; i < this.children.Length; i++) { this.children[i] = new PrefabGameObject(gameObject.children[i]); } }
public void UpdateHierarchy(ClientGameObject parent, NetGameObject remote) { this.active = remote.active; this.name = remote.name; bool isSelected = this.selected; this.Selected = false; this.Parent = parent; this.Selected = isSelected; }
public ClientGameObject(ClientScene scene, ClientGameObject parent, NetGameObject remote, IUnityData unityData) { this.unityData = unityData; this.scene = scene; this.active = remote.active; this.name = remote.name; this.instanceID = remote.instanceID; this.Parent = parent; int length = remote.children.Length; this.children = new List <ClientGameObject>(remote.children.Length); for (int i = 0; i < length; i++) { new ClientGameObject(scene, this, remote.children[i], this.unityData); } }
public ClientComponent(ClientGameObject parent, NetComponent component, IUnityData unityData) { this.parent = parent; this.type = component.type; this.unityData = unityData; this.instanceID = component.instanceID; this.togglable = component.togglable; this.deletable = component.deletable; this.name = component.name; ClientComponent.reuseFields.Clear(); this.enabledFieldIndex = -1; for (int i = 0; i < component.fields.Length; i++) { if (component.fields[i].name.Equals("enabled") == true) { this.enabledFieldIndex = i; } ClientComponent.reuseFields.Add(new ClientField(this, i, component.fields[i], this.unityData)); } this.fields = ClientComponent.reuseFields.ToArray(); this.methods = new ClientMethod[component.methods.Length]; this.methodNames = new string[this.methods.Length]; for (int i = 0; i < this.methods.Length; i++) { try { this.methods[i] = new ClientMethod(this, component.methods[i]); StringBuilder buffer = Utility.GetBuffer(); if (component.methods[i].returnType != null) { buffer.Append(component.methods[i].returnType.Name); } else { buffer.Append(component.methods[i].returnTypeRaw); } buffer.Append(' '); buffer.Append(component.methods[i].name); buffer.Append('('); string comma = string.Empty; for (int j = 0; j < component.methods[i].argumentTypes.Length; j++) { buffer.Append(comma); buffer.Append(component.methods[i].argumentTypes[j].Name); comma = ", "; } buffer.Append(')'); this.methodNames[i] = Utility.ReturnBuffer(buffer); } catch (Exception ex) { InternalNGDebug.LogException("Method " + i + " " + component.methods[i] + " in Component " + this.name + " (" + this.type + ") failed.", ex); } } this.booleanHandler = TypeHandlersManager.GetTypeHandler <bool>(); this.animEnable = new BgColorContentAnimator(null, 1F, 0F); if (this.type != null) { this.icon = AssetPreview.GetMiniTypeThumbnail(this.type); } if (this.icon == null) { this.icon = UtilityResources.CSharpIcon; } }
public PrefabConstruct(string path, ClientGameObject root) { this.path = path; this.rootGameObject = new PrefabGameObject(root); }
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()); } }