Exemplo n.º 1
0
        public HIRCSection(BinaryReader br) : base("HIRC", null)
        {
            uint objectCount = br.ReadUInt32();

            for (uint i = 0; i < objectCount; i++)
            {
                WwiseObjectType objType   = (WwiseObjectType)br.ReadByte();
                uint            objLength = br.ReadUInt32();
                switch (objType)
                {
                case WwiseObjectType.Sound_SFX__Sound_Voice:
                    this.objects.Add(new SoundSFXVoiceWwiseObject(br, objLength));
                    break;

                case WwiseObjectType.Event_Action:
                    this.objects.Add(new EventActionWwiseObject(br, objLength));
                    break;

                case WwiseObjectType.Event:
                    this.objects.Add(new EventWwiseObject(br));
                    break;

                default:
                    this.objects.Add(new WwiseObject(objType, br.ReadBytes((int)objLength)));
                    break;
                }
            }
        }
Exemplo n.º 2
0
    public static WwiseObjectReference FindOrCreateWwiseObject(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
    {
        var parentPath  = GetParentPath(wwiseObjectType);
        var path        = System.IO.Path.Combine(parentPath, GetAssetFileName(guid));
        var asset       = FindExistingWwiseObject(wwiseObjectType, guid, path);
        var assetExists = asset != null;

        if (!assetExists)
        {
            AkUtilities.CreateFolder(parentPath);
            asset      = Create(wwiseObjectType);
            asset.guid = guid.ToString().ToUpper();
        }

        var changed = UpdateWwiseObjectData(asset, name);

        if (!assetExists)
        {
            UnityEditor.AssetDatabase.CreateAsset(asset, path);
        }
        else if (changed)
        {
            UnityEditor.EditorUtility.SetDirty(asset);
        }

        return(asset);
    }
Exemplo n.º 3
0
    protected static WwiseObjectReference FindExistingWwiseObject(WwiseObjectType wwiseObjectType, System.Guid guid, string path)
    {
        var asset = UnityEditor.AssetDatabase.LoadAssetAtPath <WwiseObjectReference>(path);

        if (asset)
        {
            return(asset);
        }

        System.Type type = null;
        if (!m_WwiseObjectReferenceClasses.TryGetValue(wwiseObjectType, out type))
        {
            return(null);
        }

        var guids = UnityEditor.AssetDatabase.FindAssets("t:" + type.Name);

        foreach (var assetGuid in guids)
        {
            var assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuid);
            asset = UnityEditor.AssetDatabase.LoadAssetAtPath <WwiseObjectReference>(assetPath);
            if (asset && asset.WwiseObjectType == wwiseObjectType && asset.Guid == guid)
            {
                return(asset);
            }
        }

        return(null);
    }
