Exemple #1
0
    void RebuildMaterialIndexArray()
    {
        materialArray = new int[_target.GetComponent <MeshRenderer>().sharedMaterials.Length];
        str           = new string[materialArray.Length];

        for (int i = 0; i < materialArray.Length; i++)
        {
            materialArray[i] = i;
            str[i]           = i.ToString() + ". " + _target.GetComponent <MeshRenderer>().sharedMaterials[i].ToString();

            //
            if (str[i].IndexOf("null") == -1)
            {
                str[i] = str[i].Remove(str[i].IndexOf("("));
            }
        }

        if (_target.materialIndex > materialArray.Length - 1)
        {
            _target.materialIndex = materialArray.Length - 1;
        }
    }
Exemple #2
0
    private void UseLegacyAnimations()
    {
        var anim = FlowController.GetComponent <Animation>();

        if (anim == null)
        {
            Debug.LogError("Legacy Animation Clip was not created/added because ther is no Animation component on " +
                           FlowController.gameObject.name);
            return;
        }


        _videoLength = EditorGUILayout.IntField("Animation Length", _videoLength);

        if (!_hasSelectedAnimation && anim != null && anim.clip != null)
        {
            _hasSelectedAnimation = true;
            _clipName             = anim.clip.name;
        }
        else if (anim != null && anim.clip == null)
        {
            _hasSelectedAnimation = false;
        }

        _clipName = EditorGUILayout.TextField("Animation Clip Name", _clipName);

        if (GUILayout.Button("Prepare Animation Clip"))
        {
#if UNITY_3_5
            Undo.RegisterUndo(anim, "Create Animation Clip");
#else
            Undo.RecordObject(anim, "Create Animation Clip");
#endif
            AnimationClip clip = null;

            var updateAnimationClip = anim.clip != null && anim.clip.name == _clipName;
            clip = updateAnimationClip ? anim.clip : new AnimationClip();
            FillAnimation(clip);

            if (!updateAnimationClip)
            {
                anim.AddClip(clip, _clipName);
            }

            EditorUtility.SetDirty(anim);
        }
    }