public static void RenderManipulatorProperty (ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty) { if (thisManipulatorProperty == null) thisManipulatorProperty = new ManipulatorPropertyC(); EditorGUILayout.Separator(); thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup("Property Type", thisManipulatorProperty.type); // Velocity if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.AdditiveVelocity) { thisManipulatorProperty.velocity = EditorGUILayout.Vector3Field("Particle Velocity", thisManipulatorProperty.velocity); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Velocity Strength", thisManipulatorProperty.strength); thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle("Local Rotation", thisManipulatorProperty.useLocalRotation); } else // Color if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Color) { thisManipulatorProperty.color = EditorGUILayout.ColorField("Particle Color", thisManipulatorProperty.color); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange); thisManipulatorProperty.keepColorAlphas = EditorGUILayout.Toggle("Keep Color Alphas", thisManipulatorProperty.keepColorAlphas); } else // Size if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Size) { thisManipulatorProperty.size = EditorGUILayout.FloatField("Particle Size", thisManipulatorProperty.size); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Size Strength", thisManipulatorProperty.strength); } else // Target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Target) { // Target List bool hasNull = false; EditorGUILayout.BeginVertical(boxStyle); targetsFoldout = GUILayout.Toggle(targetsFoldout, "Targets ("+thisManipulatorProperty.targets.Count+")", EditorStyles.foldout); if (targetsFoldout) { if (thisManipulatorProperty.targets.Count>0) { for (int t = 0; t<thisManipulatorProperty.targets.Count; t++) { EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26)); EditorGUILayout.BeginHorizontal(); GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18)); thisManipulatorProperty.targets[t] = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t], typeof(Transform), true) as Transform; if (!thisManipulatorProperty.targets[t]) hasNull = true; EditorGUILayout.Separator(); if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){ thisManipulatorProperty.targets.RemoveAt(t); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } else { EditorGUILayout.HelpBox("No targets created.", MessageType.Info); } if (hasNull) EditorGUILayout.HelpBox("All targets must be assigned.", MessageType.Warning); if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){ thisManipulatorProperty.targets.Add(thisManipulator.transform); } EditorGUILayout.Separator(); } EditorGUILayout.EndVertical(); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Target Strength", thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle("Only Position In Range", thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider("Zero Velocity Strength", thisManipulatorProperty.zeroVelocityStrength, 0, playgroundScriptReference.maximumAllowedManipulatorZeroVelocity); } else // Death if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Death) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Death Strength", thisManipulatorProperty.strength); } else // Attractor if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Attractor) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Attractor Strength", thisManipulatorProperty.strength); } else // Gravitational if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Gravitational) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Gravitational Strength", thisManipulatorProperty.strength); } else // Repellent if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Repellent) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Repellent Strength", thisManipulatorProperty.strength); } else // Lifetime Color if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.LifetimeColor) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent("Lifetime Color")); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange); } EditorGUILayout.Separator(); if (thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.None && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Attractor && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Gravitational && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Repellent ) thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup("Transition", thisManipulatorProperty.transition); }
public static void RenderManipulatorProperty (ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty) { if (thisManipulatorProperty == null) thisManipulatorProperty = new ManipulatorPropertyC(); thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup(playgroundLanguage.propertyType, thisManipulatorProperty.type); bool guiEnabled = GUI.enabled; EditorGUILayout.Separator(); // Velocity if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.AdditiveVelocity) { thisManipulatorProperty.velocity = EditorGUILayout.Vector3Field(playgroundLanguage.particleVelocity, thisManipulatorProperty.velocity); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.velocityStrength, thisManipulatorProperty.strength); thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle(playgroundLanguage.localRotation, thisManipulatorProperty.useLocalRotation); } else // Color if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Color) { thisManipulatorProperty.color = EditorGUILayout.ColorField(playgroundLanguage.particleColor, thisManipulatorProperty.color); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange); thisManipulatorProperty.keepColorAlphas = EditorGUILayout.Toggle(playgroundLanguage.keepColorAlphas, thisManipulatorProperty.keepColorAlphas); } else // Size if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Size) { thisManipulatorProperty.size = EditorGUILayout.FloatField(playgroundLanguage.particleSize, thisManipulatorProperty.size); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.sizeStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlySizeInRange = EditorGUILayout.Toggle(playgroundLanguage.onlySizeInRange, thisManipulatorProperty.onlySizeInRange); } else // Target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Target) { // Target List bool hasNull = false; EditorGUILayout.BeginVertical(boxStyle); playgroundSettings.manipulatorTargetsFoldout = GUILayout.Toggle(playgroundSettings.manipulatorTargetsFoldout, playgroundLanguage.targets+" ("+thisManipulatorProperty.targets.Count+")", EditorStyles.foldout); if (playgroundSettings.manipulatorTargetsFoldout) { if (thisManipulatorProperty.targets.Count>0) { for (int t = 0; t<thisManipulatorProperty.targets.Count; t++) { EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26)); EditorGUILayout.BeginHorizontal(); GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18)); thisManipulatorProperty.targets[t].transform = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t].transform, typeof(Transform), true) as Transform; if (!thisManipulatorProperty.targets[t].available) hasNull = true; EditorGUILayout.Separator(); if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){ thisManipulatorProperty.targets.RemoveAt(t); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } else { EditorGUILayout.HelpBox(playgroundLanguage.noTargets, MessageType.Info); } if (hasNull) EditorGUILayout.HelpBox(playgroundLanguage.allTargets, MessageType.Warning); if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){ PlaygroundTransformC newPlaygroundTransform = new PlaygroundTransformC(); newPlaygroundTransform.transform = thisManipulator.transform.transform; newPlaygroundTransform.Update (); thisManipulatorProperty.targets.Add(newPlaygroundTransform); } EditorGUILayout.Separator(); } EditorGUILayout.EndVertical(); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } else // Death if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Death) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.deathStrength, thisManipulatorProperty.strength); } else // Attractor if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Attractor) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.attractorStrength, thisManipulatorProperty.strength); } else // Gravitational if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Gravitational) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.gravitationalStrength, thisManipulatorProperty.strength); } else // Repellent if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Repellent) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.repellentStrength, thisManipulatorProperty.strength); } else // Vortex if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Vortex) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.vortexStrength, thisManipulatorProperty.strength); } else // Turbulence if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Turbulence) { thisManipulatorProperty.turbulenceType = (TURBULENCETYPE)EditorGUILayout.EnumPopup (playgroundLanguage.turbulenceType, thisManipulatorProperty.turbulenceType); EditorGUI.indentLevel++; thisManipulatorProperty.strength = EditorGUILayout.Slider(playgroundLanguage.strength, thisManipulatorProperty.strength, 0f, playgroundSettings.maximumAllowedTurbulenceStrength); thisManipulatorProperty.turbulenceScale = EditorGUILayout.Slider(playgroundLanguage.scale, thisManipulatorProperty.turbulenceScale, 0f, playgroundSettings.maximumAllowedTurbulenceScale); thisManipulatorProperty.turbulenceTimeScale = EditorGUILayout.Slider(playgroundLanguage.timeScale, thisManipulatorProperty.turbulenceTimeScale, 0f, playgroundSettings.maximumAllowedTurbulenceTimeScale); EditorGUILayout.BeginHorizontal(); thisManipulatorProperty.turbulenceApplyLifetimeStrength = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeStrength, thisManipulatorProperty.turbulenceApplyLifetimeStrength, GUILayout.Width (140)); GUILayout.FlexibleSpace(); GUI.enabled = (thisManipulatorProperty.turbulenceApplyLifetimeStrength && thisManipulatorProperty.turbulenceType!=TURBULENCETYPE.None); serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue = EditorGUILayout.CurveField(serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue); GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } else // Lifetime Color if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.LifetimeColor) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent(playgroundLanguage.lifetimeColor)); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange); } else // Mesh target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.MeshTarget) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.meshTarget)); GUILayout.BeginVertical(boxStyle); EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent( playgroundLanguage.meshVerticesUpdate, playgroundLanguage.meshVerticesUpdateDescription )); GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue; EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("updateNormals"), new GUIContent( playgroundLanguage.meshNormalsUpdate, playgroundLanguage.meshNormalsUpdateDescription )); GUI.enabled = guiEnabled; GUILayout.EndVertical(); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting)); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } else // Skinned mesh target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.SkinnedMeshTarget) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.skinnedMeshTarget)); GUILayout.BeginVertical(boxStyle); EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent( playgroundLanguage.meshVerticesUpdate, playgroundLanguage.meshVerticesUpdateDescription )); GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue; EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("updateNormals"), new GUIContent( playgroundLanguage.meshNormalsUpdate, playgroundLanguage.meshNormalsUpdateDescription )); GUI.enabled = guiEnabled; GUILayout.EndVertical(); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting)); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } else // State target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.StateTarget) { if (thisManipulatorProperty.stateTarget.stateTransform==null) thisManipulatorProperty.stateTarget.stateTransform = thisManipulator.transform.transform; GUILayout.BeginVertical(boxStyle); Texture2D currentStateTexture = thisManipulatorProperty.stateTarget.stateTexture; Mesh currentStateMesh = thisManipulatorProperty.stateTarget.stateMesh; EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateTransform"), new GUIContent(playgroundLanguage.transform)); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateMesh"), new GUIContent(playgroundLanguage.mesh)); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateTexture"), new GUIContent(playgroundLanguage.texture)); if (currentStateTexture!=thisManipulatorProperty.stateTarget.stateTexture || currentStateMesh!=thisManipulatorProperty.stateTarget.stateMesh) thisManipulatorProperty.stateTarget.Initialize(); if (thisManipulatorProperty.stateTarget.stateTexture!=null) EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateDepthmap"), new GUIContent(playgroundLanguage.depthmap)); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateScale"), new GUIContent(playgroundLanguage.scale, playgroundLanguage.stateScaleDescription)); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateOffset"), new GUIContent(playgroundLanguage.offset, playgroundLanguage.stateOffsetDescription)); if (thisManipulatorProperty.stateTarget.stateMesh==null) { GUILayout.BeginHorizontal(); bool currentApplyChromaKey = thisManipulatorProperty.stateTarget.applyChromaKey; thisManipulatorProperty.stateTarget.applyChromaKey = EditorGUILayout.Toggle (playgroundLanguage.chromaKey, thisManipulatorProperty.stateTarget.applyChromaKey); GUI.enabled = guiEnabled&&thisManipulatorProperty.stateTarget.applyChromaKey; EditorGUIUtility.labelWidth = 1f; Color currentChroma = new Color(thisManipulatorProperty.stateTarget.chromaKey.r,thisManipulatorProperty.stateTarget.chromaKey.g, thisManipulatorProperty.stateTarget.chromaKey.b); thisManipulatorProperty.stateTarget.chromaKey = (Color32)EditorGUILayout.ColorField((Color)thisManipulatorProperty.stateTarget.chromaKey); EditorGUIUtility.labelWidth = 50f; float currentSpread = thisManipulatorProperty.stateTarget.chromaKeySpread; thisManipulatorProperty.stateTarget.chromaKeySpread = EditorGUILayout.Slider(playgroundLanguage.spread, thisManipulatorProperty.stateTarget.chromaKeySpread, 0, 1f); if (currentChroma!=new Color(thisManipulatorProperty.stateTarget.chromaKey.r,thisManipulatorProperty.stateTarget.chromaKey.g, thisManipulatorProperty.stateTarget.chromaKey.b) || currentSpread!=thisManipulatorProperty.stateTarget.chromaKeySpread || currentApplyChromaKey!=thisManipulatorProperty.stateTarget.applyChromaKey) thisManipulatorProperty.stateTarget.Initialize(); GUI.enabled = guiEnabled; EditorGUIUtility.labelWidth = 0; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); if(GUILayout.Button(playgroundLanguage.refresh, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){ thisManipulatorProperty.stateTarget.Initialize(); } EditorGUILayout.Separator(); EditorGUIUtility.labelWidth = 40f; EditorGUILayout.PrefixLabel(playgroundLanguage.points+":"); EditorGUIUtility.labelWidth = 0; EditorGUILayout.SelectableLabel(thisManipulatorProperty.stateTarget.positionLength.ToString(), GUILayout.MaxWidth(80)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting)); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } else // Spline target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.SplineTarget) { EditorGUILayout.BeginVertical(boxStyle); thisManipulatorProperty.splineTarget = (PlaygroundSpline)EditorGUILayout.ObjectField(playgroundLanguage.spline, thisManipulatorProperty.splineTarget, typeof(PlaygroundSpline), true); if (thisManipulatorProperty.splineTarget==null) EditorGUILayout.HelpBox(playgroundLanguage.newSplineMessage, MessageType.Info); else thisManipulatorProperty.splineTimeOffset = EditorGUILayout.Slider (playgroundLanguage.timeOffset, thisManipulatorProperty.splineTimeOffset, 0, 1f); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button (playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { PlaygroundSpline spline = PlaygroundC.CreateSpline(thisManipulatorProperty); spline.transform.parent = Selection.activeTransform; Selection.activeGameObject = thisManipulatorProperty.splineTarget.gameObject; } GUI.enabled = thisManipulatorProperty.splineTarget!=null; if (GUILayout.Button (playgroundLanguage.edit, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) Selection.activeGameObject = thisManipulatorProperty.splineTarget.gameObject; GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); thisManipulatorProperty.splineTargetMethod = (SPLINETARGETMETHOD)EditorGUILayout.EnumPopup(playgroundLanguage.targetMethod, thisManipulatorProperty.splineTargetMethod); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } else if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Math) { thisManipulatorProperty.mathProperty.property = (MATHMANIPULATORPROPERTY)EditorGUILayout.EnumPopup(playgroundLanguage.particleProperty, thisManipulatorProperty.mathProperty.property); thisManipulatorProperty.mathProperty.type = (MATHMANIPULATORTYPE)EditorGUILayout.EnumPopup(playgroundLanguage.type, thisManipulatorProperty.mathProperty.type); thisManipulatorProperty.mathProperty.clamp = (MATHMANIPULATORCLAMP)EditorGUILayout.EnumPopup(playgroundLanguage.clamp, thisManipulatorProperty.mathProperty.clamp); if (thisManipulatorProperty.mathProperty.clamp!=MATHMANIPULATORCLAMP.None) { EditorGUI.indentLevel++; thisManipulatorProperty.mathProperty.clampFloor = EditorGUILayout.FloatField(playgroundLanguage.floor, thisManipulatorProperty.mathProperty.clampFloor); thisManipulatorProperty.mathProperty.clampCeil = EditorGUILayout.FloatField(playgroundLanguage.ceil, thisManipulatorProperty.mathProperty.clampCeil); EditorGUI.indentLevel--; } if (thisManipulatorProperty.mathProperty.property == MATHMANIPULATORPROPERTY.Rotation || thisManipulatorProperty.mathProperty.property == MATHMANIPULATORPROPERTY.Size) { thisManipulatorProperty.mathProperty.value = EditorGUILayout.FloatField(playgroundLanguage.value, thisManipulatorProperty.mathProperty.value); thisManipulatorProperty.mathProperty.rate = EditorGUILayout.FloatField(playgroundLanguage.rate, thisManipulatorProperty.mathProperty.rate); } else { thisManipulatorProperty.mathProperty.value3 = EditorGUILayout.Vector3Field(playgroundLanguage.value, thisManipulatorProperty.mathProperty.value3); thisManipulatorProperty.mathProperty.rate3 = EditorGUILayout.Vector3Field(playgroundLanguage.rate, thisManipulatorProperty.mathProperty.rate3); } } EditorGUILayout.Separator(); if (thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.None && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Attractor && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Gravitational && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Repellent && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Vortex && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Turbulence && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Math ) { GUI.enabled = guiEnabled&&thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.AdditiveVelocity; thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup(playgroundLanguage.transition, thisManipulatorProperty.transition); GUI.enabled = guiEnabled; } }
public override void OnInspectorGUI() { if (boxStyle == null) { boxStyle = GUI.skin.FindStyle("box"); } EditorGUILayout.BeginVertical(boxStyle); playgroundSettings.playgroundSplineFoldout = GUILayout.Toggle(playgroundSettings.playgroundSplineFoldout, playgroundLanguage.playgroundSpline, EditorStyles.foldout); if (playgroundSettings.playgroundSplineFoldout) { selectedNode = (selectedIndex + 1) / 3; selectedBezier = selectedIndex < 3?0:(((selectedIndex) % 3)) % 2; selectedIndexIsNode = selectedIndex == 0 || selectedIndex % 3 == 0; EditorGUILayout.Separator(); bool currentLoop = spline.Loop; GUI.enabled = spline.NodeCount > 1; bool loop = EditorGUILayout.Toggle(playgroundLanguage.loop, spline.Loop); GUI.enabled = true; spline.reverse = EditorGUILayout.Toggle(playgroundLanguage.reverse, spline.reverse); spline.timeOffset = EditorGUILayout.Slider(playgroundLanguage.timeOffset, spline.timeOffset, 0, 1f); spline.positionOffset = EditorGUILayout.Vector3Field(playgroundLanguage.positionOffset, spline.positionOffset); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(boxStyle); if (selectedIndex < spline.ControlPointCount) { DrawSelectedPointInspector(); } if (currentLoop != loop) { Undo.RecordObject(spline, "Toggle Loop"); EditorUtility.SetDirty(spline); spline.Loop = loop; } EditorGUILayout.EndVertical(); // List of nodes if (GUILayout.Button(playgroundLanguage.nodes + " (" + (spline.NodeCount + 1) + ")", EditorStyles.toolbarDropDown)) { playgroundSettings.nodesFoldout = !playgroundSettings.nodesFoldout; } if (playgroundSettings.nodesFoldout) { EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26)); for (int i = 0; i <= spline.NodeCount; i++) { if (i == selectedNode && selectedIndex > -1) { GUI.backgroundColor = new Color(1f, 1f, .2f); } EditorGUILayout.BeginVertical(boxStyle); GUI.backgroundColor = Color.white; EditorGUILayout.BeginHorizontal(); // Node if (i == selectedNode && selectedIndexIsNode) { EditorGUILayout.LabelField("", EditorStyles.foldout, GUILayout.Width(14)); } else if (i == selectedNode && selectedIndex != -1) { GUILayout.Space(19f); } if (GUILayout.Button(playgroundLanguage.node + " " + i + " (" + spline.GetControlPointMode(i * 3).ToString() + ")", EditorStyles.label, GUILayout.MaxWidth(130))) { selectedIndex = SelectIndex(i * 3); } GUILayout.Space(3f); if (GUILayout.Button(spline.transformNodes[i * 3].enabled?playgroundLanguage.transform:playgroundLanguage.vector3, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { spline.transformNodes[i * 3].enabled = !spline.transformNodes[i * 3].enabled; } EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 1f; Vector3 point; if (spline.transformNodes[i * 3].enabled) { spline.transformNodes[i * 3].transform = (Transform)EditorGUILayout.ObjectField(spline.transformNodes[i * 3].transform, typeof(Transform), true); if (spline.transformNodes[i * 3].IsAvailable()) { point = spline.transformNodes[i * 3].GetPosition(); } else { point = spline.GetControlPoint(i * 3); } } else { point = EditorGUILayout.Vector3Field(" ", spline.GetControlPoint(i * 3)); } EditorGUIUtility.labelWidth = 0; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.SetControlPoint(i * 3, point); } if (GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { Undo.RecordObject(spline, "Swap spline node"); spline.SwapNodes(i, i > 0? i - 1 : spline.NodeCount); EditorUtility.SetDirty(spline); } if (GUILayout.Button(playgroundLanguage.downSymbol, EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { Undo.RecordObject(spline, "Swap spline node"); spline.SwapNodes(i, i < spline.NodeCount? i + 1 : 0); EditorUtility.SetDirty(spline); } EditorGUI.BeginChangeCheck(); if (GUILayout.Button("+", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { Undo.RecordObject(spline, "Add Node"); spline.AddNode(i); EditorUtility.SetDirty(spline); selectedIndex = SelectIndex((i + 1) * 3); } GUI.enabled = (!spline.Loop && spline.NodeCount > 1 || spline.Loop && spline.NodeCount > 2); EditorGUI.BeginChangeCheck(); if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { Undo.RecordObject(spline, "Remove Node"); spline.RemoveNode(i); EditorUtility.SetDirty(spline); selectedIndex -= 3; if (selectedIndex < 0) { selectedIndex = SelectIndex(0); } return; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (i == selectedNode && selectedIndex > -1) { int thisBez; // Bezier 0 if (selectedNode > 0) { thisBez = selectedNode > 0?(i * 3) - 1:(spline.NodeCount * 3) - 1; EditorGUILayout.BeginHorizontal(); if (selectedBezier == 0 && !selectedIndexIsNode) { EditorGUILayout.LabelField("", EditorStyles.foldout, GUILayout.Width(14)); } else { GUILayout.Space(19f); } if (GUILayout.Button(playgroundLanguage.bezier + " 0", EditorStyles.label, GUILayout.MaxWidth(133))) { selectedIndex = SelectIndex(thisBez); } EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 1f; if (GUILayout.Button(spline.transformNodes[thisBez].enabled?playgroundLanguage.transform:playgroundLanguage.vector3, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { spline.transformNodes[thisBez].enabled = !spline.transformNodes[thisBez].enabled; } if (spline.transformNodes[thisBez].enabled) { spline.transformNodes[thisBez].transform = (Transform)EditorGUILayout.ObjectField(spline.transformNodes[thisBez].transform, typeof(Transform), true); if (spline.transformNodes[thisBez].IsAvailable()) { point = spline.transformNodes[thisBez].GetPosition(); } else { point = spline.GetControlPoint(thisBez); } } else { point = EditorGUILayout.Vector3Field(" ", spline.GetControlPoint(thisBez)); } GUILayout.Space(35f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.SetControlPoint(selectedNode > 0?(i * 3) - 1:(spline.NodeCount * 3) - 1, point); } EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = 0; } // Bezier 1 if (selectedNode < spline.NodeCount) { thisBez = selectedNode < spline.NodeCount?(i * 3) + 1:1; EditorGUILayout.BeginHorizontal(); if ((selectedIndex == 1 || selectedBezier == 1) && !selectedIndexIsNode) { EditorGUILayout.LabelField("", EditorStyles.foldout, GUILayout.Width(14)); } else { GUILayout.Space(19f); } if (GUILayout.Button(selectedNode > 0?playgroundLanguage.bezier + " 1":playgroundLanguage.bezier + " 0", EditorStyles.label, GUILayout.MaxWidth(133))) { selectedIndex = SelectIndex(thisBez); } EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 1f; if (GUILayout.Button(spline.transformNodes[thisBez].enabled?playgroundLanguage.transform:playgroundLanguage.vector3, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { spline.transformNodes[thisBez].enabled = !spline.transformNodes[thisBez].enabled; } if (spline.transformNodes[thisBez].enabled) { spline.transformNodes[thisBez].transform = (Transform)EditorGUILayout.ObjectField(spline.transformNodes[thisBez].transform, typeof(Transform), true); if (spline.transformNodes[thisBez].IsAvailable()) { point = spline.transformNodes[thisBez].GetPosition(); } else { point = spline.GetControlPoint(thisBez); } } else { point = EditorGUILayout.Vector3Field(" ", spline.GetControlPoint(thisBez)); } GUILayout.Space(35f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.SetControlPoint(thisBez, point); } EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = 0; } } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { Undo.RecordObject(spline, "Add Node"); selectedNode = spline.NodeCount; spline.AddNode(selectedNode); EditorUtility.SetDirty(spline); selectedIndex = SelectIndex((selectedNode + 1) * 3); } EditorGUILayout.Separator(); if (GUILayout.Button(playgroundLanguage.convertAllToTransforms, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { Transform pTrans = new GameObject("Nodes").transform; pTrans.parent = spline.splineTransform; pTrans.localPosition = Vector3.zero; Transform[] transforms = spline.ExportToTransforms(); spline.positionOffset = Vector3.zero; for (int i = 0; i < transforms.Length; i++) { spline.transformNodes[i].transform = transforms[i]; spline.transformNodes[i].enabled = true; if (transforms[i].parent == spline.splineTransform) { transforms[i].parent = pTrans; } } Selection.activeTransform = pTrans; } if (GUILayout.Button(playgroundLanguage.convertAllToVector3, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { spline.SetPoints(spline.ExportToVector3()); spline.positionOffset = Vector3.zero; for (int i = 0; i < spline.ControlPointCount; i++) { spline.transformNodes[i].enabled = false; } } EditorGUILayout.Separator(); if (GUILayout.Button(playgroundLanguage.reverseAllNodes, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { spline.ReverseAllNodes(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } // List of users if (GUILayout.Button(playgroundLanguage.usedBy + " (" + spline.usedBy.Count + ")", EditorStyles.toolbarDropDown)) { playgroundSettings.usedByFoldout = !playgroundSettings.usedByFoldout; } if (playgroundSettings.usedByFoldout) { EditorGUILayout.Separator(); if (spline.usedBy.Count > 0) { EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26)); for (int i = 0; i < spline.usedBy.Count; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(spline.usedBy[i].name, EditorStyles.label)) { Selection.activeTransform = spline.usedBy[i]; } EditorGUILayout.Separator(); if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { if (EditorUtility.DisplayDialog(playgroundLanguage.removeUserTitle, playgroundLanguage.removeUserMessage, playgroundLanguage.yes, playgroundLanguage.no)) { PlaygroundParticlesC ps = spline.usedBy[i].GetComponent <PlaygroundParticlesC>(); Undo.RecordObjects(new Object[] { spline, ps }, "Remove User"); if (ps != null) { Transform user = spline.usedBy[i]; if (ps.splines.Contains(spline)) { spline.RemoveUser(user); ps.splines.Remove(spline); } foreach (ManipulatorObjectC m in ps.manipulators) { ManipulatorPropertyC mp = m.property; if (mp.splineTarget != null && mp.splineTarget == spline) { spline.RemoveUser(user); } foreach (ManipulatorPropertyC mps in m.properties) { if (mps.splineTarget != null && mps.splineTarget == spline) { spline.RemoveUser(user); } } } } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } else { EditorGUILayout.HelpBox(playgroundLanguage.noSplineUserMessage, MessageType.Info); } } // Advanced if (GUILayout.Button(playgroundLanguage.advanced, EditorStyles.toolbarDropDown)) { playgroundSettings.splineAdvancedFoldout = !playgroundSettings.splineAdvancedFoldout; } if (playgroundSettings.splineAdvancedFoldout) { EditorGUILayout.Separator(); spline.fixedVelocityOnNewNode = EditorGUILayout.FloatField(playgroundLanguage.velocityOnNewNode, spline.fixedVelocityOnNewNode); spline.moveTransformsAsBeziers = EditorGUILayout.Toggle(playgroundLanguage.moveTransformsAsBeziers, spline.moveTransformsAsBeziers); spline.exportWithNodeStructure = EditorGUILayout.Toggle(playgroundLanguage.exportWithNodeStructure, spline.exportWithNodeStructure); EditorGUILayout.Separator(); spline.drawGizmo = EditorGUILayout.Toggle(playgroundLanguage.drawBezierGizmo, spline.drawGizmo); spline.bezierWidth = EditorGUILayout.FloatField(playgroundLanguage.bezierWidth, spline.bezierWidth); if (spline.bezierWidth < 0) { spline.bezierWidth = 0; } } } EditorGUILayout.EndVertical(); SceneView.RepaintAll(); }
public static void RenderManipulatorProperty(ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty) { if (thisManipulatorProperty == null) { thisManipulatorProperty = new ManipulatorPropertyC(); } EditorGUILayout.Separator(); thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup("Property Type", thisManipulatorProperty.type); // Velocity if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.AdditiveVelocity) { thisManipulatorProperty.velocity = EditorGUILayout.Vector3Field("Particle Velocity", thisManipulatorProperty.velocity); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Velocity Strength", thisManipulatorProperty.strength); thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle("Local Rotation", thisManipulatorProperty.useLocalRotation); } else // Color if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Color) { thisManipulatorProperty.color = EditorGUILayout.ColorField("Particle Color", thisManipulatorProperty.color); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange); thisManipulatorProperty.keepColorAlphas = EditorGUILayout.Toggle("Keep Color Alphas", thisManipulatorProperty.keepColorAlphas); } else // Size if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Size) { thisManipulatorProperty.size = EditorGUILayout.FloatField("Particle Size", thisManipulatorProperty.size); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Size Strength", thisManipulatorProperty.strength); } else // Target if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Target) { // Target List bool hasNull = false; EditorGUILayout.BeginVertical(boxStyle); targetsFoldout = GUILayout.Toggle(targetsFoldout, "Targets (" + thisManipulatorProperty.targets.Count + ")", EditorStyles.foldout); if (targetsFoldout) { if (thisManipulatorProperty.targets.Count > 0) { for (int t = 0; t < thisManipulatorProperty.targets.Count; t++) { EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26)); EditorGUILayout.BeginHorizontal(); GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18)); thisManipulatorProperty.targets[t] = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t], typeof(Transform), true) as Transform; if (!thisManipulatorProperty.targets[t]) { hasNull = true; } EditorGUILayout.Separator(); if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { thisManipulatorProperty.targets.RemoveAt(t); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } else { EditorGUILayout.HelpBox("No targets created.", MessageType.Info); } if (hasNull) { EditorGUILayout.HelpBox("All targets must be assigned.", MessageType.Warning); } if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) { thisManipulatorProperty.targets.Add(thisManipulator.transform); } EditorGUILayout.Separator(); } EditorGUILayout.EndVertical(); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Target Strength", thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle("Only Position In Range", thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider("Zero Velocity Strength", thisManipulatorProperty.zeroVelocityStrength, 0, playgroundScriptReference.maximumAllowedManipulatorZeroVelocity); } else // Death if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Death) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Death Strength", thisManipulatorProperty.strength); } else // Attractor if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Attractor) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Attractor Strength", thisManipulatorProperty.strength); } else // Gravitational if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Gravitational) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Gravitational Strength", thisManipulatorProperty.strength); } else // Repellent if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Repellent) { thisManipulatorProperty.strength = EditorGUILayout.FloatField("Repellent Strength", thisManipulatorProperty.strength); } else // Lifetime Color if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.LifetimeColor) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent("Lifetime Color")); thisManipulatorProperty.strength = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange); } EditorGUILayout.Separator(); if (thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.None && thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.Attractor && thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.Gravitational && thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.Repellent ) { thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup("Transition", thisManipulatorProperty.transition); } }
public static void RenderManipulatorProperty(ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty) { if (thisManipulatorProperty == null) thisManipulatorProperty = new ManipulatorPropertyC(); thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup(playgroundLanguage.propertyType, thisManipulatorProperty.type); bool guiEnabled = GUI.enabled; EditorGUILayout.Separator(); // Velocity if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.AdditiveVelocity) { thisManipulatorProperty.velocity = EditorGUILayout.Vector3Field(playgroundLanguage.particleVelocity, thisManipulatorProperty.velocity); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.velocityStrength, thisManipulatorProperty.strength); thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle(playgroundLanguage.localRotation, thisManipulatorProperty.useLocalRotation); } else // Color if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Color) { thisManipulatorProperty.color = EditorGUILayout.ColorField(playgroundLanguage.particleColor, thisManipulatorProperty.color); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange); thisManipulatorProperty.keepColorAlphas = EditorGUILayout.Toggle(playgroundLanguage.keepColorAlphas, thisManipulatorProperty.keepColorAlphas); } else // Size if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Size) { thisManipulatorProperty.size = EditorGUILayout.FloatField(playgroundLanguage.particleSize, thisManipulatorProperty.size); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.sizeStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlySizeInRange = EditorGUILayout.Toggle(playgroundLanguage.onlySizeInRange, thisManipulatorProperty.onlySizeInRange); } else // Target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Target) { // Target List bool hasNull = false; EditorGUILayout.BeginVertical(boxStyle); playgroundSettings.manipulatorTargetsFoldout = GUILayout.Toggle(playgroundSettings.manipulatorTargetsFoldout, playgroundLanguage.targets+" ("+thisManipulatorProperty.targets.Count+")", EditorStyles.foldout); if (playgroundSettings.manipulatorTargetsFoldout) { if (thisManipulatorProperty.targets.Count>0) { for (int t = 0; t<thisManipulatorProperty.targets.Count; t++) { EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26)); EditorGUILayout.BeginHorizontal(); GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18)); thisManipulatorProperty.targets[t].transform = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t].transform, typeof(Transform), true) as Transform; if (!thisManipulatorProperty.targets[t].available) hasNull = true; EditorGUILayout.Separator(); if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){ thisManipulatorProperty.targets.RemoveAt(t); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } else { EditorGUILayout.HelpBox(playgroundLanguage.noTargets, MessageType.Info); } if (hasNull) EditorGUILayout.HelpBox(playgroundLanguage.allTargets, MessageType.Warning); if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){ PlaygroundTransformC newPlaygroundTransform = new PlaygroundTransformC(); newPlaygroundTransform.transform = thisManipulator.transform.transform; newPlaygroundTransform.Update (); thisManipulatorProperty.targets.Add(newPlaygroundTransform); } EditorGUILayout.Separator(); } EditorGUILayout.EndVertical(); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } else // Death if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Death) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.deathStrength, thisManipulatorProperty.strength); } else // Attractor if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Attractor) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.attractorStrength, thisManipulatorProperty.strength); } else // Gravitational if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Gravitational) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.gravitationalStrength, thisManipulatorProperty.strength); } else // Repellent if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Repellent) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.repellentStrength, thisManipulatorProperty.strength); } else // Vortex if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Vortex) { thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.vortexStrength, thisManipulatorProperty.strength); } else // Turbulence if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Turbulence) { thisManipulatorProperty.turbulenceType = (TURBULENCETYPE)EditorGUILayout.EnumPopup (playgroundLanguage.turbulenceType, thisManipulatorProperty.turbulenceType); EditorGUI.indentLevel++; thisManipulatorProperty.strength = EditorGUILayout.Slider(playgroundLanguage.strength, thisManipulatorProperty.strength, 0f, playgroundSettings.maximumAllowedTurbulenceStrength); thisManipulatorProperty.turbulenceScale = EditorGUILayout.Slider(playgroundLanguage.scale, thisManipulatorProperty.turbulenceScale, 0f, playgroundSettings.maximumAllowedTurbulenceScale); thisManipulatorProperty.turbulenceTimeScale = EditorGUILayout.Slider(playgroundLanguage.timeScale, thisManipulatorProperty.turbulenceTimeScale, 0f, playgroundSettings.maximumAllowedTurbulenceTimeScale); EditorGUILayout.BeginHorizontal(); thisManipulatorProperty.turbulenceApplyLifetimeStrength = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeStrength, thisManipulatorProperty.turbulenceApplyLifetimeStrength, GUILayout.Width (140)); GUILayout.FlexibleSpace(); GUI.enabled = (thisManipulatorProperty.turbulenceApplyLifetimeStrength && thisManipulatorProperty.turbulenceType!=TURBULENCETYPE.None); serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue = EditorGUILayout.CurveField(serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue); GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } else // Lifetime Color if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.LifetimeColor) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent(playgroundLanguage.lifetimeColor)); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange); } else // Mesh target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.MeshTarget) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.meshTarget)); GUILayout.BeginVertical(boxStyle); EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent( playgroundLanguage.meshVerticesUpdate, playgroundLanguage.meshVerticesUpdateDescription )); GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue; EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("updateNormals"), new GUIContent( playgroundLanguage.meshNormalsUpdate, playgroundLanguage.meshNormalsUpdateDescription )); GUI.enabled = guiEnabled; GUILayout.EndVertical(); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting)); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } else // Skinned mesh target if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.SkinnedMeshTarget) { EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.skinnedMeshTarget)); GUILayout.BeginVertical(boxStyle); EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent( playgroundLanguage.meshVerticesUpdate, playgroundLanguage.meshVerticesUpdateDescription )); GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue; EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("updateNormals"), new GUIContent( playgroundLanguage.meshNormalsUpdate, playgroundLanguage.meshNormalsUpdateDescription )); GUI.enabled = guiEnabled; GUILayout.EndVertical(); EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting)); thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength); thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange); thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity); } EditorGUILayout.Separator(); if (thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.None && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Attractor && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Gravitational && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Repellent && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Vortex && thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Turbulence ) thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup(playgroundLanguage.transition, thisManipulatorProperty.transition); }
// Calculate the effect from manipulator properties public static void PropertyManipulator (PlaygroundParticlesC playgroundParticles, ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, ref int p, ref float t, ref Vector3 particlePosition, ref Vector3 manipulatorPosition, ref bool localSpace) { if (thisManipulator.Contains(particlePosition, manipulatorPosition)) { switch (thisManipulatorProperty.type) { // Velocity Property case MANIPULATORPROPERTYTYPEC.Velocity: if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) playgroundParticles.playgroundCache.velocity[p] = thisManipulatorProperty.useLocalRotation? thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity)-manipulatorPosition : thisManipulatorProperty.velocity; else playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], thisManipulatorProperty.useLocalRotation? thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity)-manipulatorPosition : thisManipulatorProperty.velocity, t*thisManipulatorProperty.strength*thisManipulator.strength); break; // Additive Velocity Property case MANIPULATORPROPERTYTYPEC.AdditiveVelocity: if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) playgroundParticles.playgroundCache.velocity[p] += thisManipulatorProperty.useLocalRotation? thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity*(t*thisManipulatorProperty.strength*thisManipulator.strength))-manipulatorPosition : thisManipulatorProperty.velocity*(t*thisManipulatorProperty.strength*thisManipulator.strength); else playgroundParticles.playgroundCache.velocity[p] += Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], thisManipulatorProperty.useLocalRotation? thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity)-manipulatorPosition : thisManipulatorProperty.velocity, t*thisManipulatorProperty.strength*thisManipulator.strength)*(t*thisManipulatorProperty.strength*thisManipulator.strength); break; // Color Property case MANIPULATORPROPERTYTYPEC.Color: Color staticColor; if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) { if (thisManipulatorProperty.keepColorAlphas) { staticColor = thisManipulatorProperty.color; staticColor.a = Mathf.Clamp(playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime).a, 0, staticColor.a); playgroundParticles.particleCache.particles[p].color = staticColor; } else playgroundParticles.particleCache.particles[p].color = thisManipulatorProperty.color; } else { if (thisManipulatorProperty.keepColorAlphas) { staticColor = thisManipulatorProperty.color; staticColor.a = Mathf.Clamp(playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime).a, 0, staticColor.a); playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, staticColor, t*thisManipulatorProperty.strength*thisManipulator.strength); } else playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, thisManipulatorProperty.color, t*thisManipulatorProperty.strength*thisManipulator.strength); playgroundParticles.playgroundCache.changedByPropertyColorLerp[p] = true; } // Only color in range of manipulator boundaries if (!thisManipulatorProperty.onlyColorInRange) playgroundParticles.playgroundCache.changedByPropertyColor[p] = true; // Keep alpha of original color if (thisManipulatorProperty.keepColorAlphas) playgroundParticles.playgroundCache.changedByPropertyColorKeepAlpha[p] = true; // Set color pairing key else if (playgroundParticles.playgroundCache.propertyColorId[p] != thisManipulator.transform.GetInstanceID()) { playgroundParticles.playgroundCache.propertyColorId[p] = thisManipulator.transform.GetInstanceID(); } break; // Lifetime Color Property case MANIPULATORPROPERTYTYPEC.LifetimeColor: if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) { playgroundParticles.particleCache.particles[p].color = thisManipulatorProperty.lifetimeColor.Evaluate(playgroundParticles.lifetime>0?playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime:0); } else { playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, thisManipulatorProperty.lifetimeColor.Evaluate(playgroundParticles.lifetime>0?playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime:0), t*thisManipulatorProperty.strength*thisManipulator.strength); playgroundParticles.playgroundCache.changedByPropertyColorLerp[p] = true; } // Only color in range of manipulator boundaries if (!thisManipulatorProperty.onlyColorInRange) playgroundParticles.playgroundCache.changedByPropertyColor[p] = true; // Set color pairing key else if (playgroundParticles.playgroundCache.propertyColorId[p] != thisManipulator.transform.GetInstanceID()) { playgroundParticles.playgroundCache.propertyColorId[p] = thisManipulator.transform.GetInstanceID(); } break; // Size Property case MANIPULATORPROPERTYTYPEC.Size: if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) playgroundParticles.particleCache.particles[p].size = thisManipulatorProperty.size; else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Lerp) playgroundParticles.particleCache.particles[p].size = Mathf.Lerp(playgroundParticles.particleCache.particles[p].size, thisManipulatorProperty.size, t*thisManipulatorProperty.strength*thisManipulator.strength); else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Linear) playgroundParticles.particleCache.particles[p].size = Mathf.MoveTowards(playgroundParticles.particleCache.particles[p].size, thisManipulatorProperty.size, t*thisManipulatorProperty.strength*thisManipulator.strength); playgroundParticles.playgroundCache.changedByPropertySize[p] = true; break; // Target Property case MANIPULATORPROPERTYTYPEC.Target: if (thisManipulatorProperty.targets.Count>0 && thisManipulatorProperty.targets[thisManipulatorProperty.targetPointer%thisManipulatorProperty.targets.Count]) { // Set target pointer if (playgroundParticles.playgroundCache.propertyId[p] != thisManipulator.transform.GetInstanceID()) { playgroundParticles.playgroundCache.propertyTarget[p] = thisManipulatorProperty.targetPointer; thisManipulatorProperty.targetPointer++; thisManipulatorProperty.targetPointer=thisManipulatorProperty.targetPointer%thisManipulatorProperty.targets.Count; playgroundParticles.playgroundCache.propertyId[p] = thisManipulator.transform.GetInstanceID(); } // Teleport or lerp to position based on transition type if (playgroundParticles.playgroundCache.propertyId[p] == thisManipulator.transform.GetInstanceID() && thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count]) { if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) playgroundParticles.particleCache.particles[p].position = localSpace? playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position) : thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position; else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Lerp) { playgroundParticles.particleCache.particles[p].position = localSpace? Vector3.Lerp(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength) : Vector3.Lerp(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength); if (thisManipulatorProperty.zeroVelocityStrength>0) playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], Vector3.zero, t*thisManipulatorProperty.zeroVelocityStrength); } else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Linear) { playgroundParticles.particleCache.particles[p].position = localSpace? Vector3.MoveTowards(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength) : Vector3.MoveTowards(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength); if (thisManipulatorProperty.zeroVelocityStrength>0) playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], Vector3.zero, t*thisManipulatorProperty.zeroVelocityStrength); } // This particle was changed by a target property playgroundParticles.playgroundCache.changedByPropertyTarget[p] = true; } } break; // Death Property case MANIPULATORPROPERTYTYPEC.Death: if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) playgroundParticles.playgroundCache.life[p] = playgroundParticles.lifetime; else playgroundParticles.playgroundCache.birth[p] -= t*thisManipulatorProperty.strength*thisManipulator.strength; // This particle was changed by a death property playgroundParticles.playgroundCache.changedByPropertyDeath[p] = true; break; // Attractors case MANIPULATORPROPERTYTYPEC.Attractor: if (!playgroundParticles.onlySourcePositioning) { float attractorDistance = Vector3.Distance(manipulatorPosition, particlePosition); playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (manipulatorPosition-particlePosition)*((thisManipulatorProperty.strength*thisManipulator.strength)/attractorDistance), t*((thisManipulatorProperty.strength*thisManipulator.strength)/attractorDistance)); } break; // Attractors Gravitational case MANIPULATORPROPERTYTYPEC.Gravitational: if (!playgroundParticles.onlySourcePositioning) { playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (manipulatorPosition-particlePosition)*(thisManipulatorProperty.strength*thisManipulator.strength)/Vector3.Distance(manipulatorPosition, particlePosition), t); } break; // Repellents case MANIPULATORPROPERTYTYPEC.Repellent: if (!playgroundParticles.onlySourcePositioning) { float repellentsDistance = Vector3.Distance(manipulatorPosition, particlePosition); playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (particlePosition-manipulatorPosition)*((thisManipulatorProperty.strength*thisManipulator.strength)/repellentsDistance), t*((thisManipulatorProperty.strength*thisManipulator.strength)/repellentsDistance)); } break; } playgroundParticles.playgroundCache.changedByProperty[p] = true; } else { // Handle colors outside of property manipulator range if (playgroundParticles.playgroundCache.propertyColorId[p] == thisManipulator.transform.GetInstanceID() && (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Color || thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.LifetimeColor)) { // Lerp back color with previous set key if (playgroundParticles.playgroundCache.changedByPropertyColorLerp[p] && thisManipulatorProperty.transition != MANIPULATORPROPERTYTRANSITIONC.None && thisManipulatorProperty.onlyColorInRange) playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime), t*thisManipulatorProperty.strength*thisManipulator.strength); } // Target positioning outside of range if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Target && thisManipulatorProperty.transition != MANIPULATORPROPERTYTRANSITIONC.None) { if (thisManipulatorProperty.targets.Count>0 && thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count]!=null) { if (playgroundParticles.playgroundCache.changedByPropertyTarget[p] && !thisManipulatorProperty.onlyPositionInRange && thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count] && playgroundParticles.playgroundCache.propertyId[p] == thisManipulator.transform.GetInstanceID()) { if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Lerp) playgroundParticles.particleCache.particles[p].position = localSpace? Vector3.Lerp(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength) : Vector3.Lerp(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength); else playgroundParticles.particleCache.particles[p].position = localSpace? Vector3.MoveTowards(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength) : Vector3.MoveTowards(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength); if (thisManipulatorProperty.zeroVelocityStrength>0) playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], Vector3.zero, t*thisManipulatorProperty.zeroVelocityStrength); } } } } }
public ManipulatorPropertyC Clone () { ManipulatorPropertyC manipulatorProperty = new ManipulatorPropertyC(); manipulatorProperty.type = this.type; manipulatorProperty.transition = this.transition; manipulatorProperty.velocity = this.velocity; manipulatorProperty.color = this.color; manipulatorProperty.lifetimeColor = this.lifetimeColor; manipulatorProperty.size = this.size; manipulatorProperty.useLocalRotation = this.useLocalRotation; manipulatorProperty.onlyColorInRange = this.onlyColorInRange; manipulatorProperty.keepColorAlphas = keepColorAlphas; manipulatorProperty.onlyPositionInRange = onlyPositionInRange; manipulatorProperty.zeroVelocityStrength = zeroVelocityStrength; manipulatorProperty.strength = strength; manipulatorProperty.targetPointer = targetPointer; manipulatorProperty.targets = new List<Transform>(); for (int i = 0; i<targets.Count; i++) manipulatorProperty.targets.Add(targets[i]); return manipulatorProperty; }