Beispiel #1
0
        //note this function also modified MeshList.
        MeshFilter CreateMeshObj(Material mat)
        {
            GameObject obj = new GameObject("xftmesh " + mat.name);

            obj.layer = gameObject.layer;
            MeshList.Add(obj);
            obj.AddComponent <MeshFilter>();
            obj.AddComponent <MeshRenderer>();
            SetActive(obj, true);

#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                XffectComponent.SetActive(obj, true);
            }
#endif

            MeshFilter   Meshfilter;
            MeshRenderer Meshrenderer;
            Meshfilter                  = (MeshFilter)obj.GetComponent(typeof(MeshFilter));
            Meshrenderer                = (MeshRenderer)obj.GetComponent(typeof(MeshRenderer));
            Meshrenderer.castShadows    = false;
            Meshrenderer.receiveShadows = false;
            Meshrenderer.GetComponent <Renderer>().sharedMaterial = mat;
            Meshfilter.sharedMesh = new Mesh();
            return(Meshfilter);
        }
        public XffectComponent AddXffect(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;

            newobj.parent = transform;
            XffectComponent.SetActive(newobj.gameObject, false);

            newobj.gameObject.name = baseobj.gameObject.name;

            XffectComponent xft = newobj.GetComponent <XffectComponent>();

            EffectDic[name].Add(xft);
            if (xft != null)
            {
                xft.Initialize();
            }
            return(xft);
        }
Beispiel #3
0
 public override void OnBegin()
 {
     base.OnBegin();
     if (m_owner.LightComp != null)
     {
         XffectComponent.SetActive(m_owner.LightComp.gameObject, true);
     }
 }
Beispiel #4
0
 public override void Reset()
 {
     base.Reset();
     if (m_owner.LightComp == null)
     {
         return;
     }
     XffectComponent.SetActive(m_owner.LightComp.gameObject, false);
 }
Beispiel #5
0
 public override void Initialize()
 {
     if (m_owner.LightComp == null)
     {
         Debug.LogWarning("you should assign a light source to Light Event to use it!");
         return;
     }
     m_elapsedTime = 0f;
     XffectComponent.SetActive(m_owner.LightComp.gameObject, false);
 }
Beispiel #6
0
 public override void Reset()
 {
     if (m_owner.LightComp == null)
     {
         return;
     }
     XffectComponent.SetActive(m_owner.LightComp.gameObject, false);
     m_elapsedTime = 0f;
     m_editorFlag  = false;
 }
Beispiel #7
0
        public override void Update(float deltaTime)
        {
            if (m_editorFlag)
            {
                return;
            }
            if (m_owner.LightComp == null)
            {
                return;
            }

            m_elapsedTime += deltaTime;

            if (m_elapsedTime > m_owner.EndTime)
            {
                XffectComponent.SetActive(m_owner.LightComp.gameObject, false);
                return;
            }

            if (m_elapsedTime > m_owner.StartTime)
            {
                XffectComponent.SetActive(m_owner.LightComp.gameObject, true);
                float intensity = 0f;
                if (m_owner.LightIntensityType == MAGTYPE.Curve && m_owner.LightIntensityCurve != null)
                {
                    intensity = m_owner.LightIntensityCurve.Evaluate(m_elapsedTime - m_owner.StartTime);
                }
                else
                {
                    intensity = m_owner.LightIntensity;
                }
                m_owner.LightComp.intensity = intensity;

                float range = 0f;
                if (m_owner.LightRangeType == MAGTYPE.Curve && m_owner.LightRangeCurve != null)
                {
                    range = m_owner.LightRangeCurve.Evaluate(m_elapsedTime - m_owner.StartTime);
                }
                else
                {
                    range = m_owner.LightRange;
                }
                m_owner.LightComp.range = range;
            }
        }
Beispiel #8
0
        //note this function also modified MeshList.
        MeshFilter CreateMeshObj(Material mat)
        {
            GameObject obj = new GameObject("xftmesh " + mat.name);

            obj.layer = gameObject.layer;
            MeshList.Add(obj);
            obj.AddComponent <MeshFilter>();
            obj.AddComponent <MeshRenderer>();
            SetActive(obj, true);



#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                XffectComponent.SetActive(obj, true);
                //obj.hideFlags = HideFlags.HideAndDontSave;
                EditorUtility.SetSelectedWireframeHidden(obj.GetComponent <Renderer>(), true);
            }
#endif

            MeshFilter   Meshfilter;
            MeshRenderer Meshrenderer;
            Meshfilter                  = (MeshFilter)obj.GetComponent(typeof(MeshFilter));
            Meshrenderer                = (MeshRenderer)obj.GetComponent(typeof(MeshRenderer));
            Meshrenderer.castShadows    = false;
            Meshrenderer.receiveShadows = false;
            Meshrenderer.GetComponent <Renderer>().sharedMaterial = mat;

            if (UseWith2DSprite)
            {
                Meshrenderer.sortingLayerName = SortingLayerName;
                Meshrenderer.sortingOrder     = SortingOrder;
            }

            Meshfilter.sharedMesh = new Mesh();
            return(Meshfilter);
        }