Inheritance: MonoBehaviour
示例#1
0
    void OnEnable()
    {
        m_AkGameObject = target as AkGameObj;

        DefaultHandles.Hidden = hideDefaultHandle;
    }
示例#2
0
        /// <summary>
        /// 初始化加载wwise对象和数据
        /// </summary>
        public void InitWwise()
        {
            LoadUserSoundSetting();
            LoadUserVolumeSetting();
            wwiseGameObjectDic.Clear();
            //首先创建背景音乐播放对象,默认创建一个游戏音乐对象和一个游戏音效对象
            wWiseGameMusic = new GameObject("WwiseGameMusic");
            wWiseGameMusic.AddComponent <AkInitializer>();
            wWiseGameMusic.AddComponent <AkAudioListener>();
            AkGameObj _obj = wWiseGameMusic.GetComponent <AkGameObj>();

            if (_obj != null)
            {
                _obj.isEnvironmentAware = false;
            }

            //创建第一个音效对象
            CreateWwisGameobject(this.wWiseGameSoundEffect);
            //创建第一个音效对象
            CreateWwisGameobject(this.wWiseGameSoundOther);

            //获取加载文件路径,默认为StreamingAssets\audio\SoundbanksInfo.txt 如果无法找到查找默认资源加载路劲下的SoundbanksInfo.txt
            //string path = AkSoundEngineController.GetDecodedBankFullPath() + "/SoundbanksInfo.txt";
            string path = Application.persistentDataPath + "/AssetBundle/DecodedBanks/SoundbanksInfo.txt";

            Logger.Log("配置文件位置   " + path);
            string soundStr = string.Empty;

            if (File.Exists(path))
            {
                Logger.Log("文件存在  加载音效配置");
                soundStr = File.ReadAllText(path);
            }
            else
            {
                TextAsset textAsset = Resources.Load <TextAsset>("SoundbanksInfo");
                if (textAsset == null)
                {
                    Logger.Log("内置音效文件无");
                    return;
                }
                soundStr = textAsset.text;
            }
            //读取名称和资源关系
            BnkJson bJson = JsonUtility.FromJson <BnkJson>(soundStr);

            if (bJson != null)
            {
                List <BnkMap> m = bJson.m;
                if (m != null)
                {
                    foreach (BnkMap bMap in m)
                    {
                        if (!allBnkDic.ContainsKey(bMap.n))
                        {
                            allBnkDic.Add(bMap.n, bMap.d);
                        }
                    }
                }
            }
        }
