private void PrepareDragDrop(object sender, System.EventArgs args)
    {
        var item = (AK.Wwise.TreeView.TreeViewItem)sender;

        try
        {
            if (item == null || !item.IsDraggable)
            {
                return;
            }

            var treeInfo       = (AkTreeInfo)item.DataContext;
            var reference      = WwiseObjectReference.FindOrCreateWwiseObject(treeInfo.ObjectType, item.Header, treeInfo.Guid);
            var groupReference = reference as WwiseGroupValueObjectReference;
            if (groupReference)
            {
                var ParentTreeInfo = (AkTreeInfo)item.Parent.DataContext;
                groupReference.SetupGroupObjectReference(item.Parent.Header, ParentTreeInfo.Guid);
            }

            UnityEngine.GUIUtility.hotControl        = 0;
            UnityEditor.DragAndDrop.objectReferences = new UnityEngine.Object[] { DragDropHelperMonoScript, reference };
            UnityEditor.DragAndDrop.SetGenericData(AkDragDropHelper.DragDropIdentifier, reference);
            UnityEditor.DragAndDrop.StartDrag("Dragging an AkObject");
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.Log(e.ToString());
        }
    }
 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);
         }
     }
 }
    private static bool UpdateWwiseObjectData(WwiseObjectReference wwiseObjectReference, string name)
    {
        var id = AkUtilities.ShortIDGenerator.Compute(name);

        if (wwiseObjectReference.objectName == name && wwiseObjectReference.id == id)
        {
            return(false);
        }

        wwiseObjectReference.objectName = name;
        wwiseObjectReference.id         = id;
        return(true);
    }
