public override void OnInspectorGUI()
        {
            serializedObject.Update();
            SpriteTrail TrailSettingsScript = target as SpriteTrail;

            EditorGUILayout.PropertyField(m_TrailName);
            GUILayout.Space(15);

            EditorGUILayout.PropertyField(m_CurrentTrailPreset);
            if (TrailSettingsScript.m_CurrentTrailPreset == null)
            {
                EditorGUILayout.HelpBox(
                    "You need to assign a preset (Current trail preset).\n You can create one, or use one of the preset In the folder : \nSpriteTrail/PREFAB/TRAIL_PRESETS",
                    MessageType.Warning,
                    true);
                GUILayout.Space(15);
            }

            EditorGUILayout.PropertyField(m_HideTrailOnDisabled);

            //GUILayout.Space(15);
            EditorGUILayout.PropertyField(m_TrailActivationCondition);
            switch (TrailSettingsScript.m_TrailActivationCondition)
            {
            case TrailActivationCondition.AlwaysEnabled:
                break;

            case TrailActivationCondition.Manual:
                break;

            case TrailActivationCondition.VelocityMagnitude:
                EditorGUILayout.PropertyField(m_VelocityNeededToStart);
                EditorGUILayout.PropertyField(m_StartIfUnderVelocity);
                EditorGUILayout.PropertyField(m_VelocityStartIsLocalSpace);
                GUILayout.Space(15);
                break;
            }


            EditorGUILayout.PropertyField(m_TrailDeactivationCondition);
            switch (TrailSettingsScript.m_TrailDeactivationCondition)
            {
            case TrailDeactivationCondition.Manual:
                break;

            case TrailDeactivationCondition.Time:
                EditorGUILayout.PropertyField(m_TrailActivationDuration);
                GUILayout.Space(15);
                break;

            case TrailDeactivationCondition.VelocityMagnitude:
                EditorGUILayout.PropertyField(m_VelocityNeededToStop);
                EditorGUILayout.PropertyField(m_StopIfOverVelocity);
                EditorGUILayout.PropertyField(m_VelocityStopIsLocalSpace);
                GUILayout.Space(15);
                break;
            }



            EditorGUILayout.PropertyField(m_TrailParent);
            EditorGUILayout.PropertyField(m_SpriteToDuplicate);
            EditorGUILayout.PropertyField(m_Layer);
            EditorGUILayout.PropertyField(m_ZMoveStep);
            EditorGUILayout.PropertyField(m_ZMoveMax);
            EditorGUILayout.PropertyField(m_SortingLayerID, new GUIContent("Sorting Layer", m_OrderInSortingLayer.tooltip));
            EditorGUILayout.PropertyField(m_OrderInSortingLayer, new GUIContent("Order in Layer", m_OrderInSortingLayer.tooltip));

            serializedObject.ApplyModifiedProperties();
        }
示例#2
0
        public void Initialise(SpriteTrail trail)
        {
            m_NeedDequeue       = false;
            m_TrailPos          = -1;
            m_NeedLateUpdate    = false;
            m_TimeSinceCreation = 0;
            m_MotherTrail       = trail;
            this.m_myGameObject.SetActive(true);
            m_TrailSettings = trail.m_CurrentTrailPreset;
            if (SpriteRenderer == null)
            {
                SpriteRenderer = GetComponent <SpriteRenderer>();
            }
            if (m_TrailSettings.m_SpecialMat != null)
            {
                SpriteRenderer.material = m_TrailSettings.m_SpecialMat;
            }
            else
            {
                SpriteRenderer.material = trail.m_SpriteToDuplicate.material;
            }
            SpriteRenderer.color          = trail.m_SpriteToDuplicate.color;
            SpriteRenderer.sortingLayerID = trail.m_SortingLayerID;
            SpriteRenderer.sortingOrder   = trail.m_OrderInSortingLayer;
            SpriteRenderer.sprite         = trail.m_SpriteToDuplicate.sprite;
            SpriteRenderer.flipX          = trail.m_SpriteToDuplicate.flipX;
            SpriteRenderer.flipY          = trail.m_SpriteToDuplicate.flipY;
            m_InitSize = m_Transform.localScale;
            m_InitPos  = m_Transform.localPosition;
            m_Init     = true;
            trail.m_ElementsInTrail.Enqueue(this);


            ApplyFrameEffect();

            if (m_TrailSettings.m_TrailElementDurationCondition == TrailElementDurationCondition.ElementCount)
            {
                if (m_TrailSettings.m_TrailMaxLength > 0)
                {
                    while (trail.m_ElementsInTrail.Count > m_TrailSettings.m_TrailMaxLength)
                    {
                        trail.m_ElementsInTrail.Dequeue().Hide();
                    }
                }
                else
                {
                    while (trail.m_ElementsInTrail.Count > 0)
                    {
                        trail.m_ElementsInTrail.Dequeue().Hide();
                    }
                }


                int _cnt = 0;
                foreach (TrailElement _elem in trail.m_ElementsInTrail)
                {
                    _elem.m_TrailPos       = trail.m_ElementsInTrail.Count - _cnt;
                    _elem.m_NeedLateUpdate = true;
                    _cnt++;
                }
            }
        }