Exemple #1
0
    void Awake()
    {
        moveDirection = transform.TransformDirection(Vector3.forward);

        controller = this.GetComponent <CharacterController>();

        charAvatar = this.gameObject.GetComponent <EQBrowser.Avatar>();

        charAvatar.SetCurGroundHeight(this.gameObject.transform.position.y);

        //TODO: Animation
    }
    void Awake()
    {
        m_colliderControl = this.gameObject.GetComponent <CharacterColliderController>();
        m_avatar          = this.gameObject.GetComponent <EQBrowser.Avatar>();
        m_charControl     = this.gameObject.GetComponent <CharacterController>();

        m_avatar.SetCurGroundHeight(this.gameObject.transform.position.y);

        if (m_colliderControl == null)
        {
            Debug.LogError(string.Format("Cannot find Character Collider Controller for {0}", this.gameObject.name));
        }

        if (m_avatar == null)
        {
            Debug.LogError(string.Format("Cannot find Avatar for {0}", this.gameObject.name));
        }
    }
Exemple #3
0
    void AttemptMatchTextureToSlot(GameObject m_modelPrefab, Object texturesDirObj, bool overWriteRects)
    {
        //First find the AvatarTextureCreatorData
        AvatarTextureCreatorData avatarData = m_modelPrefab.GetComponentInChildren <AvatarTextureCreatorData>();

        //If we can't find the component
        if (avatarData == null)
        {
            //Look for the avatar component
            EQBrowser.Avatar avatar = m_modelPrefab.GetComponentInChildren <EQBrowser.Avatar>();

            //If avatar isn't null, then use it's gameobject to add it, otherwise eject with an error
            if (avatar != null)
            {
                avatarData = avatar.gameObject.AddComponent <EQBrowser.AvatarTextureCreatorData>();
            }
            else
            {
                Debug.LogError(string.Format("Can't find an AvatarTextureCreatorData OR Avatar, not finishing on {0}", m_modelPrefab.name));
                return;
            }
        }

        string texAssetFolderPath = AssetDatabase.GetAssetPath(texturesDirObj);

        string dataPath      = Application.dataPath;
        string texFolderPath = dataPath.Substring(0, dataPath.Length - 6) + texAssetFolderPath;

        //Create the source textures slots
        avatarData.SourceTextures = new Texture2D[14];
        if (avatarData.SourceTextureRects.Length != avatarData.SourceTextures.Length)
        {
            avatarData.SourceTextureRects = new Rect[avatarData.SourceTextures.Length];
        }

        //string[] allMatFilePaths = Directory.GetFiles(matFolderPath, "*.mat", SearchOption.AllDirectories);
        //Get all the different texture file types to make this more future proof
        string[][] allTexFilePathsROUGH = new string[4][];
        allTexFilePathsROUGH[0] = Directory.GetFiles(texFolderPath, "*.bmp", SearchOption.AllDirectories);
        allTexFilePathsROUGH[1] = Directory.GetFiles(texFolderPath, "*.tga", SearchOption.AllDirectories);
        allTexFilePathsROUGH[2] = Directory.GetFiles(texFolderPath, "*.psd", SearchOption.AllDirectories);
        allTexFilePathsROUGH[3] = Directory.GetFiles(texFolderPath, "*.png", SearchOption.AllDirectories);

        //Combine them all into one nice list for easier processing
        string[] allTexFilePaths = new string[allTexFilePathsROUGH[0].Length + allTexFilePathsROUGH[1].Length + allTexFilePathsROUGH[2].Length + allTexFilePathsROUGH[3].Length];

        int index = 0;

        for (int i = 0; i < allTexFilePathsROUGH.Length; i++)
        {
            for (int j = 0; j < allTexFilePathsROUGH[i].Length; j++)
            {
                allTexFilePaths[index] = allTexFilePathsROUGH[i][j];
                index++;
            }
        }

        if (allTexFilePaths.Length < 1)
        {
            Debug.LogError(string.Format("Can't find any textures! Aborting on model: {0}", m_modelPrefab.name));
            return;
        }

        //Now go through and look for matches
        int  count     = 0;
        bool foundItem = true;

        System.Collections.Generic.List <string> missingItems = new System.Collections.Generic.List <string>();
        string searchName = "";
        int    texCount   = 0;

        for (int i = 0; i < avatarData.SourceTextures.Length; i++)
        {
            if (foundItem == false)
            {
                missingItems.Add(searchName);
            }

            //Hopefully get the correct file name
            searchName = ConvertTextureIndexToSearchString(i, allTexFilePaths[0]);

            //Now search through all the textures for that file to assign it to the slot
            for (texCount = 0; texCount < allTexFilePaths.Length; texCount++)
            {
                //We're going to set up the default rects for the uvs here too
                if (avatarData.SourceTextureRects[i] != null && overWriteRects)
                {
                    avatarData.SourceTextureRects[i] = new Rect(0, 0, 1f, 1f);
                }

                string texName = allTexFilePaths[texCount].Substring(dataPath.Length - 6);
                if (searchName.ToLower() == Path.GetFileNameWithoutExtension(texName).ToLower())
                {
                    //We should have the correct texture, so assign it
                    avatarData.SourceTextures[i] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(texName);
                    count++;
                    foundItem = true;
                    break;
                }
            }

            if (texCount >= allTexFilePaths.Length)
            {
                foundItem = false;
            }
        }

        Debug.Log(string.Format("Finished with model: {0} and found {1} textures. Missing the following:", m_modelPrefab.name, count));
        for (int i = 0; i < missingItems.Count; i++)
        {
            Debug.Log(missingItems[i]);
        }
    }
    void Awake()
    {
        moveDirection = transform.TransformDirection(Vector3.forward);

        controller = this.GetComponent<CharacterController>();

        charAvatar = this.gameObject.GetComponent<EQBrowser.Avatar>();

        charAvatar.SetCurGroundHeight(this.gameObject.transform.position.y);

        //TODO: Animation
    }
    void Awake()
    {
        m_colliderControl = this.gameObject.GetComponent<CharacterColliderController>();
        m_avatar = this.gameObject.GetComponent<EQBrowser.Avatar>();
        m_charControl = this.gameObject.GetComponent<CharacterController>();

        m_avatar.SetCurGroundHeight(this.gameObject.transform.position.y);

        if (m_colliderControl == null)
        {
            Debug.LogError(string.Format("Cannot find Character Collider Controller for {0}", this.gameObject.name));
        }

        if (m_avatar == null)
        {
            Debug.LogError(string.Format("Cannot find Avatar for {0}", this.gameObject.name));
        }
    }