public void AddRefSpe(GameObject go)
    {
        SpecialEffect newSpe = go.GetComponent <SpecialEffect>();

        if (newSpe == null)
        {
            return;
        }

        if (PrefabUtility.GetPrefabType(go) != PrefabType.Prefab)
        {
            EditorUtility.DisplayDialog("警告!", "请使用来自Prefab的特效作为参考特效!", "确定");
            return;
        }

        GameObject speInst = PrefabUtility.InstantiatePrefab(go) as GameObject;

        newSpe = speInst.GetComponent <SpecialEffect>();


        SpecialEffect test = GameObject.Instantiate(newSpe) as SpecialEffect;

        SpecialEffectEditProxy newSpeProxy = new SpecialEffectEditProxy(test, null, false);

        refSpeMgr.Add(newSpeProxy);
        NotifyEditTargetChange();
        NotifyRefSpeListChange();

        GameObject.DestroyImmediate(speInst);
    }
    public void UnExecute()
    {
        if (!SpecialEffectEditorModel.GetInstance().HasEditTarget())
        {
            return;
        }
        SpecialEffectEditProxy spe = SpecialEffectEditorModel.GetInstance().GetEditTarget();

        int indx = 0;

        foreach (var item in oldTimeLineItems)
        {
            //int itemIndx = indices[i];
            //spe.SetItemTimeInfo(itemIndx, item.startTime, item.length);
            //spe.SetItemTimeInfo(item.BlindSpeItem, item.RealTimeLineItem.startTime, item.RealTimeLineItem.length);
            if (indices[indx].side == TimeLineViewCtrl.SIDE_LEFT)
            {
                spe.SetItemStartTime(item.BlindSpeItem, item.RealTimeLineItem.startTime);
            }
            else if (indices[indx].side == TimeLineViewCtrl.SIDE_RIGHT)
            {
                spe.SetItemPlayTime(item.BlindSpeItem, item.RealTimeLineItem.length);
            }
            else if (indices[indx].side == TimeLineViewCtrl.SIDE_MID)
            {
                spe.SetItemDelayTime(item.BlindSpeItem, item.RealTimeLineItem.startTime);
            }
            indx++;
        }


        SpecialEffectEditorModel.GetInstance().NotifyEditTargetValueChange();
        //值变动时刷新Inspector
        SpecialEffectEditorModel.GetInstance().NotifySelectItemChanged();
    }
    /*
     * 待编辑特效相关函数
     */

    //设置编辑目标特效
    public bool SetEditTarget(GameObject go)
    {
        SpecialEffect newSpe = go.GetComponent <SpecialEffect>();

        if (newSpe == null)
        {
            return(false);
        }

        RetargetSpeToOldTarget();

        Object prefab = null;

        //若打开特效为Prefab
        if (PrefabUtility.GetPrefabType(go) == PrefabType.Prefab)
        {
            //GameObject speInst = PrefabUtility.InstantiatePrefab(go) as GameObject;
            GameObject speInst = GameObject.Instantiate(go) as GameObject;
            prefab = go;
            newSpe = speInst.GetComponent <SpecialEffect>();
        }

        targetSpe = new SpecialEffectEditProxy(newSpe, prefab, true);
        targetSpe.ShowSpecialEffectInspector();

        NotifyEditTargetChange();
        return(true);
    }
    public void ShowSelectRefSpeInspector(int i)
    {
        SpecialEffectEditProxy refSpe = refSpeMgr.GetAt(i);

        if (refSpe != null)
        {
            refSpe.ShowSpecialEffectInspector();
        }
    }
    /*
     * 预览特效相关函数
     */
    public void SetRefSpeStartTime(int i, float t)
    {
        SpecialEffectEditProxy refSpe = refSpeMgr.GetAt(i);

        if (refSpe != null)
        {
            refSpe.StartTime = t;
        }
    }
    public bool GetRefSpeName(int i, ref string n)
    {
        SpecialEffectEditProxy refSpe = refSpeMgr.GetAt(i);

        if (refSpe != null)
        {
            n = refSpe.Name;
            return(true);
        }
        return(false);
    }
    public bool GetRefSpeLength(int i, ref float len)
    {
        SpecialEffectEditProxy refSpe = refSpeMgr.GetAt(i);

        if (refSpe != null)
        {
            len = refSpe.TotalTime;
            return(true);
        }
        return(false);
    }
    public bool GetRefSpeStartTime(int i, ref float t)
    {
        SpecialEffectEditProxy refSpe = refSpeMgr.GetAt(i);

        if (refSpe != null)
        {
            t = refSpe.StartTime;
            return(true);
        }
        return(false);
    }
Пример #9
0
 public void Set(SpecialEffectEditProxy e, SpecialEffectElement elem)
 {
     for (int index = 0; index < e.RealSpe.elems.Count; index++)
     {
         if (UnityEngine.Object.ReferenceEquals(e.RealSpe.elems[index], elem))
         {
             Set(e, index);
             break;
         }
     }
 }
Пример #10
0
    public void RetargetSpeToOldTarget()
    {
        if (targetSpe == null)
        {
            return;
        }


        targetSpe.Destroy();
        targetSpe = null;

        NotifyEditTargetChange();
    }
Пример #11
0
    public void Set(SpecialEffectEditProxy e, int sel)
    {
        if (e == null)
        {
            selectItem = -1;
            return;
        }

        selectItem = sel;
        e.GetItemName(sel, ref name);
        e.GetItemTimeInfo(sel, ref startTime, ref length);
        e.GetItemStateInfo(sel, ref isLoop);
        e.GetItemDelayTime(sel, ref delayTime);
    }
Пример #12
0
 public void Set(SpecialEffectEditProxy spe)
 {
     if (spe == null)
     {
         Reset();
         return;
     }
     name           = spe.Name;
     bindTargetPath = spe.BindingTargetPath;
     totalTime      = spe.TotalTime;
     elemNum        = spe.GetItemCount();
     playStyle      = spe.Style;
     playOnAwake    = spe.PlayOnAwake;
     supportPhysics = spe.SupportPhysics;
 }
Пример #13
0
 public void Add(SpecialEffectEditProxy spe)
 {
     refSpeList.Add(spe);
 }