Exemplo n.º 4
0
        public HIRCSection(BinaryReader br) : base("HIRC", br.BaseStream.Position, null)
        {
            uint objectCount = br.ReadUInt32();

            for (uint i = 0; i < objectCount; i++)
            {
                WwiseObjectType objType   = (WwiseObjectType)br.ReadByte();
                uint            objLength = br.ReadUInt32();
                switch (objType)
                {
                case WwiseObjectType.Sound_SFX__Sound_Voice:
                    this.objects.Add(new SoundSFXVoiceWwiseObject(br, objLength));
                    break;

                case WwiseObjectType.Event_Action:
                    this.objects.Add(new EventActionWwiseObject(br, objLength));
                    break;

                //本家WoTのpckファイルを読み込むとクラッシュするため廃止

                /*case WwiseObjectType.Event:
                 *  this.objects.Add(new EventWwiseObject(br));
                 *  break;*/
                default:
                    this.objects.Add(new WwiseObject(objType, br.ReadBytes((int)objLength)));
                    break;
                }
            }
        }
    public static WwiseObjectReference GetWwiseObjectForMigration(WwiseObjectType wwiseObjectType, byte[] valueGuid)
    {
        System.Guid guid;

        try
        {
            guid = new System.Guid(valueGuid);
        }
        catch
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Invalid guid for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + ">.");
            return(null);
        }

        System.Collections.Generic.Dictionary <System.Guid, WwiseObjectData> map = null;
        if (!WwiseObjectDataMap.TryGetValue(wwiseObjectType, out map))
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Cannot find WwiseObjectReferences of type <WwiseObjectType." + wwiseObjectType + ">.");
            return(null);
        }

        WwiseObjectData data = null;

        if (!map.TryGetValue(guid, out data))
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Cannot find guid <" + guid.ToString() + "> for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + ">.");
            return(null);
        }

        return(FindOrCreateWwiseObject(wwiseObjectType, data.objectName, guid));
    }
    public static WwiseObjectReference FindOrCreateWwiseObject(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
    {
        var path        = AssetFilePath(wwiseObjectType, guid, true);
        var loadedAsset = UnityEditor.AssetDatabase.LoadAssetAtPath <WwiseObjectReference>(path);
        var asset       = loadedAsset ? loadedAsset : Create(wwiseObjectType);
        var id          = AkUtilities.ShortIDGenerator.Compute(name);

        if (asset.objectName != name || asset.id != id)
        {
            asset.objectName = name;
            asset.id         = id;
            asset.guid       = guid.ToString().ToUpper();

            if (loadedAsset)
            {
                UnityEditor.EditorUtility.SetDirty(asset);
            }
        }

        if (!loadedAsset)
        {
            UnityEditor.AssetDatabase.CreateAsset(asset, path);
        }

        return(asset);
    }
    private static string AssetFilePath(WwiseObjectType wwiseObjectType, System.Guid guid, bool createDirectory)
    {
        var relativePath = System.IO.Path.Combine(System.IO.Path.Combine("Wwise", "Resources"), wwiseObjectType.ToString());
        var fileName     = guid.ToString().ToUpper();

        return(AssetFilePath(relativePath, fileName, createDirectory));
    }
Exemplo n.º 8
0
    public static WwiseGroupValueObjectReference GetWwiseObjectForMigration(WwiseObjectType wwiseObjectType, byte[] valueGuid, int id, byte[] groupGuid, int groupId)
    {
        var objectReference = GetWwiseObjectForMigration(wwiseObjectType, valueGuid, id);

        if (!objectReference)
        {
            return(null);
        }

        var groupValueObjectReference = objectReference as WwiseGroupValueObjectReference;

        if (!groupValueObjectReference)
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Not setting WwiseObjectReference since it is not a WwiseGroupValueObjectReference.");
            return(null);
        }

        var groupObjectReference = GetWwiseObjectForMigration(groupValueObjectReference.GroupWwiseObjectType, groupGuid, groupId);

        if (!groupObjectReference)
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Not setting WwiseObjectReference since its GroupObjectReference cannot be determined.");
            return(null);
        }

        groupValueObjectReference.GroupObjectReference = groupObjectReference;
        UnityEditor.EditorUtility.SetDirty(groupValueObjectReference);
        return(groupValueObjectReference);
    }
Exemplo n.º 9
0
 public AkWwiseTreeViewItem(AkWwiseTreeViewItem other) : base(other.id, other.depth, other.displayName)
 {
     objectGuid = other.objectGuid;
     objectType = other.objectType;
     children   = new List <TreeViewItem>();
     this.depth = other.depth;
 }
Exemplo n.º 10
0
    public static WwiseObjectReference FindWwiseObject(WwiseObjectType wwiseObjectType, System.Guid guid)
    {
        var parentPath = GetParentPath(wwiseObjectType);
        var path       = System.IO.Path.Combine(parentPath, GetAssetFileName(guid));

        return(FindExistingWwiseObject(wwiseObjectType, guid, path));
    }
