public override string ToString() { return(UnityString.Format("Type {0} NameID {1} InstanceID {2} BufferPointer {3} MipLevel {4} CubeFace {5} DepthSlice {6}", new object[] { this.m_Type, this.m_NameID, this.m_InstanceID, this.m_BufferPointer, this.m_MipLevel, this.m_CubeFace, this.m_DepthSlice })); }
public override string ToString() { return(UnityString.Format("[{0}]-address:{1},port:{2},networkId:0x{3},accessTokenString.IsEmpty:{4},nodeId:0x{5},usingRelay:{6}", new object[] { base.ToString(), this.address, this.port, this.networkId.ToString("X"), string.IsNullOrEmpty(this.accessTokenString), this.nodeId.ToString("X"), this.usingRelay })); }
public override string GetInfoString() { if (target == null) { return(""); } Sprite sprite = target as Sprite; return(UnityString.Format("({0}x{1})", (int)sprite.rect.width, (int)sprite.rect.height )); }
public static void PrintTimes() { string str = "Measured execution times:\n----------------------------\n"; foreach (KeyValuePair <string, float> kvp in m_Timers) { str += UnityString.Format("{0,6:0.0} ms: {1} in {2} calls\n", kvp.Value * 1000, kvp.Key, m_Calls[kvp.Key]); } Debug.Log(str); m_Names.Clear(); m_StartTime.Clear(); m_Timers.Clear(); m_Calls.Clear(); }
public override string ToString() { return(UnityString.Format("[{0}]-networkId:0x{1},name:{2},averageEloScore:{3},maxSize:{4},currentSize:{5},isPrivate:{6},matchAttributes.Count:{7},directConnectInfos.Count:{8}", new object[] { base.ToString(), this.networkId.ToString("X"), this.name, this.averageEloScore, this.maxSize, this.currentSize, this.isPrivate, (this.matchAttributes != null) ? this.matchAttributes.Count : 0, this.directConnectInfos.Count })); }
public override string ToString() { return(UnityString.Format("[{0}]-pageSize:{1},pageNum:{2},nameFilter:{3}, filterOutPrivateMatches:{4}, eloScore:{5}, matchAttributeFilterLessThan.Count:{6}, matchAttributeFilterEqualTo.Count:{7}, matchAttributeFilterGreaterThan.Count:{8}", new object[] { base.ToString(), this.pageSize, this.pageNum, this.nameFilter, this.filterOutPrivateMatches, this.eloScore, (this.matchAttributeFilterLessThan != null) ? this.matchAttributeFilterLessThan.Count : 0, (this.matchAttributeFilterEqualTo != null) ? this.matchAttributeFilterEqualTo.Count : 0, (this.matchAttributeFilterGreaterThan != null) ? this.matchAttributeFilterGreaterThan.Count : 0 })); }
public override string ToString() { return(UnityString.Format("[{0}]-name:{1},size:{2},publicAddress:{3},privateAddress:{4},eloScore:{5},advertise:{6},HasPassword:{7},matchAttributes.Count:{8}", new object[] { base.ToString(), this.name, this.size, this.publicAddress, this.privateAddress, this.eloScore, this.advertise, (!string.IsNullOrEmpty(this.password)) ? "YES" : "NO", (this.matchAttributes != null) ? this.matchAttributes.Count : 0 })); }
public void AvatarTimeControlGUI(Rect rect) { Rect timeControlRect = rect; timeControlRect.height = kTimeControlRectHeight; timeControl.DoTimeControl(timeControlRect); // Show current time in seconds:frame and in percentage rect.y = rect.yMax - 20; float time = timeControl.currentTime - timeControl.startTime; EditorGUI.DropShadowLabel(new Rect(rect.x, rect.y, rect.width, 20), UnityString.Format("{0,2}:{1:00} ({2:000.0%}) Frame {3}", (int)time, Repeat(Mathf.FloorToInt(time * fps), fps), timeControl.normalizedTime, Mathf.FloorToInt(timeControl.currentTime * fps)) ); }
protected bool ValidateRegistration(MethodInfo method, object targetObj, PersistentListenerMode mode, Type argumentType) { if (method == null) { throw new ArgumentNullException("method", UnityString.Format("Can not register null method on {0} for callback!", new object[] { targetObj })); } UnityEngine.Object @object = targetObj as UnityEngine.Object; if (@object == null || @object.GetInstanceID() == 0) { throw new ArgumentException(UnityString.Format("Could not register callback {0} on {1}. The class {2} does not derive from UnityEngine.Object", new object[] { method.Name, targetObj, (targetObj != null) ? targetObj.GetType().ToString() : "null" })); } if (method.IsStatic) { throw new ArgumentException(UnityString.Format("Could not register listener {0} on {1} static functions are not supported.", new object[] { method, base.GetType() })); } bool result; if (this.FindMethod(method.Name, targetObj, mode, argumentType) == null) { Debug.LogWarning(UnityString.Format("Could not register listener {0}.{1} on {2} the method could not be found.", new object[] { targetObj, method, base.GetType() })); result = false; } else { result = true; } return(result); }
public void UpdateOverlayData(int firstEmptyFrame) { m_Data.hasOverlay = true; int numCharts = m_Data.numSeries; for (int i = 0; i < numCharts; ++i) { var chart = m_Data.series[i]; var length = chart.yValues.Length; if (m_Data.overlays[i] == null || m_Data.overlays[i].yValues.Length != length) { m_Data.overlays[i] = new ChartSeriesViewData(chart.name, chart.category, length, chart.color); } float maxValue; ProfilerDriver.GetCounterValuesBatch(ProfilerArea.CPU, UnityString.Format("Selected{0}", chart.name), firstEmptyFrame, 1.0f, m_Data.overlays[i].yValues, out maxValue); m_Data.overlays[i].yScale = m_DataScale; } }
public void AvatarTimeControlGUI(Rect rect) { const float kSliderWidth = 150f; const float kSpacing = 4f; Rect timeControlRect = rect; // background GUI.Box(rect, GUIContent.none, EditorStyles.toolbar); timeControlRect.height = kTimeControlRectHeight; timeControlRect.xMax -= kSliderWidth; Rect sliderControlRect = rect; sliderControlRect.height = kTimeControlRectHeight; sliderControlRect.yMin += 1; sliderControlRect.yMax -= 1; sliderControlRect.xMin = sliderControlRect.xMax - kSliderWidth + kSpacing; timeControl.DoTimeControl(timeControlRect); Rect labelRect = new Rect(new Vector2(rect.x, rect.y), EditorStyles.toolbarLabel.CalcSize(EditorGUIUtility.TrTempContent("xxxxxx")));; labelRect.x = rect.xMax - labelRect.width; labelRect.yMin = rect.yMin; labelRect.yMax = rect.yMax; sliderControlRect.xMax = labelRect.xMin; EditorGUI.BeginChangeCheck(); timeControl.playbackSpeed = PreviewSlider(sliderControlRect, timeControl.playbackSpeed, 0.03f); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetFloat(kSpeedPref, timeControl.playbackSpeed); } GUI.Label(labelRect, timeControl.playbackSpeed.ToString("f2", CultureInfo.InvariantCulture.NumberFormat) + "x", EditorStyles.toolbarLabel); // Show current time in seconds:frame and in percentage rect.y = rect.yMax - 24; float time = timeControl.currentTime - timeControl.startTime; EditorGUI.DropShadowLabel(new Rect(rect.x, rect.y, rect.width, 20), UnityString.Format("{0,2}:{1:00} ({2:000.0%}) Frame {3}", (int)time, Repeat(Mathf.FloorToInt(time * fps), fps), timeControl.normalizedTime, Mathf.FloorToInt(timeControl.currentTime * fps)) ); }
protected override void ImmediateRepaint() { VisualElement t = parent; Vector2 screenStart = start; Vector2 screenEnd = end; // Avoid drawing useless information if (start == end) { return; } // Apply offset screenStart += t.layout.position; screenEnd += t.layout.position; var r = new Rect { min = new Vector2(Math.Min(screenStart.x, screenEnd.x), Math.Min(screenStart.y, screenEnd.y)), max = new Vector2(Math.Max(screenStart.x, screenEnd.x), Math.Max(screenStart.y, screenEnd.y)) }; var lineColor = new Color(1.0f, 0.6f, 0.0f, 1.0f); var segmentSize = 5f; Vector3[] points = { new Vector3(r.xMin, r.yMin, 0.0f), new Vector3(r.xMax, r.yMin, 0.0f), new Vector3(r.xMax, r.yMax, 0.0f), new Vector3(r.xMin, r.yMax, 0.0f) }; DrawDottedLine(points[0], points[1], segmentSize, lineColor); DrawDottedLine(points[1], points[2], segmentSize, lineColor); DrawDottedLine(points[2], points[3], segmentSize, lineColor); DrawDottedLine(points[3], points[0], segmentSize, lineColor); var str = "(" + UnityString.Format("{0:0}", start.x) + ", " + UnityString.Format("{0:0}", start.y) + ")"; GUI.skin.label.Draw(new Rect(screenStart.x, screenStart.y - 18.0f, 200.0f, 20.0f), new GUIContent(str), 0); str = "(" + UnityString.Format("{0:0}", end.x) + ", " + UnityString.Format("{0:0}", end.y) + ")"; GUI.skin.label.Draw(new Rect(screenEnd.x - 80.0f, screenEnd.y + 5.0f, 200.0f, 20.0f), new GUIContent(str), 0); }
private static void DrawCulledRange(Rect totalRect, float previousLODPercentage) { if (Mathf.Approximately(previousLODPercentage, 0.0f)) { return; } var r = GetCulledBox(totalRect, DelinearizeScreenPercentage(previousLODPercentage)); // Draw the range of a lod level on the slider var tempColor = GUI.color; GUI.color = kCulledLODColor; Styles.m_LODSliderRange.Draw(r, GUIContent.none, false, false, false, false); GUI.color = tempColor; // Draw some details for the current marker var startPercentageString = UnityString.Format("Culled\n{0:0}%", previousLODPercentage * 100); Styles.m_LODSliderText.Draw(r, startPercentageString, false, false, false, false); }
void DoZoomSlider() { GUILayout.Label(Styles.zoomSliderContent); EditorGUI.BeginChangeCheck(); // Zooming feels more natural on a log scale var logScale = Mathf.Log10(m_ZoomArea.scale.y); var logMin = Mathf.Log10(minScale); var logMax = Mathf.Log10(maxScale); logScale = GUILayout.HorizontalSlider(logScale, logMin, logMax, GUILayout.MaxWidth(kScaleSliderMaxWidth), GUILayout.MinWidth(kScaleSliderMinWidth)); if (EditorGUI.EndChangeCheck()) { var newZoom = Mathf.Pow(10f, logScale); SnapZoom(newZoom); } var scaleContent = EditorGUIUtility.TempContent(UnityString.Format("{0}x", (m_ZoomArea.scale.y).ToString("G3", CultureInfo.InvariantCulture.NumberFormat))); scaleContent.tooltip = Styles.zoomSliderContent.tooltip; GUILayout.Label(scaleContent, GUILayout.Width(kScaleLabelWidth)); scaleContent.tooltip = string.Empty; }
private IEnumerator ProcessMatchResponse <JSONRESPONSE, USERRESPONSEDELEGATETYPE>(UnityWebRequest client, NetworkMatch.InternalResponseDelegate <JSONRESPONSE, USERRESPONSEDELEGATETYPE> internalCallback, USERRESPONSEDELEGATETYPE userCallback) where JSONRESPONSE : Response, new() { yield return(client.SendWebRequest()); JSONRESPONSE jsonInterface = Activator.CreateInstance <JSONRESPONSE>(); if (!client.isNetworkError && !client.isHttpError) { object obj; if (SimpleJson.TryDeserializeObject(client.downloadHandler.text, out obj)) { IDictionary <string, object> dictionary = obj as IDictionary <string, object>; if (dictionary != null) { try { jsonInterface.Parse(obj); } catch (FormatException ex) { jsonInterface.SetFailure(UnityString.Format("FormatException:[{0}] ", new object[] { ex.ToString() })); } } } } else { jsonInterface.SetFailure(UnityString.Format("Request error:[{0}] Raw response:[{1}]", new object[] { client.error, client.downloadHandler.text })); } client.Dispose(); internalCallback(jsonInterface, userCallback); yield break; }
protected bool ValidateRegistration(MethodInfo method, object targetObj, PersistentListenerMode mode, System.Type argumentType) { if (method == null) { throw new ArgumentNullException("method", UnityString.Format("Can not register null method on {0} for callback!", targetObj)); } UnityEngine.Object @object = targetObj as UnityEngine.Object; if (@object == (UnityEngine.Object)null || @object.GetInstanceID() == 0) { throw new ArgumentException(UnityString.Format("Could not register callback {0} on {1}. The class {2} does not derive from UnityEngine.Object", (object)method.Name, targetObj, (object)(targetObj != null ? targetObj.GetType().ToString() : "null"))); } if (method.IsStatic) { throw new ArgumentException(UnityString.Format("Could not register listener {0} on {1} static functions are not supported.", (object)method, (object)this.GetType())); } if (this.FindMethod(method.Name, targetObj, mode, argumentType) != null) { return(true); } Debug.LogWarning((object)UnityString.Format("Could not register listener {0}.{1} on {2} the method could not be found.", targetObj, (object)method, (object)this.GetType())); return(false); }
// ------------ private functions below ---------------------- // Coroutine for getting a match info response private IEnumerator ProcessMatchResponse <JSONRESPONSE, USERRESPONSEDELEGATETYPE>(UnityWebRequest client, InternalResponseDelegate <JSONRESPONSE, USERRESPONSEDELEGATETYPE> internalCallback, USERRESPONSEDELEGATETYPE userCallback) where JSONRESPONSE : Response, new() { // wait for request to complete yield return(client.SendWebRequest()); JSONRESPONSE jsonInterface = new JSONRESPONSE(); if (!(client.isNetworkError || client.isHttpError)) { object o; if (SimpleJson.SimpleJson.TryDeserializeObject(client.downloadHandler.text, out o)) { IDictionary <string, object> dictJsonObj = o as IDictionary <string, object>; if (null != dictJsonObj) { // Catch exception and error handling below will print out some debug info // Callback will be called properly with failure info try { jsonInterface.Parse(o); } catch (FormatException exception) { jsonInterface.SetFailure(UnityString.Format("FormatException:[{0}] ", exception.ToString())); } } } } else { jsonInterface.SetFailure(UnityString.Format("Request error:[{0}] Raw response:[{1}]", client.error, client.downloadHandler.text)); } client.Dispose(); internalCallback(jsonInterface, userCallback); }
public override void OnInspectorGUI() { serializedObject.Update(); MovieImporter importer = target as MovieImporter; if (importer != null) { GUILayout.BeginVertical(); m_linearTexture = EditorGUILayout.Toggle(linearTextureContent, m_linearTexture); int bitrate = (int)(GetVideoBitrateForQuality(m_quality) + GetAudioBitrateForQuality(m_quality)); float size = (bitrate / 8 * m_duration); float kbsize = 1024.0f * 1024.0f; m_quality = EditorGUILayout.Slider("Quality", m_quality, 0.0f, 1.0f); GUILayout.Label( UnityString.Format("Approx. {0:0.00} " + (size < kbsize ? "kB" : "MB") + ", {1} kbps", size / (size < kbsize ? 1024.0f : kbsize), bitrate / 1000), EditorStyles.helpBox); GUILayout.EndVertical(); } serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); MovieTexture movie = assetTarget as MovieTexture; if (movie && movie.loop) { EditorGUILayout.Space(); movie.loop = EditorGUILayout.Toggle("Loop", movie.loop); GUILayout.Label("The Loop setting in the Inspector is obsolete. Use the Scripting API to control looping instead.\n\nThe loop setting will be disabled on next re-import or by disabling it above.", EditorStyles.helpBox); } }
private static string intToSizeString(int inValue) { if (inValue < 0) { return("unknown"); } float val = (float)inValue; string[] scale = new string[] { "TB", "GB", "MB", "KB", "Bytes" }; int idx = scale.Length - 1; while (val > 1000.0f && idx >= 0) { val /= 1000f; idx--; } if (idx < 0) { return("<error>"); } return(UnityString.Format("{0:#.##} {1}", val, scale[idx])); }
public override string ToString() { object[] args = new object[] { base.ToString(), this.networkId.ToString("X"), this.nodeId.ToString("X") }; return(UnityString.Format("[{0}]-networkId:0x{1},nodeId:0x{2}", args)); }
public override string ToString() { return(UnityString.Format("[{0}]-address:{1},port:{2},networkId:0x{3},accessTokenString.IsEmpty:{4},nodeId:0x{5},usingRelay:{6}", base.ToString(), address, port, networkId.ToString("X"), string.IsNullOrEmpty(accessTokenString), nodeId.ToString("X"), usingRelay)); }
public override string ToString() { return(UnityString.Format("[{0}]-matches.Count:{1}", base.ToString(), (matches != null) ? matches.Count : 0)); }
public override string ToString() { object[] args = new object[] { base.ToString(), this.matches.Count }; return(UnityString.Format("[{0}]-matches.Count:{1}", args)); }
public override string ToString() { return(UnityString.Format("{0} @ {1}:{2} [{3},{4}]", networkId, address, port, nodeId, usingRelay)); }
/// <summary> /// <para>Provides string description of current class data.</para> /// </summary> public override string ToString() { return(UnityString.Format("[{0}]-address:{1},port:{2},networkId:0x{3},nodeId:0x{4},usingRelay:{5}", (object)base.ToString(), (object)this.address, (object)this.port, (object)this.networkId.ToString("X"), (object)this.nodeId.ToString("X"), (object)this.usingRelay)); }
public static string GetMessage(string failureMessage) { return(UnityString.Format("{0} {1}", (object)"Assertion failure.", (object)failureMessage)); }
public static string NullFailureMessage(object value, bool expectNull) { return(AssertionMessageUtil.GetMessage(UnityString.Format("Value was {0}Null", (object)(!expectNull ? "" : "not ")), UnityString.Format("Value was {0}Null", (object)(!expectNull ? "not " : "")))); }
public static string GetEqualityMessage(object actual, object expected, bool expectEqual) { return(AssertionMessageUtil.GetMessage(UnityString.Format("Values are {0}equal.", (object)(!expectEqual ? "" : "not ")), UnityString.Format("{0} {2} {1}", actual, expected, (object)(!expectEqual ? "!=" : "==")))); }
public static string GetMessage(string failureMessage, string expected) { return(AssertionMessageUtil.GetMessage(UnityString.Format("{0}{1}{2} {3}", (object)failureMessage, (object)Environment.NewLine, (object)"Expected:", (object)expected))); }
public override string GetInfoString() { // TextureInspector code is reused for RenderTexture and Cubemap inspectors. // Make sure we can handle the situation where target is just a Texture and // not a Texture2D. Texture t = target as Texture; Texture2D t2 = target as Texture2D; TextureImporter textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(t)) as TextureImporter; string info = t.width + "x" + t.height; bool showSize = true; bool isPackedSprite = textureImporter && textureImporter.qualifiesForSpritePacking; bool isNormalmap = IsNormalMap(t); bool stillNeedsCompression = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(t)); bool isNPOT = t2 != null && TextureUtil.IsNonPowerOfTwo(t2); GraphicsFormat format = t.graphicsFormat; showSize = !stillNeedsCompression; if (isNPOT) { info += " (NPOT)"; } if (stillNeedsCompression) { info += " (Not yet compressed)"; } else { if (isNormalmap) { switch (format) { case GraphicsFormat.RGBA_DXT5_SRGB: case GraphicsFormat.RGBA_DXT5_UNorm: info += " DXTnm"; break; case GraphicsFormat.R8G8B8A8_SRGB: case GraphicsFormat.R8G8B8A8_UNorm: case GraphicsFormat.B8G8R8A8_SRGB: case GraphicsFormat.B8G8R8A8_UNorm: info += " Nm 32 bit"; break; case GraphicsFormat.R4G4B4A4_UNormPack16: case GraphicsFormat.B4G4R4A4_UNormPack16: info += " Nm 16 bit"; break; default: info += " " + GraphicsFormatUtility.GetFormatString(format); break; } } else if (isPackedSprite) { TextureFormat desiredFormat; ColorSpace dummyColorSpace; int dummyComressionQuality; textureImporter.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out desiredFormat, out dummyColorSpace, out dummyComressionQuality); info += "\n " + GraphicsFormatUtility.GetFormatString(format) + "(Original) " + TextureUtil.GetTextureFormatString(desiredFormat) + "(Atlas)"; } else { info += " " + GraphicsFormatUtility.GetFormatString(format); } } if (showSize) { info += "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(t)); } if (TextureUtil.GetUsageMode(t) == TextureUsageMode.AlwaysPadded) { var glWidth = TextureUtil.GetGPUWidth(t); var glHeight = TextureUtil.GetGPUHeight(t); if (t.width != glWidth || t.height != glHeight) { info += UnityString.Format("\nPadded to {0}x{1}", glWidth, glHeight); } } else if (TextureUtil.GetUsageMode(t) == TextureUsageMode.BakedLightmapRGBM || TextureUtil.GetUsageMode(t) == TextureUsageMode.RealtimeLightmapRGBM || TextureUtil.GetUsageMode(t) == TextureUsageMode.RGBMEncoded) { info += "\nRGBM encoded"; } else if (TextureUtil.GetUsageMode(t) == TextureUsageMode.DoubleLDR || TextureUtil.GetUsageMode(t) == TextureUsageMode.BakedLightmapDoubleLDR) { info += "\ndLDR encoded"; } return(info); }