示例#3
0
    void OnGUI()
    {
        // Make sure everything is initialized
        // Use soundbank path, because Wwise project path can be empty.
        if (String.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath) && WwiseSetupWizard.Settings.WwiseProjectPath == null)
        {
            WwiseSetupWizard.Settings = WwiseSettings.LoadSettings();
        }

        string initialProject = WwiseSetupWizard.Settings.WwiseProjectPath;

        if (VersionStyle == null)
        {
            InitGuiStyles();
        }
        GUILayout.Label(m_WwiseVersionString, VersionStyle);

        DrawSettingsPart();

        string newProject = WwiseSetupWizard.Settings.WwiseProjectPath;         // DrawSettingsPart modifies WwiseSetupWizard.Settings.WwiseProjectPath directly.

        if (initialProject != newProject)
        {
            ApplyNewProject = true;
        }

        using (new GUILayout.VerticalScope())
        {
            GUILayout.FlexibleSpace();

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("OK", GUILayout.Width(60)))
                {
                    if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath))
                    {
                        EditorUtility.DisplayDialog("Error", "Please fill in the required settings", "Ok");
                    }

                    if (AkWwiseSettingsWindow.m_oldCreateWwiseGlobal != WwiseSetupWizard.Settings.CreateWwiseGlobal)
                    {
                        AkInitializer[] AkInitializers = UnityEngine.Object.FindObjectsOfType(typeof(AkInitializer)) as AkInitializer[];
                        if (WwiseSetupWizard.Settings.CreateWwiseGlobal == true)
                        {
                            if (AkInitializers.Length == 0)
                            {
                                //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded
                                //in the wrong order.
                                GameObject objWwise = new GameObject("WwiseGlobal");

                                //Attach initializer and terminator components
                                AkInitializer init = objWwise.AddComponent <AkInitializer>();
                                AkWwiseProjectInfo.GetData().CopyInitSettings(init);
                            }
                        }
                        else if (AkInitializers.Length != 0 && AkInitializers[0].gameObject.name == "WwiseGlobal")
                        {
                            GameObject.DestroyImmediate(AkInitializers[0].gameObject);
                        }
                    }

                    if (AkWwiseSettingsWindow.m_oldCreateWwiseListener != WwiseSetupWizard.Settings.CreateWwiseListener)
                    {
                        if (Camera.main != null)
                        {
                            AkAudioListener akListener = Camera.main.GetComponentInChildren <AkAudioListener>();

                            if (WwiseSetupWizard.Settings.CreateWwiseListener)
                            {
                                if (akListener == null)
                                {
                                    akListener = Undo.AddComponent <AkAudioListener>(Camera.main.gameObject);
                                    AkGameObj akGameObj = akListener.GetComponentInChildren <AkGameObj>();
                                    akGameObj.isEnvironmentAware = false;
                                }

                                // If Unity had already an audio listener, we want to remove it when adding our own.
                                AudioListener unityListener = Camera.main.GetComponentInChildren <AudioListener>();
                                if (unityListener != null)
                                {
                                    Component.DestroyImmediate(unityListener);
                                }
                            }
                        }
                    }

                    if (m_oldShowMissingRigidBodyWarning != WwiseSetupWizard.Settings.ShowMissingRigidBodyWarning)
                    {
                        InternalEditorUtility.RepaintAllViews();
                    }

                    WwiseSettings.SaveSettings(WwiseSetupWizard.Settings);

                    CloseWindow();

                    // Pop the Picker window so the user can start working right away
                    AkWwiseProjectInfo.GetData();                     // Load data
                    if (ApplyNewProject)
                    {
                        //Clear the data, the project path changed.
                        AkWwiseProjectInfo.GetData().Reset();
                        ApplyNewProject = false;
                        AkWwisePicker.WwiseProjectFound = true;
                    }
                    AkWwiseProjectInfo.Populate();
                    AkWwisePicker.PopulateTreeview();
                    AkWwisePicker.init();
                }

                if (GUILayout.Button("Cancel", GUILayout.Width(60)))
                {
                    WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(true);
                    CloseWindow();
                }

                GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
            }

            GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
        }
    }
示例#4
0
 internal AudioEmitter(AkGameObj target)
 {
     this.target = target;
 }
    public void CreateSurfaceReflector()
    {
        boxCollider        = gameObject.GetComponent <BoxCollider>();
        akSurfaceReflector = gameObject.GetComponent <AkSurfaceReflector>();
        akGameObject       = gameObject.GetComponent <AkGameObj>();
        rigidBody          = gameObject.GetComponent <Rigidbody>();
        meshCollider       = gameObject.GetComponent <MeshCollider>();
        meshRenderer       = gameObject.GetComponent <MeshRenderer>();

        // Check if we have any components there already.
        if (meshCollider != null)
        {
            DestroyImmediate(meshCollider);
        }

        if (boxCollider != null)
        {
            DestroyImmediate(boxCollider);
        }

        if (akSurfaceReflector != null)
        {
            DestroyImmediate(akSurfaceReflector);
        }

        if (akGameObject != null)
        {
            DestroyImmediate(akGameObject);
        }

        if (rigidBody != null)
        {
            DestroyImmediate(rigidBody);
        }

        if (meshRenderer != null)
        {
            DestroyImmediate(meshRenderer);
        }

        // Re-add our components.
        boxCollider        = gameObject.AddComponent <BoxCollider>();
        akSurfaceReflector = gameObject.AddComponent <AkSurfaceReflector>();
        akGameObject       = gameObject.AddComponent <AkGameObj>();
        rigidBody          = gameObject.AddComponent <Rigidbody>();

        // Set properties.
        boxCollider.isTrigger           = true;
        akGameObject.isEnvironmentAware = true;

        rigidBody.mass                   = 1f;
        rigidBody.drag                   = 0f;
        rigidBody.angularDrag            = 0.05f;
        rigidBody.useGravity             = false;
        rigidBody.isKinematic            = true;
        rigidBody.interpolation          = 0;
        rigidBody.collisionDetectionMode = 0;

        gameObject.name = "SurfaceReflector";

        // Destroy our ReflectorCreator when done.
        DestroyImmediate(this);
    }
