Esempio n. 1
0
        // This is an event handler on the scene view to handle dragging our objects from the browser
        // and creating new gameobjects
        void SceneUpdate(SceneView sceneView)
        {
            Event e = Event.current;

            if (e.type == EventType.dragPerform)
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    (DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef) ||
                     DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)))
                {
                    GameObject newObject = null;
                    if (DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef))
                    {
                        newObject = new GameObject("FMOD Studio Emitter");
                        newObject.AddComponent <StudioEventEmitter>();
                        newObject.GetComponent <StudioEventEmitter>().Event      = new EventRef();
                        newObject.GetComponent <StudioEventEmitter>().Event.Path = ((EditorEventRef)DragAndDrop.objectReferences[0]).Path;
                        Undo.RegisterCreatedObjectUndo(newObject, "Create FMOD Studio Emitter");
                    }
                    else
                    {
                        newObject = new GameObject("FMOD Studio Loader");
                        newObject.AddComponent <StudioBankLoader>();
                        newObject.GetComponent <StudioBankLoader>().Banks       = new BankRefList();
                        newObject.GetComponent <StudioBankLoader>().Banks.Banks = new List <BankRef>();
                        BankRef bankRef = new BankRef(((EditorBankRef)DragAndDrop.objectReferences[0]).Name);
                        newObject.GetComponent <StudioBankLoader>().Banks.AllBanks = false;
                        newObject.GetComponent <StudioBankLoader>().Banks.Banks.Add(bankRef);
                        Undo.RegisterCreatedObjectUndo(newObject, "Create FMOD Studio Loader");
                    }
                    Ray ray = HandleUtility.GUIPointToWorldRay(e.mousePosition);
                    var hit = HandleUtility.RaySnap(ray);
                    if (hit != null)
                    {
                        newObject.transform.position = ((RaycastHit)hit).point;
                    }
                    else
                    {
                        newObject.transform.position = ray.origin + ray.direction * 10.0f;
                    }
                    Selection.activeObject = newObject;
                    e.Use();
                }
            }
            if (e.type == EventType.DragUpdated)
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    (DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef) ||
                     DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    DragAndDrop.AcceptDrag();
                    e.Use();
                }
            }
        }
Esempio n. 2
0
 public static void UnloadBank(BankRef bankRef)
 {
     UnloadBank(bankRef.Name);
 }
Esempio n. 3
0
 /// <summary>
 /// Load a bank.
 /// </summary>
 /// <param name="bankRef"></param>
 /// <exception cref="BankLoadException"></exception>
 public static void LoadBank(BankRef bankRef, bool loadSamples = false)
 {
     LoadBank(bankRef.Name);
 }