private static void DrawVector4(Rect r, NGRemoteHierarchyWindow hierarchy, int materialInstanceID, NetMaterialProperty property) { Vector4 vector = property.vectorValue; float labelWidth; float controlWidth; Utility.CalculSubFieldsWidth(r.width, 44F, 4, out labelWidth, out controlWidth); r.width = labelWidth; EditorGUI.LabelField(r, Utility.NicifyVariableName(property.name)); r.x += r.width; using (IndentLevelRestorer.Get(0)) using (LabelWidthRestorer.Get(14F)) { r.width = controlWidth; EditorGUI.BeginChangeCheck(); Single v = EditorGUI.FloatField(r, "X", vector.x); r.x += r.width; if (EditorGUI.EndChangeCheck() == true) { vector.x = v; hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p => { if (p.CheckPacketStatus() == true) { ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue); property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4)); Utility.RestoreBBuffer(buffer); } }); } EditorGUI.BeginChangeCheck(); v = EditorGUI.FloatField(r, "Y", vector.y); r.x += r.width; if (EditorGUI.EndChangeCheck() == true) { vector.y = v; hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p => { if (p.CheckPacketStatus() == true) { ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue); property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4)); Utility.RestoreBBuffer(buffer); } }); } EditorGUI.BeginChangeCheck(); v = EditorGUI.FloatField(r, "Z", vector.z); r.x += r.width; if (EditorGUI.EndChangeCheck() == true) { vector.z = v; hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p => { if (p.CheckPacketStatus() == true) { ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue); property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4)); Utility.RestoreBBuffer(buffer); } }); } EditorGUI.BeginChangeCheck(); v = EditorGUI.FloatField(r, "W", vector.w); if (EditorGUI.EndChangeCheck() == true) { vector.w = v; hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p => { if (p.CheckPacketStatus() == true) { ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue); property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4)); Utility.RestoreBBuffer(buffer); } }); } } }
public override void Draw(Rect r, DataDrawer data) { if (this.animX == null) { this.animX = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animY = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animZ = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); } Vector3 vector = (Vector3)data.Value; float labelWidth; float controlWidth; Utility.CalculSubFieldsWidth(r.width, 60F, 3, out labelWidth, out controlWidth); r.width = labelWidth; EditorGUI.LabelField(r, data.Name); r.x += r.width; using (IndentLevelRestorer.Get(0)) using (LabelWidthRestorer.Get(12F)) { r.width = controlWidth; string path = data.GetPath(); if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + 'x') != NotificationPath.None) { this.dragX.NewValue(vector.x); this.animX.Start(); } using (this.animX.Restorer(0F, .8F + this.animX.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single v = EditorGUI.FloatField(r, "X", this.dragX.Get(vector.x)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + 'x', v, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + 'x', typeof(Single), this.dragX.Get(vector.x), v); this.dragX.Set(v); } this.dragX.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + 'y') != NotificationPath.None) { this.dragY.NewValue(vector.y); this.animY.Start(); } using (this.animY.Restorer(0F, .8F + this.animY.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single v = EditorGUI.FloatField(r, "Y", this.dragY.Get(vector.y)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + 'y', v, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + 'y', typeof(Single), this.dragY.Get(vector.y), v); this.dragY.Set(v); } this.dragY.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + 'z') != NotificationPath.None) { this.dragZ.NewValue(vector.z); this.animZ.Start(); } using (this.animZ.Restorer(0F, .8F + this.animZ.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single v = EditorGUI.FloatField(r, "Z", this.dragZ.Get(vector.z)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + 'z', v, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + 'z', typeof(Single), this.dragZ.Get(vector.z), v); this.dragZ.Set(v); } this.dragZ.Draw(r); } } }
public override void Draw(Rect r, DataDrawer data) { if (this.animCenterX == null) { this.animCenterX = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animCenterY = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animCenterZ = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animExtentsX = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animExtentsY = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); this.animExtentsZ = new BgColorContentAnimator(data.Inspector.Repaint, 1F, 0F); } Bounds vector = (Bounds)data.Value; float labelWidth; float controlWidth; Utility.CalculSubFieldsWidth(r.width, 44F, 4, out labelWidth, out controlWidth); r.width = labelWidth; EditorGUI.LabelField(r, data.Name); r.x += r.width; using (IndentLevelRestorer.Get(0)) using (LabelWidthRestorer.Get(14F)) { float x = r.x; r.width = controlWidth; r.height = Constants.SingleLineHeight; GUI.Label(r, "Center:"); r.x += r.width; string path = data.GetPath(); if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'x') != NotificationPath.None) { this.dragCenterX.NewValue(vector.center.x); this.animCenterX.Start(); } using (this.animCenterX.Restorer(0F, .8F + this.animCenterX.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single newValue = EditorGUI.FloatField(r, "x", this.dragCenterX.Get(vector.center.x)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'x', newValue, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'x', typeof(Single), this.dragCenterX.Get(vector.center.x), newValue); this.dragCenterX.Set(newValue); } this.dragCenterX.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'y') != NotificationPath.None) { this.dragCenterY.NewValue(vector.center.y); this.animCenterY.Start(); } using (this.animCenterY.Restorer(0F, .8F + this.animCenterY.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single newValue = EditorGUI.FloatField(r, "Y", this.dragCenterY.Get(vector.center.y)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'y', newValue, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'y', typeof(Single), this.dragCenterY.Get(vector.center.y), newValue); this.dragCenterY.Set(newValue); } this.dragCenterY.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'z') != NotificationPath.None) { this.dragCenterZ.NewValue(vector.center.z); this.animCenterZ.Start(); } using (this.animCenterZ.Restorer(0F, .8F + this.animCenterZ.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single newValue = EditorGUI.FloatField(r, "Z", this.dragCenterZ.Get(vector.center.z)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'z', newValue, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + "center" + NGServerScene.ValuePathSeparator + 'z', typeof(Single), this.dragCenterZ.Get(vector.center.z), newValue); this.dragCenterZ.Set(newValue); } this.dragCenterZ.Draw(r); r.x += r.width; } r.y += r.height + 2F; r.x = x; GUI.Label(r, "Extents:"); r.x += r.width; if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'x') != NotificationPath.None) { this.dragExtentsX.NewValue(vector.extents.x); this.animExtentsX.Start(); } using (this.animExtentsX.Restorer(0F, .8F + this.animExtentsX.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single newValue = EditorGUI.FloatField(r, "X", this.dragExtentsX.Get(vector.extents.x)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'x', newValue, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'x', typeof(Single), this.dragExtentsX.Get(vector.extents.x), newValue); this.dragExtentsX.Set(newValue); } this.dragExtentsX.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'y') != NotificationPath.None) { this.dragExtentsY.NewValue(vector.extents.y); this.animExtentsY.Start(); } using (this.animExtentsY.Restorer(0F, .8F + this.animExtentsY.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single newValue = EditorGUI.FloatField(r, "Y", this.dragExtentsY.Get(vector.extents.y)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'y', newValue, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'y', typeof(Single), this.dragExtentsY.Get(vector.extents.y), newValue); this.dragExtentsY.Set(newValue); } this.dragExtentsY.Draw(r); r.x += r.width; } if (data.Inspector.Hierarchy.GetUpdateNotification(path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'z') != NotificationPath.None) { this.dragExtentsZ.NewValue(vector.extents.z); this.animExtentsZ.Start(); } using (this.animExtentsZ.Restorer(0F, .8F + this.animExtentsZ.Value, 0F, 1F)) { EditorGUI.BeginChangeCheck(); Single newValue = EditorGUI.FloatField(r, "Z", this.dragExtentsZ.Get(vector.extents.z)); if (EditorGUI.EndChangeCheck() == true && this.AsyncUpdateCommand(data.unityData, path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'z', newValue, typeof(Single), TypeHandlersManager.GetTypeHandler(typeof(Single)))) { data.unityData.RecordChange(path + NGServerScene.ValuePathSeparator + "extents" + NGServerScene.ValuePathSeparator + 'z', typeof(Single), this.dragExtentsZ.Get(vector.extents.z), newValue); this.dragExtentsZ.Set(newValue); } this.dragExtentsZ.Draw(r); r.x += r.width; } } }