示例#6
0
 internal static void PlayJumpstepAudio(AudioGrp_FootMatType matType, AkGameObj target)
 {
     AudioEntry.Dispatcher.SetSwitch(target, matType);
     AudioEntry.Dispatcher.PostEvent(GetEventConfig(EAudioUniqueId.JumpStep), target, true);
 }
示例#7
0
        public Migration14Data()
        {
            int fullSceneListenerMask = 0;

            // Get all AkAudioListeners in the scene.
            var listenerObjects = FindObjectsOfType(typeof(AkAudioListener)) as AkAudioListener[];

            foreach (var listener in listenerObjects)
            {
                // Add AkGameObj to AkAudioListeners
                if (listener.GetComponent <AkGameObj>() == null)
                {
                    AkGameObj akGameObj = listener.gameObject.AddComponent <AkGameObj>();
                    if (akGameObj)
                    {
                        akGameObj.isEnvironmentAware = false;
                        Debug.Log("WwiseUnity: Added AkGameObj to <" + listener.gameObject.name + ">.");
                    }
                    else
                    {
                        Debug.LogError("WwiseUnity: Failed to add AkGameObj to <" + listener.gameObject.name + ">.");
                    }
                }

                var listenerId = listener.listenerId;
                if (listenerId >= 0 && listenerId < AK_NUM_LISTENERS)
                {
                    if (listeners[listenerId] == null)
                    {
                        listeners[listenerId] = new List <AkAudioListener>();
                    }

                    listeners[listenerId].Add(listener);
                    fullSceneListenerMask |= (1 << listenerId);
                }
                else
                {
                    Debug.LogError("WwiseUnity: Invalid listenerId <" + listenerId + "> found during migration.");
                }
            }

            if (fullSceneListenerMask == 0)
            {
                Debug.LogWarning("WwiseUnity: Listeners were not added via components within this Scene.");
                listeners = null;
            }
            else
            {
                for (int ii = 0; ii < AK_NUM_LISTENERS; ++ii)
                {
                    if (listeners[ii] != null && listeners[ii].Count > 1)
                    {
                        Debug.LogWarning("WwiseUnity: Multiple listeners <" + listeners[ii].Count + "> with same listenerId <" + ii + "> found during migration.");
                    }
                }

                if (fullSceneListenerMask == 1)
                {
                    Debug.Log("WwiseUnity: Default listeners will be used for this Scene.");
                    listeners = null;
                }
            }
        }
示例#8
0
 internal void SetSwitch(AkGameObj target, AudioGrp_HitMatType hitMatType)
 {
     SetSwitch(target, (int)AudioGrp_HitMatType.Id, (int)hitMatType);
 }
示例#9
0
 internal void SetSwitch(AkGameObj target, AudioGrp_FootMatType footMatType)
 {
     SetSwitch(target, (int)AudioGrp_FootMatType.Id, (int)footMatType);
 }
示例#10
0
 internal void SetSwitch(AkGameObj target, AudioGrp_MeleeAttack meleeAttack)
 {
     SetSwitch(target, (int)AudioGrp_MeleeAttack.Id, (int)meleeAttack);
 }
示例#11
0
 internal void SetSwitch(AkGameObj target, AudioGrp_BulletType bulletType)
 {
     SetSwitch(target, (int)AudioGrp_BulletType.Id, (int)bulletType);
 }
示例#12
0
 internal void SetSwitch(AkGameObj target, AuidoGrp_RefShotMode shotModelGrpIndex)
 {
     SetSwitch(target, (int)AuidoGrp_RefShotMode.Id, (int)shotModelGrpIndex);
 }