Exemple #4
0
        public void MigrateData()
        {
            ObjectReference = WwiseObjectReference.GetWwiseObjectForMigration(WwiseObjectType, valueGuid);

            MigrateDataExtension();

            if (IsValid())
            {
                UnityEngine.Debug.Log("WwiseUnity: Converted " + Name + " in " + GetType().FullName);
            }

            ClearData();
        }
 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);
             }
         }
     }
 }
    public static void UpdateWwiseObjectReferenceData()
    {
        UnityEngine.Debug.Log("WwiseUnity: Updating Wwise Object References");

        WwiseObjectReference.ClearWwiseObjectDataMap();
        UpdateWwiseObjectReference(WwiseObjectType.AuxBus, AkWwiseProjectInfo.GetData().AuxBusWwu);
        UpdateWwiseObjectReference(WwiseObjectType.Event, AkWwiseProjectInfo.GetData().EventWwu);
        UpdateWwiseObjectReference(WwiseObjectType.Soundbank, AkWwiseProjectInfo.GetData().BankWwu);
        UpdateWwiseObjectReference(WwiseObjectType.GameParameter, AkWwiseProjectInfo.GetData().RtpcWwu);
        UpdateWwiseObjectReference(WwiseObjectType.Trigger, AkWwiseProjectInfo.GetData().TriggerWwu);
        UpdateWwiseObjectReference(WwiseObjectType.AcousticTexture, AkWwiseProjectInfo.GetData().AcousticTextureWwu);
        UpdateWwiseObjectReference(WwiseObjectType.StateGroup, WwiseObjectType.State, AkWwiseProjectInfo.GetData().StateWwu);
        UpdateWwiseObjectReference(WwiseObjectType.SwitchGroup, WwiseObjectType.Switch, AkWwiseProjectInfo.GetData().SwitchWwu);
    }
    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);
        }
    }
    internal static void FindReferencesInScene(AkWwiseTreeViewItem item)
    {
        var reference = WwiseObjectReference.FindWwiseObject(item.objectType, item.objectGuid);
        var path      = UnityEditor.AssetDatabase.GetAssetPath(reference);

        if (path.IndexOf(' ') != -1)
        {
            path = '"' + path + '"';
        }

        if (path == string.Empty)
        {
            UnityEngine.Debug.Log($"No references to {item.displayName} in scene.");
            return;
        }

#if !UNITY_2019_1_OR_NEWER
        //drop "Assets" part of path
        path = string.Join("/", path.Split('/').Skip(1));
#endif

        var searchFilter = "ref:" + path;

        System.Type type = typeof(UnityEditor.SearchableEditorWindow);
        System.Reflection.FieldInfo info = type.GetField("searchableWindows",
                                                         System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
        var searchableWindows = info.GetValue(null) as List <UnityEditor.SearchableEditorWindow>;

        foreach (UnityEditor.SearchableEditorWindow sw in searchableWindows)
        {
            info = type.GetField("m_HierarchyType",
                                 System.Reflection.BindingFlags.NonPublic);
            if (sw.GetType().ToString() == "UnityEditor.SceneHierarchyWindow")
            {
                if (sw.GetType().ToString() == "UnityEditor.SceneHierarchyWindow")
                {
                    System.Reflection.MethodInfo setSearchFilter = typeof(UnityEditor.SearchableEditorWindow).GetMethod(
                        "SetSearchFilter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    object[] parameters = new object[] { searchFilter, 0, false, false };

                    setSearchFilter.Invoke(sw, parameters);
                    sw.Repaint();
                }
            }
        }
    }
    protected override void SetupDragAndDrop(SetupDragAndDropArgs args)
    {
        UnityEditor.DragAndDrop.PrepareStartDrag();

        var draggedRows = GetRows().Where(item => args.draggedItemIDs.Contains(item.id)).ToList();
        var draggedItem = draggedRows[0] as AkWwiseTreeViewItem;

        if (draggedItem.objectGuid == System.Guid.Empty ||
            draggedItem.objectType == WwiseObjectType.Bus ||
            draggedItem.objectType == WwiseObjectType.PhysicalFolder ||
            draggedItem.objectType == WwiseObjectType.Folder ||
            draggedItem.objectType == WwiseObjectType.WorkUnit ||
            draggedItem.objectType == WwiseObjectType.Project ||
            draggedItem.objectType == WwiseObjectType.StateGroup ||
            draggedItem.objectType == WwiseObjectType.SwitchGroup)
        {
            return;
        }


        var reference = WwiseObjectReference.FindOrCreateWwiseObject(draggedItem.objectType, draggedItem.name, draggedItem.objectGuid);

        if (!reference)
        {
            return;
        }

        var groupReference = reference as WwiseGroupValueObjectReference;

        if (groupReference)
        {
            var parent = draggedItem.parent as AkWwiseTreeViewItem;
            groupReference.SetupGroupObjectReference(parent.name, parent.objectGuid);
        }

        UnityEditor.MonoScript script;
        if (DragDropMonoScriptMap.TryGetValue(reference.WwiseObjectType, out script))
        {
            UnityEngine.GUIUtility.hotControl = 0;
            UnityEditor.DragAndDrop.PrepareStartDrag();
            UnityEditor.DragAndDrop.objectReferences = new UnityEngine.Object[] { script };
            AkWwiseTypes.DragAndDropObjectReference  = reference;
            UnityEditor.DragAndDrop.StartDrag("Dragging an AkObject");
        }
    }
Exemple #10
0
    private void SetGuid(AK.Wwise.TreeView.TreeViewItem in_item)
    {
        m_serializedObject.Update();

        var obj            = in_item.DataContext as AkWwiseTreeView.AkTreeInfo;
        var reference      = WwiseObjectReference.FindOrCreateWwiseObject(m_type, in_item.Header, obj.Guid);
        var groupReference = reference as WwiseGroupValueObjectReference;

        if (groupReference)
        {
            obj = in_item.Parent.DataContext as AkWwiseTreeView.AkTreeInfo;
            groupReference.SetupGroupObjectReference(in_item.Parent.Header, obj.Guid);
        }

        m_WwiseObjectReference.objectReferenceValue = reference;

        m_serializedObject.ApplyModifiedProperties();
    }
    private static bool UpdateWwiseObjectData(WwiseObjectReference wwiseObjectReference, string name)
    {
        var id      = AkUtilities.ShortIDGenerator.Compute(name);
        var changed = false;

        if (wwiseObjectReference.objectName != name || wwiseObjectReference.id != id)
        {
            changed = true;
        }

        wwiseObjectReference.objectName = name;
        wwiseObjectReference.id         = id;

        if (!wwiseObjectReference.IsComplete())
        {
            changed = true;
            wwiseObjectReference.CompleteData();
        }
        return(changed);
    }
Exemple #12
0
    private void PrepareDragDrop(object sender, System.EventArgs args)
    {
        var item = (TreeViewItem)sender;

        try
        {
            if (item == null || !item.IsDraggable)
            {
                return;
            }

            var treeInfo  = (AkTreeInfo)item.DataContext;
            var reference = WwiseObjectReference.FindOrCreateWwiseObject(treeInfo.ObjectType, item.Header, treeInfo.Guid);
            if (!reference)
            {
                return;
            }

            var groupReference = reference as WwiseGroupValueObjectReference;
            if (groupReference)
            {
                var ParentTreeInfo = (AkTreeInfo)item.Parent.DataContext;
                groupReference.SetupGroupObjectReference(item.Parent.Header, ParentTreeInfo.Guid);
            }

            MonoScript script;
            if (DragDropMonoScriptMap.TryGetValue(reference.WwiseObjectType, out script))
            {
                GUIUtility.hotControl = 0;
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.objectReferences           = new Object[] { script };
                AkUtilities.DragAndDropObjectReference = reference;
                DragAndDrop.StartDrag("Dragging an AkObject");
            }
        }
        catch (System.Exception e)
        {
            Debug.Log(e.ToString());
        }
    }
Exemple #13
0
        public static bool ProcessSingleGuidType(UnityEditor.SerializedProperty wwiseObjectReferenceProperty, WwiseObjectType wwiseObjectType,
                                                 UnityEditor.SerializedProperty valueGuidProperty, UnityEditor.SerializedProperty idProperty)
        {
            if (wwiseObjectReferenceProperty == null)
            {
                UnityEngine.Debug.LogError("WwiseUnity: This migration step is no longer necessary.");
                return(false);
            }

            var valueGuid = GetByteArray(valueGuidProperty);

            if (valueGuid == null)
            {
                var serializedObject = wwiseObjectReferenceProperty.serializedObject;
                UnityEngine.Debug.Log("WwiseUnity: No data to migrate <" + wwiseObjectType + "> on <" + serializedObject.targetObject.GetType() + ">.");
                return(false);
            }

            var objectReference = WwiseObjectReference.GetWwiseObjectForMigration(wwiseObjectType, valueGuid, GetId(idProperty));

            return(SetWwiseObjectReferenceProperty(wwiseObjectReferenceProperty, objectReference));
        }
    private void UpdateFiles()
    {
        m_totWwuCnt = m_WwuToProcess.Count;

        var iBasePathLen = s_wwiseProjectPath.Length + 1;
        var iUnprocessed = 0;

        while (m_WwuToProcess.Count - iUnprocessed > 0)
        {
            System.Collections.IEnumerator e = m_WwuToProcess.GetEnumerator();
            for (var i = 0; i < iUnprocessed + 1; i++)
            {
                e.MoveNext();
            }

            var fullPath = e.Current as string;
            var relPath  = fullPath.Substring(iBasePathLen);
            var typeStr  = relPath.Remove(relPath.IndexOf(System.IO.Path.DirectorySeparatorChar));
            if (!CreateWorkUnit(relPath, typeStr, fullPath))
            {
                iUnprocessed++;
            }
        }

        //Add the unprocessed directly.  This can happen if we don't find the parent WorkUnit.
        //Normally, it should never happen, this is just a safe guard.
        while (m_WwuToProcess.Count > 0)
        {
            System.Collections.IEnumerator e = m_WwuToProcess.GetEnumerator();
            e.MoveNext();
            var fullPath = e.Current as string;
            var relPath  = fullPath.Substring(iBasePathLen);
            var typeStr  = relPath.Remove(relPath.IndexOf(System.IO.Path.DirectorySeparatorChar));
            UpdateWorkUnit(fullPath, typeStr, relPath);
        }

        foreach (var pair in _WwiseObjectsToAdd)
        {
            System.Collections.Generic.List <AkWwiseProjectData.AkBaseInformation> removeList = null;
            if (!_WwiseObjectsToRemove.TryGetValue(pair.Key, out removeList))
            {
                continue;
            }

            removeList.Sort(AkWwiseProjectData.AkBaseInformation.CompareByGuid);
            foreach (var info in pair.Value)
            {
                var index = removeList.BinarySearch(info, AkWwiseProjectData.AkBaseInformation.CompareByGuid);
                if (index >= 0)
                {
                    removeList.RemoveAt(index);
                }
            }
        }

        foreach (var pair in _WwiseObjectsToRemove)
        {
            var type      = pair.Key;
            var childType = type == WwiseObjectType.StateGroup ? WwiseObjectType.State : WwiseObjectType.Switch;

            foreach (var info in pair.Value)
            {
                var groupValue = info as AkWwiseProjectData.GroupValue;
                if (groupValue != null)
                {
                    foreach (var value in groupValue.values)
                    {
                        WwiseObjectReference.DeleteWwiseObject(childType, value.Guid);
                    }
                }

                WwiseObjectReference.DeleteWwiseObject(type, info.Guid);
            }
        }

        UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        UnityEditor.EditorUtility.ClearProgressBar();
    }
Exemple #15
0
 protected virtual void SetSerializedObject(UnityEditor.SerializedProperty serializedProperty, WwiseObjectReference wwiseObjectReference)
 {
     serializedProperty.objectReferenceValue = wwiseObjectReference;
 }
Exemple #16
0
        private static bool SetWwiseObjectReferenceProperty(UnityEditor.SerializedProperty wwiseObjRefProperty, WwiseObjectReference objRef)
        {
            var previousObjectReference = wwiseObjRefProperty.objectReferenceValue as WwiseObjectReference;

            if (previousObjectReference == objRef)
            {
                if (objRef)
                {
                    UnityEngine.Debug.Log("WwiseUnity: WwiseObjectReference already set to <" + objRef.DisplayName + "> on <" + wwiseObjRefProperty.serializedObject.targetObject + "> for type <" + objRef.WwiseObjectType + ">.");
                }
                else
                {
                    UnityEngine.Debug.Log("WwiseUnity: WwiseObjectReference already set to <null> on <" + wwiseObjRefProperty.serializedObject.targetObject + ">.");
                }
                return(false);
            }

            if (previousObjectReference)
            {
                if (objRef)
                {
                    UnityEngine.Debug.LogWarning("WwiseUnity: Overwriting WwiseObjectReference on <" + wwiseObjRefProperty.serializedObject.targetObject + "> for type <" + objRef.WwiseObjectType + "> from <" + previousObjectReference.DisplayName + "> to <" + objRef.DisplayName + ">.");
                }
                else
                {
                    UnityEngine.Debug.LogWarning("WwiseUnity: Overwriting WwiseObjectReference on <" + wwiseObjRefProperty.serializedObject.targetObject + "> from <" + previousObjectReference.DisplayName + "> to <null>.");
                }
            }
            else if (objRef)
            {
                UnityEngine.Debug.Log("WwiseUnity: Setting WwiseObjectReference on <" + wwiseObjRefProperty.serializedObject.targetObject + "> for type <" + objRef.WwiseObjectType + "> to <" + objRef.DisplayName + ">.");
            }
            else
            {
                UnityEngine.Debug.Log("WwiseUnity: Setting WwiseObjectReference on <" + wwiseObjRefProperty.serializedObject.targetObject + "> to <null>.");
            }

            wwiseObjRefProperty.objectReferenceValue = objRef;
            return(true);
        }
Exemple #17
0
 public void SetupReference(string name, System.Guid guid)
 {
     ObjectReference = WwiseObjectReference.FindOrCreateWwiseObject(WwiseObjectType, name, guid);
 }