Exemplo n.º 11
0
    public static WwiseObjectReference GetWwiseObjectForMigration(WwiseObjectType wwiseObjectType, byte[] valueGuid, int id)
    {
        if (valueGuid == null)
        {
            return(null);
        }

        System.Collections.Generic.Dictionary <System.Guid, WwiseObjectData> map = null;
        if (!WwiseObjectDataMap.TryGetValue(wwiseObjectType, out map) || map == null)
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Cannot find WwiseObjectReferences of type <WwiseObjectType." + wwiseObjectType + ">.");
            return(null);
        }

        var             guid = System.Guid.Empty;
        WwiseObjectData data = null;

        try
        {
            guid = new System.Guid(valueGuid);
        }
        catch
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Invalid guid for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + ">.");
            return(null);
        }

        var formattedId = (uint)id;

        if (guid != System.Guid.Empty && !map.TryGetValue(guid, out data))
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Cannot find guid <" + guid.ToString() + "> for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + "> in Wwise Project.");

            foreach (var pair in map)
            {
                if (AkUtilities.ShortIDGenerator.Compute(pair.Value.objectName) == formattedId)
                {
                    guid = pair.Key;
                    data = pair.Value;
                    UnityEngine.Debug.LogWarning("WwiseUnity: Found guid <" + guid.ToString() + "> for <" + pair.Value.objectName + ">.");
                    break;
                }
            }
        }

        if (data == null)
        {
            return(null);
        }

        var objectReference = FindOrCreateWwiseObject(wwiseObjectType, data.objectName, guid);

        if (objectReference && objectReference.Id != formattedId)
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: ID mismatch for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + ">. Expected <" + formattedId + ">. Found <" + objectReference.Id + ">.");
        }

        return(objectReference);
    }
Exemplo n.º 12
0
    public AkWwiseTreeViewItem(string displayName, int depth, int id, System.Guid objGuid, WwiseObjectType objType) : base(id, depth, displayName)
    {
        objectGuid = objGuid;
        objectType = objType;

        children   = new List <TreeViewItem>();
        this.depth = depth;
    }
 public override void UpdateSearchResults(string searchFilter, WwiseObjectType objectType = WwiseObjectType.None)
 {
     searchTimer.Stop();
     searchString           = searchFilter;
     searchObjectTypeFilter = objectType;
     searchTimer.Enabled    = true;
     searchTimer.Start();
 }
Exemplo n.º 14
0
 /// <summary>
 /// Play or pause an object in Wwise authoring.
 /// Creates a WaapiCommand object containing a lambda call to TogglePlayEventAsync and adds it to the waapiCommandQueue.
 ///</summary>
 /// <param name="objectType">Used to check whether the object is playable.</param>
 /// <param name="guid">GUID of the object to be played.</param>
 static public void TogglePlayEvent(WwiseObjectType objectType, System.Guid guid)
 {
     if (IsPlayable(objectType))
     {
         waapiCommandQueue.Enqueue(new WaapiCommand(
                                       async() => await TogglePlayEventAsync(guid)));
     }
 }
Exemplo n.º 15
0
    public void SetRootItem(string Header, WwiseObjectType ObjType)
    {
        RootItem.Items.Clear();
        RootItem.Header      = Header;
        RootItem.DataContext = new AkTreeInfo(ObjType);
        AddHandlerEvents(RootItem);

        RootItem.IsExpanded = GetExpansionStatus("/" + RootItem.Header);
    }
 public void AddBaseFolder(List <WwiseObjectInfo> infoItems, WwiseObjectType oType)
 {
     if (infoItems != null && infoItems.Count > 0)
     {
         AddItems(infoItems);
         var folder = Find(infoItems[0].objectGUID);
         wwiseObjectFolders[oType] = folder;
     }
 }
