Ejemplo n.º 1
0
        private void OnSceneGUI()
        {
            CanvasParticleEmitter EmitterObject = target as CanvasParticleEmitter;

            switch ((CanvasParticleEmitter.EmitterShapes)m_EmitterShape.enumValueIndex)
            {
            case CanvasParticleEmitter.EmitterShapes.Directional:
                DrawGizmoDirectional(EmitterObject);
                break;

            case CanvasParticleEmitter.EmitterShapes.Point:
                DrawGizmoPoint(EmitterObject);
                break;

            case CanvasParticleEmitter.EmitterShapes.RectEmitter:
                DrawGizmoRect(EmitterObject);
                break;

            case CanvasParticleEmitter.EmitterShapes.CircleEmitter:
                DrawGizmoCircle(EmitterObject);
                break;

            case CanvasParticleEmitter.EmitterShapes.LineEmitter:
                DrawGizmoLine(EmitterObject);
                break;

            case CanvasParticleEmitter.EmitterShapes.PointList:
                DrawGizmoPoints(EmitterObject);
                break;
            }
        }
Ejemplo n.º 2
0
        private void DrawGizmoLine(CanvasParticleEmitter EmitterObject)
        {
            Vector3 lineCenter = EmitterObject.transform.position + (new Vector3(m_EmitterLinePointA.vector2Value.x, m_EmitterLinePointA.vector2Value.y, 0) + new Vector3(m_EmitterLinePointB.vector2Value.x, m_EmitterLinePointB.vector2Value.y, 0)) / 2;

            Handles.DrawLine(new Vector3(m_EmitterLinePointA.vector2Value.x, m_EmitterLinePointA.vector2Value.y, 0) + EmitterObject.transform.position, new Vector3(m_EmitterLinePointB.vector2Value.x, m_EmitterLinePointB.vector2Value.y, 0) + EmitterObject.transform.position);
            Handles.DrawLine(lineCenter, RotatePointAroundPivot(lineCenter + new Vector3(100, 0, 0), lineCenter, new Vector3(0, 0, -m_EmitterDirection.floatValue - (m_EmitterSpread.floatValue / 2) + 90)));
            Handles.DrawLine(lineCenter, RotatePointAroundPivot(lineCenter + new Vector3(100, 0, 0), lineCenter, new Vector3(0, 0, -m_EmitterDirection.floatValue + (m_EmitterSpread.floatValue / 2) + 90)));
        }
Ejemplo n.º 3
0
 private void DrawGizmoPoints(CanvasParticleEmitter EmitterObject)
 {
     Handles.DrawLine(EmitterObject.transform.position + new Vector3(0, -1, 0), EmitterObject.transform.position + new Vector3(0, 1, 0));
     Handles.DrawLine(EmitterObject.transform.position + new Vector3(-1, 0, 0), EmitterObject.transform.position + new Vector3(1, 0, 0));
     for (int i = 0; i < m_EmitterShapePointListPoints.arraySize; i++)
     {
         Vector3 lineCenter = EmitterObject.transform.position + (new Vector3(m_EmitterShapePointListPoints.GetArrayElementAtIndex(i).vector2Value.x, m_EmitterShapePointListPoints.GetArrayElementAtIndex(i).vector2Value.y, 0));
         Handles.DrawLine(lineCenter - new Vector3(1, 0, 0), lineCenter + new Vector3(1, 0, 0));
         Handles.DrawLine(lineCenter - new Vector3(0, 1, 0), lineCenter + new Vector3(0, 1, 0));
     }
 }
Ejemplo n.º 4
0
 private void DrawGizmoRect(CanvasParticleEmitter EmitterObject)
 {
     Vector3[] rectPoints = RectPoints(m_EmitterRect.rectValue, EmitterObject.transform.position);
     Handles.DrawPolyLine(rectPoints);
     Handles.DrawLine(rectPoints [3], rectPoints [0]);
 }
Ejemplo n.º 5
0
 private void DrawGizmoCircle(CanvasParticleEmitter EmitterObject)
 {
     Vector3[] circlePoints = CirclePoints(EmitterObject.transform.position, m_EmitterCircleSegments.intValue, m_EmitterCircleRadius.floatValue).ToArray();
     Handles.DrawPolyLine(circlePoints);
     Handles.DrawLine(circlePoints [circlePoints.Length - 1], circlePoints [0]);
 }
