private WarnPrefab ( Object target, string title, string warning, string okButton ) : bool | ||
target | Object | |
title | string | |
warning | string | |
okButton | string | |
return | bool |
private bool CheckIfChild(Object subEmitter) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(m_ParticleSystemUI.m_ParticleSystems[0]); ParticleSystem ps = subEmitter as ParticleSystem; if (IsChild(ps, root)) { return(true); } if (PrefabUtility.IsPartOfAnyPrefab(ps.gameObject) && !PrefabUtility.IsAnyPrefabInstanceRoot(ps.gameObject)) { string kPrefabReparentWarn = $"The assigned sub emitter is not part of the current effect because it is not a child of the current root Particle System GameObject: '{root.gameObject.name}'. The Particle System cannot be moved because it is a child of a Prefab instance."; EditorUtility.WarnPrefab(ps.gameObject, "Reparent GameObjects", kPrefabReparentWarn, "OK"); return(false); } string kReparentText = string.Format("The assigned sub emitter is not a child of the current root particle system GameObject: '{0}' and is therefore NOT considered a part of the current effect. Do you want to reparent it?", root.gameObject.name); if (EditorUtility.DisplayDialog( "Reparent GameObjects", kReparentText, "Yes, Reparent", "No, Remove")) { if (EditorUtility.IsPersistent(subEmitter)) { var newGo = Object.Instantiate(subEmitter) as GameObject; if (newGo != null) { newGo.transform.parent = m_ParticleSystemUI.m_ParticleSystems[0].transform; newGo.transform.localPosition = Vector3.zero; newGo.transform.localRotation = Quaternion.identity; } } else { if (ps != null) { Undo.SetTransformParent(ps.gameObject.transform.transform, m_ParticleSystemUI.m_ParticleSystems[0].transform, "Reparent sub emitter"); } } return(true); } else if (ps != null) { // Clear sub-emitters that have been deselected, to avoid having their particles left paused in the Scene View (case 946999) ps.Clear(true); } return(false); }