示例#13
0
        private void LoadBankResultHandler(AudioEventItem econfig, AkGameObj target, bool skipSwitchSetting = false)
        {
            var audioEmitter = typesController.GetEmitter(target);

            audioEmitter.PostEvent(econfig, skipSwitchSetting);
        }
示例#14
0
 internal void PrepareEvent(int eventId, AkGameObj target)
 {
 }
示例#15
0
 public void StopListeningToEmitter(AkGameObj emitter)
 {
     EmittersToStartListeningTo.Remove(emitter);
     EmittersToStopListeningTo.Add(emitter);
 }
示例#16
0
 internal void SetSwitch(AkGameObj target, AudioGrp_Magazine magIndex)
 {
     SetSwitch(target, (int)AudioGrp_Magazine.Id, (int)magIndex);
 }
示例#17
0
        //TODO:同步
        internal static void PlayWeaponReloadAudio(int weaponId, AudioGrp_Magazine magazineIndex, AkGameObj target)
        {
            AudioEventItem evtConfig =
                SingletonManager.Get <AudioWeaponManager>().FindById(weaponId, (item) => item.ReloadStart);

            if (evtConfig != null)
            {
                AudioEntry.Dispatcher.SetSwitch(target, magazineIndex);
                AudioEntry.Dispatcher.PostEvent(evtConfig, target);
            }
            else
            {
                AudioEntry.Logger.ErrorFormat("Audio Post event failed,target:{0},evtCfg:{1}", target, weaponId);
            }


            // audioLogger.Info("Auido play once");
        }
示例#18
0
 internal void SetSwitch(AkGameObj target, AudioGrp_Footstep stepIndex)
 {
     SetSwitch(target, (int)AudioGrp_Footstep.Id, (int)stepIndex);
 }
 private void Awake()
 {
     InitIntervalsAndFadeRates();
     m_gameObj = GetComponent <AkGameObj>();
 }
示例#20
0
        private void SetSwitch(AkGameObj target, int grpId, int index)
        {
            var emitterData = typesController.GetEmitter(target);

            emitterData.SetSwitch(grpId, index);
        }
    void OnEnable()
    {
        m_AkGameObject = target as AkGameObj;

        DefaultHandles.Hidden = hideDefaultHandle;
    }
