Example #1
0
 internal void Stop()
 {
     ParticleSystemEditorUtils.playbackIsScrubbing = false;
     ParticleSystemEditorUtils.playbackTime        = 0.0F;
     ParticleSystemEffectUtils.StopEffect();
     m_Owner.Repaint();
 }
Example #2
0
        void Update()
        {
            if (m_CheckObjectIndex >= 0)
            {
                // Wait until the ObjectSelector is closed before checking object
                if (!ObjectSelector.isVisible)
                {
                    SerializedProperty subEmitterData = m_SubEmitters.GetArrayElementAtIndex(m_CheckObjectIndex);
                    SerializedProperty subEmitter     = subEmitterData.FindPropertyRelative("emitter");
                    Object             obj            = subEmitter.objectReferenceValue;
                    ParticleSystem     newSubEmitter  = obj as ParticleSystem;
                    if (newSubEmitter != null)
                    {
                        bool validSubemitter = true;

                        if (ValidateSubemitter(newSubEmitter))
                        {
                            string errorMsg = ParticleSystemEffectUtils.CheckCircularReferences(newSubEmitter);
                            if (errorMsg.Length == 0)
                            {
                                // Ok there is no circular references, now check if its a child
                                if (!CheckIfChild(obj))
                                {
                                    validSubemitter = false;
                                }
                            }
                            else
                            {
                                // Circular references detected
                                string circularRefErrorMsg = string.Format("'{0}' could not be assigned as subemitter on '{1}' due to circular referencing!\nBacktrace: {2} \n\nReference will be removed.", newSubEmitter.gameObject.name, m_ParticleSystemUI.m_ParticleSystems[0].gameObject.name, errorMsg);
                                EditorUtility.DisplayDialog("Circular References Detected", circularRefErrorMsg, "Ok");
                                validSubemitter = false;
                            }
                        }
                        else
                        {
                            validSubemitter = false;
                        }

                        if (!validSubemitter)
                        {
                            subEmitter.objectReferenceValue = m_PreviousSubEmitter; // revert invalid reference
                            m_ParticleSystemUI.ApplyProperties();
                            m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint();
                        }
                    }

                    // Cleanup
                    m_CheckObjectIndex        = -1;
                    m_PreviousSubEmitter      = null;
                    EditorApplication.update -= Update;
                }
            }
        }
Example #3
0
 private void Update()
 {
     if (this.m_CheckObjectIndex >= 0)
     {
         if (!ObjectSelector.isVisible)
         {
             SerializedProperty arrayElementAtIndex  = this.m_SubEmitters.GetArrayElementAtIndex(this.m_CheckObjectIndex);
             SerializedProperty serializedProperty   = arrayElementAtIndex.FindPropertyRelative("emitter");
             UnityEngine.Object objectReferenceValue = serializedProperty.objectReferenceValue;
             ParticleSystem     particleSystem       = objectReferenceValue as ParticleSystem;
             if (particleSystem != null)
             {
                 bool flag = true;
                 if (this.ValidateSubemitter(particleSystem))
                 {
                     string text = ParticleSystemEffectUtils.CheckCircularReferences(particleSystem);
                     if (text.Length == 0)
                     {
                         if (!this.CheckIfChild(objectReferenceValue))
                         {
                             flag = false;
                         }
                     }
                     else
                     {
                         string message = string.Format("'{0}' could not be assigned as subemitter on '{1}' due to circular referencing!\nBacktrace: {2} \n\nReference will be removed.", particleSystem.gameObject.name, this.m_ParticleSystemUI.m_ParticleSystems[0].gameObject.name, text);
                         EditorUtility.DisplayDialog("Circular References Detected", message, "Ok");
                         flag = false;
                     }
                 }
                 else
                 {
                     flag = false;
                 }
                 if (!flag)
                 {
                     serializedProperty.objectReferenceValue = null;
                     this.m_ParticleSystemUI.ApplyProperties();
                     this.m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint();
                 }
             }
             this.m_CheckObjectIndex  = -1;
             EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(this.Update));
         }
     }
 }