Esempio n. 1
0
    //此函数将一个特效属性值与子元素属性值拷贝给自身。
    //此函数只允许编辑器调用,外界不许调用
    //前置条件:脚本所挂接的gameObject除特效之外的其他属性必需相等
    public bool _CopyValues(SpecialEffect o)
    {
#if UNITY_EDITOR
        if (o == null)
        {
            return(false);
        }

        if (o == this)
        {
            return(true);
        }

        if (GetType() != o.GetType())
        {
            return(false);
        }

        if (elems.Count != o.elems.Count)
        {
            return(false);
        }

        //检查底下的元素类型是否完全一样
        for (int i = 0; i < elems.Count; i++)
        {
            if (elems[i].GetType() != o.elems[i].GetType())
            {
                return(false);
            }
        }

        totalTime  = o.totalTime;
        style      = o.style;
        speedScale = o.speedScale;

        playOnAwake       = o.playOnAwake;
        bindingTargetPath = o.bindingTargetPath;

        for (int i = 0; i < elems.Count; i++)
        {
            if (!elems[i]._CopyValues(o.elems[i]))
            {//此种情况禁止出现
                Debug.LogError("注意!" + "子元素拷贝失败!出现不同步的特效!拷贝操作从\"" + o.gameObject.name + "\"到\"" + gameObject.name + "\"");
                return(false);
            }
        }

        return(true);
#else
        //客户端版,此函数永远运行失败
        return(false);
#endif
    }