示例#22
0
        // Any extra asset stuff not handled or loaded by the Asset Bundle should be sorted here.
        // This is also a good place to set up any references, if you need to.
        // References within SkillState scripts can be done through EntityStateConfigs instead.
        internal static void PopulateAssets()
        {
            if (!mainAssetBundle)
            {
                Debug.LogError(SamusPlugin.MODNAME + ": AssetBundle not found. Unable to Populate Assets.");
                SamusPlugin.cancel = true;
                return;
            }
            Tracker = mainAssetBundle.LoadAsset <GameObject>("samusTrackingIndicator");
            Missile = mainContentPack.projectilePrefabs[3];
            //Missile = (GameObject)result;
            if (Missile)
            {
                Missile.GetComponent <RoR2.Projectile.ProjectileSingleTargetImpact>().impactEffect = LegacyResourcesAPI.Load <GameObject>("prefabs/effects/impacteffects/missileexplosionvfx");
                GameObject refer = LegacyResourcesAPI.Load <GameObject>("prefabs/projectiles/missileprojectile");

                AkEvent[] akEvents   = refer.GetComponents <AkEvent>();
                AkGameObj akGameObj1 = Missile.AddComponent <AkGameObj>();
                akGameObj1 = refer.GetComponent <AkGameObj>();
                foreach (AkEvent item in akEvents)
                {
                    AkEvent b = Missile.AddComponent <AkEvent>();
                    b = item;
                }
            }
            //contentPack.FindAsset("projectilePrefabs", "SamusaltMissile", out object result2);
            altMissile = mainContentPack.projectilePrefabs[0];
            if (altMissile)
            {
                altMissile.GetComponent <RoR2.Projectile.ProjectileSingleTargetImpact>().impactEffect = LegacyResourcesAPI.Load <GameObject>("prefabs/effects/impacteffects/MissileExplosionVFX");
                GameObject refer     = LegacyResourcesAPI.Load <GameObject>("prefabs/projectiles/engiharpoon");
                AkGameObj  akGameObj = altMissile.AddComponent <AkGameObj>();
                AkEvent    akEvent   = altMissile.AddComponent <AkEvent>();
                akGameObj = refer.GetComponent <AkGameObj>();
                akEvent   = refer.GetComponent <AkEvent>();
            }
            //contentPack.FindAsset("projectilePrefabs", "SamusSuperMissile", out object res);
            sMissile = mainContentPack.projectilePrefabs[6];
            if (sMissile)
            {
                sMissile.GetComponent <RoR2.Projectile.ProjectileImpactExplosion>().impactEffect = LegacyResourcesAPI.Load <GameObject>("Prefabs/Effects/ImpactEffects/ExplosionVFX");
                GameObject refer   = LegacyResourcesAPI.Load <GameObject>("prefabs/projectiles/mageicebolt");
                AkEvent    akEvent = sMissile.AddComponent <AkEvent>();
                akEvent = refer.GetComponent <AkEvent>();
            }
            //contentPack.FindAsset("projectilePrefabs", "SamusBeam", out object ree);
            beam = mainContentPack.projectilePrefabs[1];
            if (beam)
            {
                GameObject refer   = LegacyResourcesAPI.Load <GameObject>("prefabs/projectiles/mageicebolt");
                AkEvent    akEvent = beam.AddComponent <AkEvent>();
                akEvent = refer.GetComponent <AkEvent>();
            }
            beamghost = beam.GetComponent <RoR2.Projectile.ProjectileController>().ghostPrefab;
            bomb      = mainContentPack.projectilePrefabs[2];
            if (bomb)
            {
                bomb.GetComponent <SphereCollider>().material = LegacyResourcesAPI.Load <GameObject>("Prefabs/Projectiles/CommandoGrenadeProjectile").GetComponent <SphereCollider>().material;
                bomb.GetComponent <RoR2.Projectile.ProjectileImpactExplosion>().impactEffect         = LegacyResourcesAPI.Load <GameObject>("prefabs/effects/omnieffect/omniexplosionvfxcommandogrenade");
                bomb.GetComponent <RoR2.Projectile.ProjectileImpactExplosion>().lifetimeExpiredSound = LegacyResourcesAPI.Load <RoR2.NetworkSoundEventDef>("networksoundeventdefs/nsecommandogrenadebounce");
            }
            bool a;

            if (mainContentPack.projectilePrefabs[1].GetComponent <AkEvent>() != null)
            {
                a = true;
            }
            else
            {
                a = false;
            }

            cBeam = mainAssetBundle.LoadAsset <GameObject>("beamproj");

            //Debug.Log(a);



            //defaultDance = mainAssetBundle.LoadAsset<AnimationClip>("DanceMoves");
            //CustomEmotesAPI.AddCustomAnimation(defaultDance, true);

            if (VRAPI.VR.enabled)
            {
                VRAPI.VR.PreventRendererDisable("DGSamusBody", "ball2Mesh");
                VRDomHand = mainAssetBundle.LoadAsset <GameObject>("samusGun");
                MotionControls.AddHandPrefab(VRDomHand);
                VRnDomHand = mainAssetBundle.LoadAsset <GameObject>("samusHand");
                MotionControls.AddHandPrefab(VRnDomHand);
                //gun = VRassets.LoadAsset<RuntimeAnimatorController>("gun");
                //ray = VRassets.LoadAsset<RuntimeAnimatorController>("ray");
                combatVisor = mainAssetBundle.LoadAsset <GameObject>("combatVisor");
                combatHUD   = mainAssetBundle.LoadAsset <GameObject>("combatHud");
                ballHUD     = mainAssetBundle.LoadAsset <GameObject>("ballHUD");
                bossHUD     = mainAssetBundle.LoadAsset <GameObject>("bossHud");
                HUDHandler  = mainAssetBundle.LoadAsset <GameObject>("hudHandler");
            }
        }