/// <summary>
        /// スクリプトを作成する.
        /// </summary>
        public static void CreateScript()
        {
            var sb = StringBuilderEx.sb.Clear();

            sb.AppendLine("/// <summary>");
            sb.AppendLine("/// レイヤー定義.");
            sb.AppendLine("/// </summary>");
            sb.AppendFormatLine("public static class {0}", Path.GetFileNameWithoutExtension(EditorConstParams.CreateLayerDefine_FILENAME));
            sb.AppendLine("{");

            sb.AppendLine("\t// layer.");
            foreach (var n in InternalEditorUtility.layers.
                     Select(c => new { var = RemoveInvalidChars(c), val = LayerMask.NameToLayer(c) }))
            {
                sb.Append("\t").AppendFormatLine(@"public const int {0} = {1};", n.var, n.val);
            }
            sb.AppendLine("\t// layer mask.");
            foreach (var n in InternalEditorUtility.layers.
                     Select(c => new { var = RemoveInvalidChars(c), val = LayerMask.NameToLayer(c) }))
            {
                sb.Append("\t").AppendFormatLine(@"public const int {0}Mask = 1<<{1};", n.var, n.val);
            }
            sb.Append("\t").AppendLine(@"public const int AllMask = 0x7fffffff;");
            sb.AppendLine("}");

            var dirPath = Path.GetDirectoryName(EditorConstParams.CreateLayerDefine_PATH);

            // ディレクトリが存在しなければディレクトリを作成する.
            DirectoryEx.CreateDirectoryIfNotExists(dirPath);
            // ファイルに書き込む.
            File.WriteAllText(EditorConstParams.CreateLayerDefine_PATH, sb.ToString(), Encoding.UTF8);
            AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
        }
Beispiel #2
0
        public static void LogHierarchyTree()
        {
            if (!IsValidate())
            {
                return;
            }
            var hierarchyTreeString = TransformEx.ToStringHierarchyTree();

//hierarchyTreeString = TransformEx.ToStringHierarchyTree("", GameObjectEx.FindFromRoot("/Canvas/ViewAnchor/LoginView/LoginButton").transform);
            {
                var dirPath = Path.GetDirectoryName(EditorConstParams.LogHierarchyTree_FILE_PATH);
                // ディレクトリが存在しなければディレクトリを作成する.
                DirectoryEx.CreateDirectoryIfNotExists(dirPath);
            }
            File.WriteAllText(EditorConstParams.LogHierarchyTree_FILE_PATH, hierarchyTreeString, Encoding.UTF8);
        }
Beispiel #3
0
        /// <summary>
        /// キャプチャを取りファイル保存する.
        /// </summary>
        /// <param name="fileName"></param>
        public static void SaveToFile(string fileName = "")
        {
            if (string.IsNullOrEmpty(fileName))
            {
#if UNITY_EDITOR
                fileName = "./Output/ScreenShot/";
#endif
                // 現在時刻からファイル名を決定
                fileName += DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".png";
            }
            // フォルダを作成する.
            var parentDirPath = Directory.GetParent(fileName).FullName;
            DirectoryEx.CreateDirectoryIfNotExists(parentDirPath);
            // キャプチャを撮り、ファイル保存する.
#if UNITY_2017_1_OR_NEWER
            UnityEngine.ScreenCapture.CaptureScreenshot(fileName);
#else
            Application.CaptureScreenshot(filename);
#endif
            Debug.Log("@ScreenShot.SaveToFile() fileName:" + fileName);
        }