Exemplo n.º 17
0
    private static void FlagForRemoval(AkWwiseProjectData.AkBaseInformation info, WwiseObjectType type)
    {
        if (!_WwiseObjectsToRemove.ContainsKey(type))
        {
            _WwiseObjectsToRemove[type] = new System.Collections.Generic.List <AkWwiseProjectData.AkBaseInformation>();
        }

        _WwiseObjectsToRemove[type].Add(info);
    }
Exemplo n.º 18
0
    private static WwiseObjectReference Create(WwiseObjectType wwiseObjectType)
    {
        System.Type type = null;
        if (m_WwiseObjectReferenceClasses.TryGetValue(wwiseObjectType, out type))
        {
            return((WwiseObjectReference)CreateInstance(type));
        }

        return(CreateInstance <WwiseObjectReference>());
    }
Exemplo n.º 19
0
    public static void UpdateWwiseObject(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
    {
        var path  = System.IO.Path.Combine(GetParentPath(wwiseObjectType), GetAssetFileName(guid));
        var asset = FindExistingWwiseObject(wwiseObjectType, guid, path);

        if (asset && UpdateWwiseObjectData(asset, name))
        {
            UnityEditor.EditorUtility.SetDirty(asset);
        }
    }
Exemplo n.º 20
0
    public static void DeleteWwiseObject(WwiseObjectType wwiseObjectType, System.Guid guid)
    {
        var path       = System.IO.Path.Combine(GetParentPath(wwiseObjectType), GetAssetFileName(guid));
        var guidString = UnityEditor.AssetDatabase.AssetPathToGUID(path);

        if (!string.IsNullOrEmpty(guidString))
        {
            UnityEditor.AssetDatabase.DeleteAsset(path);
        }
    }
Exemplo n.º 21
0
 private static void UpdateWwiseObjectReference(WwiseObjectType type, System.Collections.Generic.List <AkWwiseProjectData.EventWorkUnit> infoWwus)
 {
     foreach (var infoWwu in infoWwus)
     {
         foreach (var info in infoWwu.List)
         {
             WwiseObjectReference.UpdateWwiseObjectDataMap(type, info.Name, info.Guid);
         }
     }
 }
Exemplo n.º 22
0
                public WwiseObject(BinaryReader reader)
                {
                    Type   = (WwiseObjectType)reader.ReadByte();
                    Length = reader.ReadUInt32();
                    Id     = reader.ReadUInt32();

                    AdditionalData = Type switch
                    {
                        _ => reader.ReadBytes(Convert.ToInt32(Length - sizeof(uint))),
                    };
                }
Exemplo n.º 23
0
    public AkWwiseTreeView(TreeViewState treeViewState,
                           AkWwiseTreeDataSource data, WwiseObjectType componentType)
        : base(treeViewState)

    {
        m_pickerMode        = PickerMode.ComponentPicker;
        componentObjectType = componentType;
        Initialize(data);
        data.LoadComponentData(componentObjectType);
        Reload();
    }
    public override AkWwiseTreeViewItem GetComponentDataRoot(WwiseObjectType objectType)
    {
        if (!wwiseObjectFolders.ContainsKey(objectType))
        {
            ProjectRoot.AddWwiseItemChild(BuildObjectTypeTree(objectType));
        }

        var tempProjectRoot = new AkWwiseTreeViewItem(ProjectRoot);

        tempProjectRoot.AddWwiseItemChild(wwiseObjectFolders[objectType]);
        return(tempProjectRoot);
    }
    protected static void RegisterWwiseObjectReferenceClass <T>(WwiseObjectType wwiseObjectType) where T : WwiseObjectReference
    {
        var type = typeof(T);

        if (m_WwiseObjectReferenceClasses.ContainsKey(wwiseObjectType))
        {
            UnityEngine.Debug.LogError("WwiseUnity: WwiseObjectReference subclass <" + type.Name + "> already registered for <WwiseObjectType." + wwiseObjectType + ">.");
            return;
        }

        m_WwiseObjectReferenceClasses.Add(wwiseObjectType, type);
    }
Exemplo n.º 26
0
 private static void UpdateWwiseObjectReference(WwiseObjectType groupType, WwiseObjectType type, System.Collections.Generic.List <AkWwiseProjectData.GroupValWorkUnit> infoWwus)
 {
     foreach (var infoWwu in infoWwus)
     {
         foreach (var info in infoWwu.List)
         {
             WwiseObjectReference.UpdateWwiseObjectDataMap(groupType, info.Name, info.Guid);
             foreach (var subTypeInfo in info.values)
             {
                 WwiseObjectReference.UpdateWwiseObjectDataMap(type, subTypeInfo.Name, subTypeInfo.Guid);
             }
         }
     }
 }
Exemplo n.º 27
0
    private static void FlagForInsertion(AkWwiseProjectData.AkBaseInformation info, WwiseObjectType type)
    {
        if (!_WwiseObjectsToAdd.ContainsKey(type))
        {
            _WwiseObjectsToAdd[type] = new System.Collections.Generic.List <AkWwiseProjectData.AkBaseInformation>();
        }

        _WwiseObjectsToAdd[type].Add(info);

        if (!AkUtilities.IsMigrating)
        {
            WwiseObjectReference.UpdateWwiseObject(type, info.Name, info.Guid);
        }
    }
Exemplo n.º 28
0
    public UnityEngine.Texture2D GetIcon(WwiseObjectType type)
    {
        switch (type)
        {
        case WwiseObjectType.AcousticTexture:
            return(m_textureWwiseAcousticTextureIcon);

        case WwiseObjectType.AuxBus:
            return(m_textureWwiseAuxBusIcon);

        case WwiseObjectType.Bus:
            return(m_textureWwiseBusIcon);

        case WwiseObjectType.Event:
            return(m_textureWwiseEventIcon);

        case WwiseObjectType.Folder:
            return(m_textureWwiseFolderIcon);

        case WwiseObjectType.GameParameter:
            return(m_textureWwiseGameParameterIcon);

        case WwiseObjectType.PhysicalFolder:
            return(m_textureWwisePhysicalFolderIcon);

        case WwiseObjectType.Project:
            return(m_textureWwiseProjectIcon);

        case WwiseObjectType.Soundbank:
            return(m_textureWwiseSoundbankIcon);

        case WwiseObjectType.State:
            return(m_textureWwiseStateIcon);

        case WwiseObjectType.StateGroup:
            return(m_textureWwiseStateGroupIcon);

        case WwiseObjectType.Switch:
            return(m_textureWwiseSwitchIcon);

        case WwiseObjectType.SwitchGroup:
            return(m_textureWwiseSwitchGroupIcon);

        case WwiseObjectType.WorkUnit:
            return(m_textureWwiseWorkUnitIcon);

        default:
            return(m_textureWwisePhysicalFolderIcon);
        }
    }
Exemplo n.º 29
0
    public AkWwiseTreeViewItem(WwiseObjectInfo info, int id, int depth) : base(id, depth, info.name)
    {
        objectGuid  = info.objectGUID;
        objectType  = info.type;
        numChildren = info.childrenCount;

        if (objectType == WwiseObjectType.Event)
        {
            numChildren = 0;
        }

        children   = new List <TreeViewItem>();
        this.depth = depth;
    }
    public static void UpdateWwiseObject(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
    {
        var path  = AssetFilePath(wwiseObjectType, guid, false);
        var asset = UnityEditor.AssetDatabase.LoadAssetAtPath <WwiseObjectReference>(path);

        if (!asset)
        {
            return;
        }

        asset.objectName = name;
        asset.id         = AkUtilities.ShortIDGenerator.Compute(name);

        UnityEditor.EditorUtility.SetDirty(asset);
    }
 public PathElement(string Name, WwiseObjectType objType)
 {
     ElementName = Name;
     ObjectType = objType;
 }