示例#1
0
    public override void OnInspectorGUI()
    {
        Xffect ctarget = (Xffect)target;

        EditorGUILayout.BeginVertical();

        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        LayerName = EditorGUILayout.TextField("name:", LayerName);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        ctarget.LifeTime = EditorGUILayout.FloatField("life:", ctarget.LifeTime);
        if (GUILayout.Button("Add Layer"))
        {
            GameObject layer = new GameObject(LayerName);
            layer.AddComponent("EffectLayer");
            layer.transform.parent = Selection.activeTransform;
        }
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
示例#2
0
    private void Awake()
    {
        IEnumerator enumerator = base.transform.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                Transform current = (Transform)enumerator.Current;
                this.ObjectDic[current.name] = new ArrayList();
                this.ObjectDic[current.name].Add(current);
                Xffect component = current.GetComponent <Xffect>();
                if (component != null)
                {
                    component.Initialize();
                }
                current.gameObject.SetActive(false);
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
    }
示例#3
0
 private void Awake()
 {
     foreach (Transform transform in base.transform)
     {
         this.ObjectDic[transform.name] = new ArrayList();
         this.ObjectDic[transform.name].Add(transform);
         Xffect component = transform.GetComponent <Xffect>();
         if (component != null)
         {
             component.Initialize();
         }
         transform.gameObject.SetActive(false);
     }
 }
示例#4
0
 void Awake()
 {
     foreach (Transform child in transform)
     {
         ObjectDic[child.name] = new ArrayList();
         ObjectDic[child.name].Add(child);
         Xffect xft = child.GetComponent <Xffect>();
         //make sure all child is init.
         if (xft != null)
         {
             xft.Initialize();
         }
         child.gameObject.active = false;
     }
 }
示例#5
0
 private void OnEffect(string eftname)
 {
     if (eftname == "lightning")
     {
         for (int i = 0; i < 9; i++)
         {
             Xffect  component = EffectCache.GetObject(eftname).GetComponent <Xffect>();
             Vector3 zero      = Vector3.zero;
             zero.x = Random.Range(-2.2f, 2.3f);
             zero.z = Random.Range(-2.1f, 2.1f);
             component.SetEmitPosition(zero);
             component.Active();
         }
     }
     else if (eftname == "cyclone")
     {
         Xffect component = EffectCache.GetObject(eftname).GetComponent <Xffect>();
         component.SetDirectionAxis(GetFaceDirection().normalized);
         component.Active();
     }
     else if (eftname == "crystal")
     {
         Xffect component = EffectCache.GetObject("crystal_surround").GetComponent <Xffect>();
         component.Active();
         component = EffectCache.GetObject("crystal").GetComponent <Xffect>();
         component.SetEmitPosition(new Vector3(0f, 1.9f, 1.4f));
         component.Active();
         component = EffectCache.GetObject("crystal_lightn").GetComponent <Xffect>();
         component.SetDirectionAxis(new Vector3(-1.5f, 1.8f, 0f));
         component.Active();
         component = EffectCache.GetObject("crystal").GetComponent <Xffect>();
         component.SetEmitPosition(new Vector3(0f, 1.5f, -1.2f));
         component.Active();
         component = EffectCache.GetObject("crystal_lightn").GetComponent <Xffect>();
         component.SetDirectionAxis(new Vector3(1.4f, 1.4f, 0f));
         component.Active();
     }
     else
     {
         Xffect component = EffectCache.GetObject(eftname).GetComponent <Xffect>();
         component.Active();
     }
 }
示例#6
0
    protected Transform AddObject(string name)
    {
        Transform original = base.transform.Find(name);

        if (original == null)
        {
            Debug.Log("object:" + name + "doesn't exist!");
            return(null);
        }
        Transform transform2 = UnityEngine.Object.Instantiate(original, Vector3.zero, Quaternion.identity) as Transform;

        this.ObjectDic[name].Add(transform2);
        transform2.gameObject.SetActive(false);
        Xffect component = transform2.GetComponent <Xffect>();

        if (component != null)
        {
            component.Initialize();
        }
        return(transform2);
    }
示例#7
0
    //默认active为 false,应该由调用方active.
    protected Transform AddObject(string name)
    {
        Transform baseobj = transform.Find(name);

        if (baseobj == null)
        {
            Debug.Log("object:" + name + "doesn't exist!");
            return(null);
        }
        Transform newobj = Instantiate(baseobj, Vector3.zero, Quaternion.identity) as Transform;

        ObjectDic[name].Add(newobj);
        newobj.gameObject.active = false;
        Xffect xft = newobj.GetComponent <Xffect>();

        if (xft != null)
        {
            xft.Initialize();
        }
        return(newobj);
    }