/// <summary> /// 获取正在调用的成员的名字。 /// </summary> /// <returns>成员名字。</returns> public static string GetCurrentMemberName() { string name = new StackTrace(true).GetFrame(1).GetMethod().Name; if (name.StartsWith("get_") == true) { return name.Substring("get_".Length); } if (name.StartsWith("set_") == true) { return name.Substring("set_".Length); } return name; }
/// <summary> /// 获取调用当前上下文的成员的名字。 /// </summary> /// <returns>成员名字。</returns> public static string GetCallerMemberName() { string name = new StackTrace(true).GetFrame(2).GetMethod().Name; if (name.StartsWith("get_", StringComparison.Ordinal) == true) { return name.Substring("get_".Length); } if (name.StartsWith("set_", StringComparison.Ordinal) == true) { return name.Substring("set_".Length); } return name; }
//protected abstract MonoBehaviour TargetController { get; } private void DrawGlobalUI() { DrawCustomGlobalUI(); GUILayout.Label("SKS Global settings", EditorStyles.boldLabel); EditorGUI.indentLevel = EditorGUI.indentLevel + IndentSize; GUILayout.Space(BumperSize); if (_imageFoldout = EditorGUILayout.Foldout(_imageFoldout, "Image Settings", EditorStyles.foldout)) { EditorGUI.indentLevel = EditorGUI.indentLevel + IndentSize; GUILayout.BeginHorizontal(); { GUILayout.Space(EditorGUI.indentLevel * 10); #if SKS_VR GUILayout.Label("Single Pass Stereo Rendering: " + SKSGlobalRenderSettings.SinglePassStereo); #endif } GUILayout.EndHorizontal(); GUI.enabled = !Application.isPlaying; #if SKS_VR GUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indentLevel * 10); GUILayout.Label("Recursion in VR is very expensive. 3 is the typically acceptable max (prefer 0 if possible)"); GUILayout.EndHorizontal(); #endif SKSGlobalRenderSettings.RecursionNumber = EditorGUILayout.IntSlider( new GUIContent("Recursion Number", "The number of times that EffectRenderers will draw through each other."), SKSGlobalRenderSettings.RecursionNumber, 0, 10); if (SKSGlobalRenderSettings.RecursionNumber > 1) { EditorGUILayout.HelpBox( "Please be aware that recursion can get very expensive very quickly." + " Consider making this scale with the Quality setting of your game.", MessageType.Warning); } GUI.enabled = true; GUILayout.BeginHorizontal(); { GUILayout.Space(EditorGUI.indentLevel * 10); SKSGlobalRenderSettings.AggressiveRecursionOptimization = GUILayout.Toggle( SKSGlobalRenderSettings.AggressiveRecursionOptimization, new GUIContent("Enable Aggressive Optimization for Recursion", "Aggressive optimization will halt recursive rendering immediately if the " + "source EffectRenderer cannot raycast to the EffectRenderers it is trying to render. " + "Without Occlusion Culling (due to lack of Unity Support), this is a lifesaver for " + "large scenes.")); } GUILayout.EndHorizontal(); if (SKSGlobalRenderSettings.AggressiveRecursionOptimization) { EditorGUILayout.HelpBox( "Enabling this option can save some serious performance, " + "but it is possible for visual bugs to arise due to portals being partially inside walls. " + "If you are seeing black EffectRenderers while recursing, try turning this option off " + "and see if it helps. If it does, then please make sure that your EffectRenderers are not" + "inside walls.", MessageType.Warning); } GUILayout.BeginHorizontal(); { GUILayout.Space(EditorGUI.indentLevel * 10); SKSGlobalRenderSettings.AdaptiveQuality = GUILayout.Toggle(SKSGlobalRenderSettings.AdaptiveQuality, new GUIContent("Enable Adaptive Quality Optimization for Recursion", "Adaptive quality rapidly degrades the quality of recursively " + "rendered EffectRenderers. This is usually desirable.")); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(EditorGUI.indentLevel * 10); SKSGlobalRenderSettings.CustomSkybox = GUILayout.Toggle(SKSGlobalRenderSettings.CustomSkybox, new GUIContent("Enable Skybox Override", "Enable custom skybox rendering. This is needed for skyboxes to not look strange through" + "SKSEffectCameras on some platforms when optimizations are enabled.")); } GUILayout.EndHorizontal(); EditorGUI.indentLevel = EditorGUI.indentLevel - IndentSize; } GUILayout.Space(BumperSize); if (_editorFoldout = EditorGUILayout.Foldout(_editorFoldout, "Editor Settings", EditorStyles.foldout)) { EditorGUI.indentLevel = EditorGUI.indentLevel + IndentSize; GUILayout.BeginHorizontal(); { GUILayout.Space(EditorGUI.indentLevel * 10); SKSGlobalRenderSettings.Gizmos = GUILayout.Toggle(SKSGlobalRenderSettings.Gizmos, new GUIContent("Draw Gizmos", "Draw SKS Gizmos when applicable assets are selected in the Editor")); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(EditorGUI.indentLevel * 10); SKSGlobalRenderSettings.Preview = GUILayout.Toggle(SKSGlobalRenderSettings.Preview, new GUIContent("Draw EffectRenderer Previews (experimental, buggy on many Unity versions)", "Draw EffectRenderer Previews when selected in the Editor." + " Experimental.")); } GUILayout.EndHorizontal(); EditorGUI.indentLevel = EditorGUI.indentLevel - IndentSize; } GUILayout.Label("Something doesn't look right!/I'm getting errors!"); SKSGlobalRenderSettings.UvFlip = GUILayout.Toggle(SKSGlobalRenderSettings.UvFlip, "My stuff is rendering upside down!"); GUILayout.Label("Troubleshooting:"); string path = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); if (path == null) { return; } path = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar)); string studioName = "SKStudios"; string root = path.Substring(0, path.LastIndexOf(studioName) + (studioName.Length + 1)); string PDFPath = Path.Combine(root, AssetName); PDFPath = Path.Combine(PDFPath, "README.pdf"); GUILayout.BeginHorizontal(); { if (GUILayout.Button(AssetName + " Manual")) { Application.OpenURL(PDFPath); } if (GUILayout.Button("Setup")) { SettingsWindow.Show(); } } GUILayout.EndHorizontal(); EditorGUI.indentLevel = EditorGUI.indentLevel - IndentSize; }
/// <summary> /// Check validation statement for a property /// </summary> /// <param name="assert"> /// Validation statement /// </param> /// <param name="errorInfo"> /// Validation statement description /// </param> /// <remarks> /// This method could only be called from methods starting with {ValidateMethodPrefix} /// Checked property name is calculated from the caller method name. /// </remarks> protected void Validate(bool assert, string errorInfo) { string callerName = new StackTrace().GetFrame(1).GetMethod().Name; string property = callerName.Substring(ValidateMethodPrefix.Length); if (!assert) { this.AddValidationError(property, errorInfo); } }
private static string GetDefaultIncludeFilename() { string filename; try { filename = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); filename = Path.Combine( Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + "_Include.txt"); if ((!File.Exists(filename)) || string.IsNullOrEmpty(Application.dataPath)) { return null; } } catch { return null; } filename = filename.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); string dataPath = Application.dataPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); if ((filename.StartsWith(dataPath, StringComparison.OrdinalIgnoreCase))) { filename = filename.Substring(dataPath.Length).TrimStart(Path.DirectorySeparatorChar); } return filename; }