コード例 #1
0
    public static void CreateAsset()
    {
        StringDataBase asset = ScriptableObject.CreateInstance <StringDataBase>();

        string path = UnityEditor.AssetDatabase.GetAssetPath(UnityEditor.Selection.activeObject);

        if (path == "")
        {
            path = "Assets";
        }
        else if (Path.GetExtension(path) != "")
        {
            path = path.Replace(Path.GetFileName(UnityEditor.AssetDatabase.GetAssetPath(UnityEditor.Selection.activeObject)), "");
        }

        string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(path + "/" + "renameMe_StringDB" + ".asset");

        UnityEditor.AssetDatabase.CreateAsset(asset, assetPathAndName);

        UnityEditor.AssetDatabase.SaveAssets();
        //UnityEditor.EditorUtility.FocusProjectWindow();
        UnityEditor.Selection.activeObject = asset;
    }
コード例 #2
0
        /// <summary>
        /// Parses String Information Blocks and add them to a parsed HPK tree
        /// </summary>
        /// <param name="hpkelem">HPK element holding the input data</param>
        /// <param name="root">Tree node which new nodes will be added to</param>
        /// <param name="StringID">Last used string ID (increased when string found)</param>
        /// <param name="db">String database where new strings will be added to</param>
        private void ParsePackageSibt(HPKElement hpkelem, ParsedHpkNode root, ref UInt16 StringID, StringDataBase db)
        {
            ParsedHpkNode    branch = new ParsedHpkNode(hpkelem, hpkelem.Name);
            HiiSibtBlockBase elem   = (HiiSibtBlockBase)hpkelem;

            switch (elem.BlockType)
            {
            case EFI_HII_SIBT_e.EFI_HII_SIBT_STRING_UCS2:
                string StringText = ((HiiSibtBlockStringUcs2.Payload_t)elem.Payload).StringText;
                StringID++;
                branch.Name = StringID.ToDecimalString(5) + " " + StringText;
                db.Strings.Add(new KeyValuePair <ushort, string>(StringID, StringText));
                break;

            case EFI_HII_SIBT_e.EFI_HII_SIBT_SKIP1: StringID += ((EFI_HII_SIBT_SKIP1_BLOCK)elem.Header).SkipCount; return; // Skip

            case EFI_HII_SIBT_e.EFI_HII_SIBT_SKIP2: StringID += ((EFI_HII_SIBT_SKIP2_BLOCK)elem.Header).SkipCount; return; // Skip

            case EFI_HII_SIBT_e.EFI_HII_SIBT_END: return;                                                                  // Skip

            default:
                foreach (HiiSibtBlockBase child in elem.Childs)
                {
                    ParsePackageSibt(child, branch, ref StringID, db);
                }
                break;     // simply add all others 1:1 when no specific handler exists
            }

            root.Childs.Add(branch);
        }