Example #1
0
        public void switchByName(string cellName, Animator animator, object callback)
        {
            if (!isInited)
            {
                init();
            }
            int index = MapEx.getInt(mapIndex, cellName);

            if (needSwitchController)
            {
                if (animator != null)
                {
                    animator.runtimeAnimatorController = animatorControllers [index];
                }
                else
                {
                    Debug.LogError("animator is null");
                }
            }

            if (switchType == CLSwitchType.showOrHide)
            {
                for (int i = 0; i < partObjs.Count; i++)
                {
                    if (i == index)
                    {
                        NGUITools.SetActive(partObjs [i], true);
                    }
                    else
                    {
                        NGUITools.SetActive(partObjs [i], false);
                    }
                }
                Utl.doCallback(callback);
            }
            else if (switchType == CLSwitchType.switchShader)
            {
                if (render.sharedMaterial != null)
                {
                    string mName = render.sharedMaterial.name;
//					mName = mName.Replace(" (Instance)", "");
                    CLMaterialPool.returnObj(mName);
                    render.sharedMaterial = null;
                }
                setMat(render, materialNames [index], callback);
            }
        }
Example #2
0
 public void cleanMaterial()
 {
     if (switchType == CLSwitchType.switchShader)
     {
         if (render.sharedMaterial != null)
         {
                                 #if UNITY_EDITOR
             if (Application.isPlaying)
             {
                 CLMaterialPool.returnObj(render.sharedMaterial.name);
             }
                                 #else
             CLMaterialPool.returnObj(render.sharedMaterial.name);
                                 #endif
             render.sharedMaterial = null;
         }
     }
 }
Example #3
0
 public void returnMaterial()
 {
     CLMaterialPool.returnObj(materialName);
 }