예제 #1
0
파일: Effect.cs 프로젝트: 37Sir/WarChess
 /// <summary>
 /// 播放特效
 /// </summary>
 /// <param name="refObject"></param>
 /// <param name="offset">偏移量</param>
 /// <param name="scale">缩放</param>
 /// <param name="rotation">旋转角度</param>
 /// <param name="playbackSpeed">播放速率</param>
 /// <param name="layer">层</param>
 /// <param name="attribute">属性</param>
 public void Play(GameObject refObject, Vector3 offset, float scale, Quaternion rotation, Quaternion localRotation, float playbackSpeed, int layer, EffectPack.Attribute attribute)
 {
     m_refObject = refObject;
     m_attribute = attribute;
     if (EffectObject)
     {
         if (layer >= 0)
         {
             SetLayer(layer);
         }
         AttachAnchor(offset);
         EffectObject.SetActive(true);
         StartParticle();
         SetScale(scale);
         SetEffectRotation(rotation);
         SetEffectLocalRotation(localRotation);
         SetPlaybackSpeed(playbackSpeed);
     }
 }
예제 #2
0
    /// <summary>
    /// 绘制attribute面板
    /// </summary>
    /// <param name="attribute"></param>
    private void DrawEffectAttribute(EffectPack.Attribute attribute)
    {
        int anchorIndex = EffectConfig.Instance.Anchors.IndexOf(attribute.Anchor);

        if (anchorIndex < 0)
        {
            anchorIndex    = EffectConfig.Instance.Anchors.Count - 1;
            _effectAnchors = EffectConfig.Instance.Anchors.ToArray();
        }

        attribute.Anchor           = _effectAnchors[EditorGUILayout.Popup("Anchor", anchorIndex, _effectAnchors)];
        attribute.DelayTime        = EditorGUILayout.FloatField("Delay Time", attribute.DelayTime);
        attribute.IsAttach         = EditorGUILayout.Toggle("Is Attach", attribute.IsAttach);
        GUI.enabled                = attribute.IsAttach;
        attribute.IsFixedTranslate = EditorGUILayout.Toggle("Is Fixed Translate", attribute.IsFixedTranslate);
        GUI.enabled                = (attribute.IsAttach && !attribute.IsFixedTranslate);
        attribute.IsFixedRotation  = EditorGUILayout.Toggle("Is Fixed Rotation", attribute.IsFixedRotation);
        GUI.enabled                = true;
        attribute.IsFixedScale     = EditorGUILayout.Toggle("Is Fixed Scale", attribute.IsFixedScale);
        attribute.Offset           = EditorGUILayout.Vector3Field("Offset", attribute.Offset);
    }
예제 #3
0
파일: Effect.cs 프로젝트: 37Sir/WarChess
 /// <summary>
 /// 重置
 /// </summary>
 public virtual void Reset()
 {
     m_refObject    = null;
     m_anchorObject = null;
     m_attribute    = null;
     if (m_particleSystems != null)
     {
         for (int i = 0; i < m_particleSystems.Length; ++i)
         {
             if (m_particleSystems[i])
             {
                 m_particleSystems[i].time = 0.0f;
                 m_particleSystems[i].Clear();
             }
         }
         m_particleSystems = null;
     }
     m_scaleChange = 1.0f;
     m_speedChange = 1.0f;
     m_anchor      = null;
     EffectObject  = null;
 }
예제 #4
0
    /// <summary>
    /// 绘制attribute的列表
    /// </summary>
    /// <param name="targets"></param>
    private void DrawEffectList(UnityEngine.Object[] targets)
    {
        EffectPack effectPack = targets[0] as EffectPack;

        for (int i = 0; i < effectPack.Attributes.Count;)
        {
            bool isEqual = true;

            for (int j = 1; j < targets.Length; ++j)
            {
                if (!effectPack.Attributes[i].Equals((targets[j] as EffectPack).Attributes[i]))
                {
                    isEqual = false;
                    break;
                }
            }

            if (isEqual)
            {
                m_attribute.Copy(effectPack.Attributes[i]);

                string header = ((m_attribute.EffectName != null) ? m_attribute.EffectName : string.Empty);

                if (LayoutUtility.Foldout(header))
                {
                    LayoutUtility.BeginContents();

                    if (GUILayout.Button("", "ToggleMixed", GUILayout.Width(20f)))
                    {
                        UnityEditor.Undo.RecordObjects(targets, "Remove Effect Attribute");
                        for (int j = 0; j < targets.Length; ++j)
                        {
                            (targets[j] as EffectPack).Attributes.RemoveAt(i);
                            EditorUtility.SetDirty(targets[j]);
                        }
                    }
                    else
                    {
                        DrawEffectAttribute(m_attribute);
                        if (!m_attribute.Equals(effectPack.Attributes[i]))
                        {
                            UnityEditor.Undo.RecordObjects(targets, "Modify Effect Attribute");
                            for (int j = 0; j < targets.Length; ++j)
                            {
                                (targets[j] as EffectPack).Attributes[i].Copy(m_attribute);
                                EditorUtility.SetDirty(targets[j]);
                            }
                        }
                    }
                    LayoutUtility.EndContents();
                }
            }
            ++i;
        }

        // 绘制加入新的Effect的选项
        if (LayoutUtility.Foldout("Add Effect Attribute"))
        {
            LayoutUtility.BeginContents();
            string effectName = LayoutUtility.PrefabFiled("Effect", null);
            if (effectName != null)
            {
                UnityEditor.Undo.RecordObjects(targets, "Add Effect Attribute");

                for (int j = 0; j < targets.Length; ++j)
                {
                    EffectPack.Attribute attribute = new EffectPack.Attribute();
                    attribute.EffectName = effectName;
                    attribute.EffectPath = Config.EffectsRoot + "/" + effectName;
                    (targets[j] as EffectPack).Attributes.Add(attribute);
                    EditorUtility.SetDirty(targets[j]);
                }
            }
            LayoutUtility.EndContents();
        }
    }