Пример #1
0
    private static void CreateSfxDataBase(List <SoundClip> list, string fileNameTitle)
    {
        string fileName = fileNameTitle + typeof(SoundClipList).Name;
        string path     = System.IO.Path.Combine(ASSET_SFX_FOLDER, fileName + ".asset");

        if (File.Exists(path))
        {
            SoundClipList database = (SoundClipList)AssetDatabase.LoadAssetAtPath(path, typeof(SoundClipList));

            if (null == database)
            {
                return;
            }

            database._soundList = new SoundClip[list.Count];

            for (int i = 0; i < list.Count; i++)
            {
                database._soundList[i] = list[i];
            }
            EditorUtility.SetDirty(database);
        }
        else
        {
            SoundClipList database = ScriptableObject.CreateInstance <SoundClipList>();

            database._soundList = new SoundClip[list.Count];

            for (int i = 0; i < list.Count; i++)
            {
                database._soundList[i] = list[i];
            }
            AssetDatabase.CreateAsset(database, path);
        }
    }
Пример #2
0
    void Awake()
    {
        playerRigidbody   = GetComponent <Rigidbody>();
        playerAnimator    = GetComponent <Animator>();
        playerSoundClip   = GetComponent <SoundClipList>();
        playerAudioSource = GetComponent <AudioSource>();
        playerInventory   = GetComponent <PlayerInventory>();



        charViewCamera = transform.Find("CharCamera").GetComponent <Camera>();
        upViewCamera   = transform.Find("UpViewCamera").GetComponent <Camera>();
        //upViewCamera = GameObject.Find("UpViewCamera").GetComponent<Camera>();

        if (InputManager.s_cameraMode == InputManager.CAM_MODE_UPVIEW)
        {
            charViewCamera.enabled = false;
            upViewCamera.enabled   = true;
        }
        else
        {
            charViewCamera.enabled = true;
            upViewCamera.enabled   = false;
        }


        curState = PlayerState.AnimMoveCorutine;    //ser default state
    }
Пример #3
0
    void Awake()
    {
        playerRigidbody   = GetComponent <Rigidbody>();
        playerAnimator    = GetComponent <Animator>();
        playerSoundClip   = GetComponent <SoundClipList>();
        playerAudioSource = GetComponent <AudioSource>();

        curState         = PlayerState.AnimMoveCorutine; //ser default state
        targetQuaternion = transform.rotation;           //quat init
    }
Пример #4
0
    public static void UpdateSoundClipList()
    {
        string        path = "Assets/Data/Sound/SoundClipList.asset";
        SoundClipList list = AssetDatabase.LoadAssetAtPath(path, typeof(SoundClipList)) as SoundClipList;

        foreach (SoundClip sc in list._soundList)
        {
            string scPath = AssetDatabase.GetAssetPath(sc.Clip);
            sc._clipPath = scPath.Substring(16);
            Debug.Log(sc._clipPath);
        }
        EditorUtility.SetDirty(list);
    }
Пример #5
0
    public void OnWizardOtherButton()
    {
        SoundClipList scl = AssetDatabase.LoadAssetAtPath(SoundClipAsset, typeof(SoundClipList)) as SoundClipList;

        _soundNames = new List <string>();
        HandleWavDirectory(SoundClipPath);
        bool hasError = false;

        foreach (SoundClip sc in scl._soundList)
        {
            bool   ret = false;
            string scn = "";
            if (sc.Clip == null)
            {
                scn      = sc._name;
                hasError = true;
            }
            else
            {
                scn = sc.Clip.ToString().Replace(" (UnityEngine.AudioClip)", "");
            }
            foreach (string sn in _soundNames)
            {
                if (sn.Contains(scn + ".wav"))
                {
                    ret = true;
                }
            }
            if (!ret)
            {
                Debug.LogError("sc have no source clip : " + scn);
                _deadClip.Add(sc);
                hasError = true;
            }
            string AssetName = sc._clipPath;
            AssetName = "Assets/Resources/" + sc._clipPath + ".wav";
            string[] nameAll = sc._clipPath.Split('/');
            if (nameAll[nameAll.Length - 1] != sc._name)
            {
                hasError = true;
                Debug.LogError("id name != clip name");
                Debug.Log(sc._name);
                if (sc.Clip != null)
                {
                    Debug.Log(sc.Clip.ToString());
                }
                string path = AssetDatabase.RenameAsset(AssetName, sc._name);
                Debug.LogError(path);
            }

            AssetName    = AssetName.Replace(nameAll[nameAll.Length - 1], sc._name);
            AssetName    = AssetName.Replace("Assets/Resources/", "");
            AssetName    = AssetName.Replace(".wav", "");
            sc._clipPath = AssetName;
        }
        //remove no use file
        if (!hasError)
        {
            List <SoundClip> sclNew = new List <SoundClip>();
            foreach (string sn in _soundNames)
            {
                bool ret = false;
                foreach (SoundClip sc in scl._soundList)
                {
                    if (sn.Contains(sc._name + ".wav"))
                    {
                        ret = true;
                    }
                }
                if (!ret)
                {
                    Debug.LogError(sn + " is not used for sound clip list!");
                    Debug.LogError("we will add it to list");
                    SoundClip scnew     = new SoundClip();
                    string    AssetName = sn;
                    AssetName = AssetName.Replace("Assets/Resources/", "");
                    AssetName = AssetName.Replace(".wav", "");

                    scnew._clipPath = AssetName;
                    string[] nameAll = AssetName.Split('/');
                    scnew._name = nameAll[nameAll.Length - 1];
                    sclNew.Add(scnew);

                    /*System.IO.FileInfo fileSound = new System.IO.FileInfo(sn);
                     * if(fileSound.Exists)
                     * {
                     *      fileSound.Delete();
                     * }
                     * string snMeta = sn + ".meta";
                     * fileSound = new System.IO.FileInfo(snMeta);
                     * if(fileSound.Exists)
                     * {
                     *      fileSound.Delete();
                     * }*/
                }
            }

            foreach (SoundClip sc in scl._soundList)
            {
                sclNew.Add(sc);
                sclNew.Sort(SortByName);
            }
            SoundClipList newScl = ScriptableObject.CreateInstance <SoundClipList>();
            newScl._soundList = sclNew.ToArray();
            scl = null;
            AssetDatabase.CreateAsset(newScl, SoundClipAsset);
        }
        else
        {
            List <SoundClip> sclNew = new List <SoundClip>();
            foreach (SoundClip sc in scl._soundList)
            {
                if (_deadClip.Count > 0 && _deadClip.Contains(sc))
                {
                    continue;
                }
                sclNew.Add(sc);
                sclNew.Sort(SortByName);
            }
            SoundClipList newScl = ScriptableObject.CreateInstance <SoundClipList>();
            newScl._soundList = sclNew.ToArray();
            scl = null;
            _deadClip.Clear();
            _deadClip = null;
            AssetDatabase.CreateAsset(newScl, SoundClipAsset);
        }
        Debug.Log(_soundNames.Count);
        _soundNames.Clear();
        _soundNames = null;
    }