Ejemplo n.º 6
0
 private void DrawGizmoDirectional(CanvasParticleEmitter EmitterObject)
 {
     Handles.DrawLine(EmitterObject.transform.position, RotatePointAroundPivot(EmitterObject.transform.position + new Vector3(100, 0, 0), EmitterObject.transform.position, new Vector3(0, 0, -m_EmitterDirection.floatValue - (m_EmitterSpread.floatValue / 4) + 90)));
     Handles.DrawLine(EmitterObject.transform.position, RotatePointAroundPivot(EmitterObject.transform.position + new Vector3(100, 0, 0), EmitterObject.transform.position, new Vector3(0, 0, -m_EmitterDirection.floatValue + (m_EmitterSpread.floatValue / 4) + 90)));
 }
Ejemplo n.º 7
0
 private void DrawGizmoPoint(CanvasParticleEmitter EmitterObject)
 {
     Handles.DrawLine(EmitterObject.transform.position + new Vector3(0, -1, 0), EmitterObject.transform.position + new Vector3(0, 1, 0));
     Handles.DrawLine(EmitterObject.transform.position + new Vector3(-1, 0, 0), EmitterObject.transform.position + new Vector3(1, 0, 0));
 }
Ejemplo n.º 8
0
        protected override void OnEnable()
        {
            base.OnEnable();

            m_Object = new SerializedObject(target);
            myScript = (CanvasParticleEmitter)target;

            //read only
            m_numberOfParticles = m_Object.FindProperty("m_numberOfParticles");
            m_isPlaying         = m_Object.FindProperty("m_isPlaying");
            m_isActive          = m_Object.FindProperty("m_isActive");

            //emitter base
            m_playOnAwake          = m_Object.FindProperty("m_playOnAwake");
            m_AutoKill             = m_Object.FindProperty("m_AutoKill");
            m_EmitOnce             = m_Object.FindProperty("m_EmitOnce");
            m_EmitterRate          = m_Object.FindProperty("m_EmitterRate");
            m_Duration             = m_Object.FindProperty("m_Duration");
            m_MaxParticles         = m_Object.FindProperty("m_MaxParticles");
            m_ParticlesPerEmission = m_Object.FindProperty("m_ParticlesPerEmission");


            //emitter shape
            m_EmitterShape = m_Object.FindProperty("m_EmitterShape");

            //directional emitter
            m_EmitterSpread    = m_Object.FindProperty("m_EmitterSpread");
            m_EmitterDirection = m_Object.FindProperty("m_EmitterDirection");

            //rect emitter
            m_EmitterRectType      = m_Object.FindProperty("m_EmitterShapeRectType");
            m_EmitterRect          = m_Object.FindProperty("m_EmitterShapeRect");
            m_EmitterRectTransform = m_Object.FindProperty("m_EmitterShapeRectTransform");

            //circle emitter
            m_EmitterCircleType     = m_Object.FindProperty("m_EmitterShapeCircleType");
            m_EmitterCircleRadius   = m_Object.FindProperty("m_EmitterShapeCircleRadius");
            m_EmitterCircleSegments = m_Object.FindProperty("m_EmitterShapeCircleSegments");

            //line emitter
            m_EmitterLinePointA = m_Object.FindProperty("m_EmitterShapeLinePointA");
            m_EmitterLinePointB = m_Object.FindProperty("m_EmitterShapeLinePointB");

            // point list emitter m_EmitterShapePointListPoints
            m_EmitterShapePointListPoints = m_Object.FindProperty("m_EmitterShapePointListPoints");

            //image emitter
            m_EmitterShapeImage = m_Object.FindProperty("m_EmitterShapeImage");
            //m_EmitterImagePixels = m_Object.FindProperty ("m_EmitterImagePixels");


            //forces
            m_Gravity             = m_Object.FindProperty("m_Gravity");
            m_Wave                = m_Object.FindProperty("m_Wave");
            m_WaveAmplitude       = m_Object.FindProperty("m_WaveAmplitude");
            m_Turbulence          = m_Object.FindProperty("m_Turbulence");
            m_TurbulenceAmplitude = m_Object.FindProperty("m_TurbulenceAmplitude");


            //particle size and shape
            m_particleSize          = m_Object.FindProperty("m_particleSize");
            m_particleSizeCurve     = m_Object.FindProperty("m_particleSizeCurve");
            m_ParticleSizeRandomMax = m_Object.FindProperty("m_ParticleSizeRandomMax");
            m_particleAspectRatio   = m_Object.FindProperty("m_particleAspectRatio");

            //particle behavior
            m_ParticleLife        = m_Object.FindProperty("m_ParticleLife");
            m_ParticleLifeRandMin = m_Object.FindProperty("m_ParticleLifeRandMin");
            m_ParticleLifeRandMax = m_Object.FindProperty("m_ParticleLifeRandMax");

            m_ParticleSpeed        = m_Object.FindProperty("m_ParticleSpeed");
            m_ParticleSpeedRandMin = m_Object.FindProperty("m_ParticleSpeedRandMin");
            m_ParticleSpeedRandMax = m_Object.FindProperty("m_ParticleSpeedRandMax");

            m_AlignedRotation       = m_Object.FindProperty("m_AlignedRotation");
            m_ParticleAngle         = m_Object.FindProperty("m_ParticleAngle");
            m_ParticleAngleRandMin  = m_Object.FindProperty("m_ParticleAngleRandMin");
            m_ParticleAngleRandMax  = m_Object.FindProperty("m_ParticleAngleRandMax");
            m_Stretchable           = m_Object.FindProperty("m_Stretchable");
            m_StretchableMultiplier = m_Object.FindProperty("m_StretchableMultiplier");


            m_ParticleSpinVel        = m_Object.FindProperty("m_ParticleSpinVel");
            m_ParticleSpinVelRandMin = m_Object.FindProperty("m_ParticleSpinVelRandMin");
            m_ParticleSpinVelRandMax = m_Object.FindProperty("m_ParticleSpinVelRandMax");

            //particle color and tranparency
            m_useLifeColor               = m_Object.FindProperty("m_useLifeColor");
            m_ParticleColor              = m_Object.FindProperty("m_ParticleColor");
            m_ParticleColorRamp          = m_Object.FindProperty("m_ParticleColorRamp");
            m_ParticleColorArray         = m_Object.FindProperty("m_ParticleColorArray");
            m_ParticleColorRandonR       = m_Object.FindProperty("m_ParticleColorRandonR");
            m_ParticleColorRandonG       = m_Object.FindProperty("m_ParticleColorRandonG");
            m_ParticleColorRandonB       = m_Object.FindProperty("m_ParticleColorRandonB");
            m_particleAlpha              = m_Object.FindProperty("m_ParticleAlpha");
            m_particleAlphaCurve         = m_Object.FindProperty("m_particleAlphaCurve");
            m_TextureArray               = m_Object.FindProperty("m_TextureArray");
            m_TextureAnimable            = m_Object.FindProperty("m_isAnimated");
            m_TextureFrameRate           = m_Object.FindProperty("m_ParticleFrameRate");
            m_TextureRandomStartFrame    = m_Object.FindProperty("m_isRandomStartFrame");
            m_particleTextureAspectRatio = m_Object.FindProperty("m_particleTextureAspectRatio");
            m_NumOfTextures              = m_Object.FindProperty(ARRAY_SIZE);
            //m_ParticleColliders = m_Object.FindProperty("m_ParticleColliders");
            m_Material = m_Object.FindProperty("m_Material");

            //editor update
            m_playOnEditor      = m_Object.FindProperty("m_playOnEditor");
            m_playWhenSelected  = m_Object.FindProperty("m_playWhenSelected");
            m_isPlayingOnEditor = m_Object.FindProperty("m_isPlayingOnEditor");
            m_updateTargetIndex = m_Object.FindProperty("m_updateTargetIndex");


            if (m_TextureArray.arraySize > 1)
            {
                myScript.CreateTextureAtlas();
            }

            if (!Application.isPlaying)
            {
                if (m_playOnEditor.boolValue == false)
                {
                    RemoveUpdateTarget(m_updateTargetIndex.intValue);
                    m_isPlayingOnEditor.boolValue = false;
                    m_playWhenSelected.boolValue  = false;
                }

                if (m_playOnEditor.boolValue == true && m_playWhenSelected.boolValue == true)
                {
                    AddUpdateTarget(m_updateTargetIndex.intValue);
                    m_isPlayingOnEditor.boolValue = true;
                }
            }
        }