//============================================================================// #region GUI // SHOW PROPERTY // // override public void ShowProperty(ref BaseProperty selectedProperty, bool isReadOnly) { GUILayout.BeginVertical(GetStyle(selectedProperty)); base.ShowProperty(ref selectedProperty, isReadOnly); switch (dataMode) { case eDataMode.Constant: GUILayout.BeginHorizontal(); //GUILayout.Space(8); constant = SortedPopup(constant, displayData()); GUILayout.EndHorizontal(); break; case eDataMode.Reference: CheckReferences(); ShowReferenceControl(); break; } GUILayout.EndVertical(); HandleSelection(ref selectedProperty, this); }
// COPY PROPERTY // // virtual public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint) { // We don't copy non-user-editable properties so their values // don't linger, code updates are followed in already placed properties // after the next blueprint commit. // //name = originalProperty.name; //allowDataModeRandomConstant = originalProperty.allowDataModeRandomConstant; //allowDataModeCurve = originalProperty.allowDataModeCurve; //allowDataModeRandomCurve = originalProperty.allowDataModeRandomCurve; //allowDataModeReference = originalProperty.allowDataModeReference; //allowDataModeParameter = originalProperty.allowDataModeParameter; dataMode = originalProperty.dataMode; reference = originalProperty.reference; parameterName = originalProperty.parameterName; parameter = originalProperty.parameter; if (theOwnerBlueprint != null) { ownerBlueprint = theOwnerBlueprint; } else { ownerBlueprint = originalProperty.ownerBlueprint; } coordSystem = originalProperty.coordSystem; coordSystemConversionMode = originalProperty.coordSystemConversionMode; }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup("Mesh"); sampledMesh.ShowProperty(ref selectedProperty, false); if (sampledMeshElement.displayData == null) { sampledMeshElement.displayData = () => meshElementsDisplayData; // We have to do this here because delegates are not serialized. } sampledMeshElement.ShowProperty(ref selectedProperty, false); if (samplingOrder.displayData == null) { samplingOrder.displayData = () => samplingOrderDisplayData; // We have to do this here because delegates are not serialized. } samplingOrder.ShowProperty(ref selectedProperty, false); if (isEmitterRelative == null) // HACK { isEmitterRelative = ScriptableObject.CreateInstance <BoolProperty>(); isEmitterRelative.Initialize("Emitter relative?", ownerBlueprint); AddProperty(isEmitterRelative, true); } isEmitterRelative.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup(""); useStackValue.ShowProperty(ref selectedProperty, false); if (useStackValue.GetValue() == false) { valueA.ShowProperty(ref selectedProperty, false); } if (condition.displayData == null) { condition.displayData = () => conditionsDisplayData; // We have to do this here because delegates are not serialized. } condition.ShowProperty(ref selectedProperty, false); valueB.ShowProperty(ref selectedProperty, false); valueFalse.ShowProperty(ref selectedProperty, false); valueTrue.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
// SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { BaseProperty previousSelection = selectedProperty; //moduleName.ShowProperty(ref selectedProperty, false); playOnAwake.ShowProperty(ref selectedProperty, false); pauseWhenUnseenDuration.ShowProperty(ref selectedProperty, false); //if (canParentControlPlayback == null) // HACK //{ // canParentControlPlayback = ScriptableObject.CreateInstance<BoolProperty>(); // canParentControlPlayback.SetDataModes(true, false, false, false, false, false); // canParentControlPlayback.Initialize("Can parent control playback?", true, ownerBlueprint); // AddProperty(canParentControlPlayback, false); //} //canParentControlPlayback.ShowProperty(ref selectedProperty, false); emitterDuration.ShowProperty(ref selectedProperty, false); isLooping.ShowProperty(ref selectedProperty, false); maxParticles.ShowProperty(ref selectedProperty, false); timeScale.ShowProperty(ref selectedProperty, false); accelerationNoiseSmoothing.ShowProperty(ref selectedProperty, false); // TODO: Add update rate. if (selectedProperty != previousSelection) { shouldRepaint = true; } }
// SHOW PROPERTY // // override public void ShowProperty(ref BaseProperty selectedProperty, bool isReadOnly) { GUILayout.BeginVertical(GetStyle(selectedProperty)); base.ShowProperty(ref selectedProperty, isReadOnly); switch (dataMode) { case eDataMode.Constant: EditorGUIUtility.labelWidth = 50; EditorGUIUtility.fieldWidth = 50; value = (Material)EditorGUILayout.ObjectField("Material", value, typeof(Material), true); EditorGUIUtility.labelWidth = 0; EditorGUIUtility.fieldWidth = 0; break; case eDataMode.Parameter: GUILayout.BeginVertical(); ParameterHeader(); EditorGUIUtility.labelWidth = 50; EditorGUIUtility.fieldWidth = 50; value = (Material)EditorGUILayout.ObjectField("Material", value, typeof(Material), true); EditorGUIUtility.labelWidth = 0; EditorGUIUtility.fieldWidth = 0; GUILayout.EndVertical(); break; } GUILayout.EndVertical(); HandleSelection(ref selectedProperty, this); }
// COPY PROPERTY // // override public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint) { base.CopyProperty(originalProperty, theOwnerBlueprint); BoolProperty originalBoolProperty = originalProperty as BoolProperty; value = originalBoolProperty.value; }
// COPY PROPERTY // // override public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint) { base.CopyProperty(originalProperty, theOwnerBlueprint); DropdownProperty originalDropdownProperty = originalProperty as DropdownProperty; displayData = originalDropdownProperty.displayData; constant = originalDropdownProperty.constant; }
// REFERENCE A PROPERTY // // virtual public void ReferenceAProperty(BaseProperty property, BaseModule originalModule, BaseProperty originalProperty) { if (originalModule != null) { property.dataMode = BaseProperty.eDataMode.Reference; property.reference = ScriptableObject.CreateInstance <PropertyReference>(); property.reference.Initialize(originalModule, originalProperty); } }
// SHOW MINI HEADER // // public void ShowMiniHeader(ref BaseProperty selectedProperty, bool isReadOnly) { if (isReadOnly == false) { GUILayout.BeginHorizontal("propertyHeader"); GUILayout.Label(name, "propertyName"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } }
// ADD PROPERTY // // public void AddProperty(BaseProperty bp, bool isShared) { properties.Add(bp); if (isShared && ownerStack.stackFunction == AmpsHelpers.eStackFunction.Shared) { sharedProperties.Add(bp); bp.allowDataModeReference = false; } }
// GET STYLE // // public GUIStyle GetStyle(BaseProperty selectedProperty) { if (selectedProperty == this) { return(GUI.skin.GetStyle("propertyBoxSelected")); } else { return(GUI.skin.GetStyle("propertyBoxNormal")); } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; vector.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup("Sampler"); int previousSamplerCondition = samplerCondition.GetValue(); if (samplerCondition.displayData == null) { samplerCondition.displayData = () => samplerConditionsDisplayData; // We have to do this here because delegates are not serialized. } samplerCondition.ShowProperty(ref selectedProperty, false); // If the sampler condition has changed then we select the related dropdown property // to void having a property selected which might not be displayed bellow. if (samplerCondition.GetValue() != previousSamplerCondition) { selectedProperty = samplerCondition; } if (samplerCondition.GetValue() != (int)eSamplerConditions.OnCreation) { sampleOnSpawn.ShowProperty(ref selectedProperty, false); } // BUG: It is possible that the selected property is not shown which is visually confusing. switch (samplerCondition.GetValue()) { case (int)eSamplerConditions.OnCreation: intervalOffset.ShowProperty(ref selectedProperty, false); break; case (int)eSamplerConditions.ByTime: interval.ShowProperty(ref selectedProperty, false); intervalOffset.ShowProperty(ref selectedProperty, false); break; case (int)eSamplerConditions.ByDirectValue: directValue.ShowProperty(ref selectedProperty, false); break; default: break; } if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//// COPY PROPERTIES // //// //override public void CopyProperties(BaseModule originalModule, AmpsBlueprint theOwnerBlueprint) //{ // base.CopyProperties(originalModule, theOwnerBlueprint); // QuickSetupMFModule om = originalModule as QuickSetupMFModule; // if (om != null) // { // spawnRate.CopyProperty(om.spawnRate, theOwnerBlueprint); // deathCondition.CopyProperty(om.deathCondition, theOwnerBlueprint); // acceleration.CopyProperty(om.acceleration, theOwnerBlueprint); // velocity.CopyProperty(om.velocity, theOwnerBlueprint); // position.CopyProperty(om.position, theOwnerBlueprint); // rotationRate.CopyProperty(om.rotationRate, theOwnerBlueprint); // rotation.CopyProperty(om.rotation, theOwnerBlueprint); // scale.CopyProperty(om.scale, theOwnerBlueprint); // color.CopyProperty(om.color, theOwnerBlueprint); // pivotOffset.CopyProperty(om.pivotOffset, theOwnerBlueprint); // } //} //============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup("Spawn rate"); modifySpawnRate.ShowProperty(ref selectedProperty, false); spawnRate.ShowProperty(ref selectedProperty, false); PropertyGroup("Life"); modifyDeathCondition.ShowProperty(ref selectedProperty, false); deathCondition.ShowProperty(ref selectedProperty, false); PropertyGroup("Position"); modifyPosition.ShowProperty(ref selectedProperty, false); position.ShowProperty(ref selectedProperty, false); PropertyGroup("Acceleration"); modifyAcceleration.ShowProperty(ref selectedProperty, false); acceleration.ShowProperty(ref selectedProperty, false); PropertyGroup("Velocity"); modifyVelocity.ShowProperty(ref selectedProperty, false); velocity.ShowProperty(ref selectedProperty, false); PropertyGroup("Rotation"); modifyRotation.ShowProperty(ref selectedProperty, false); rotation.ShowProperty(ref selectedProperty, false); PropertyGroup("Rotation rate"); modifyRotationRate.ShowProperty(ref selectedProperty, false); rotationRate.ShowProperty(ref selectedProperty, false); PropertyGroup("Scale"); modifyScale.ShowProperty(ref selectedProperty, false); scale.ShowProperty(ref selectedProperty, false); PropertyGroup("Color"); modifyColor.ShowProperty(ref selectedProperty, false); color.ShowProperty(ref selectedProperty, false); PropertyGroup("Pivot offset"); modifyPivotOffset.ShowProperty(ref selectedProperty, false); pivotOffset.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup("Shape: Point"); point.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup("Object transform"); sampledObject.ShowProperty(ref selectedProperty, false); insideValue.ShowProperty(ref selectedProperty, false); outsideValue.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #if UNITY_EDITOR // INITIALIZE // // virtual public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint) { type = ""; subMenuName = ""; ownerBlueprint = theOwnerBlueprint; ownerStack = theOwnerStack; shouldSelectThis = false; exampleInput = Vector4.zero; properties = new List <BaseProperty>(); sharedProperties = new List <BaseProperty>(); moduleName = ScriptableObject.CreateInstance <StringProperty>(); moduleName.Initialize("Description", ""); AddProperty(moduleName, false); selectedProperty = moduleName; }
//// COPY PROPERTIES // //// //override public void CopyProperties(BaseModule originalModule, AmpsBlueprint theOwnerBlueprint) //{ // base.CopyProperties(originalModule, theOwnerBlueprint); // DataConverterModule om = originalModule as DataConverterModule; // if (om != null) // { // conversionMode.CopyProperty(om.conversionMode, theOwnerBlueprint); // } //} //// REFERENCE PROPERTIES // //// //override public void ReferenceProperties(BaseModule originalModule) //{ // base.ReferenceProperties(originalModule); // DataConverterModule om = originalModule as DataConverterModule; // ReferenceAProperty(conversionMode, om, om.conversionMode); //} //============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { //base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; moduleName.ShowProperty(ref selectedProperty, false); PropertyGroup(""); if (conversionMode.displayData == null) { conversionMode.displayData = () => conversionModeDisplayData; // We have to do this here because delegates are not serialized. } conversionMode.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup(""); useStackValue.ShowProperty(ref selectedProperty, false); if (useStackValue.GetValue() == false) { changePerSecond.ShowProperty(ref selectedProperty, false); } if (selectedProperty != previousSelection) { shouldRepaint = true; } }
// COPY PROPERTY // // override public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint) { base.CopyProperty(originalProperty, theOwnerBlueprint); ScalarProperty originalScalarProperty = originalProperty as ScalarProperty; constant = originalScalarProperty.constant; randomMin = originalScalarProperty.randomMin; randomMax = originalScalarProperty.randomMax; curve = ScriptableObject.CreateInstance <ScalarCurve>(); curve.Initialize(originalScalarProperty.curve); curveMin = ScriptableObject.CreateInstance <ScalarCurve>(); curveMin.Initialize(originalScalarProperty.curveMin); curveMax = ScriptableObject.CreateInstance <ScalarCurve>(); curveMax.Initialize(originalScalarProperty.curveMax); isInteger = originalScalarProperty.isInteger; Randomize(); }
// HANDLE SELECTION // // public void HandleSelection(ref BaseProperty currentSelection, BaseProperty currentProperty) { if (Event.current.type == EventType.Repaint) { propertyRect = GUILayoutUtility.GetLastRect(); } if (Event.current.type == EventType.MouseDown && propertyRect.Contains(Event.current.mousePosition)) { shouldSelectThis = true; } if (Event.current.type == EventType.Layout && shouldSelectThis) { currentSelection = currentProperty; shouldSelectThis = false; } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup("Object transform"); sampledObject.ShowProperty(ref selectedProperty, false); if (sampledTransformElement.displayData == null) { sampledTransformElement.displayData = () => transformElementsDisplayData; // We have to do this here because delegates are not serialized. } sampledTransformElement.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #region GUI // SHOW PROPERTY // // override public void ShowProperty(ref BaseProperty selectedProperty, bool isReadOnly) { GUILayout.BeginVertical(GetStyle(selectedProperty)); base.ShowProperty(ref selectedProperty, isReadOnly); switch (dataMode) { case eDataMode.Parameter: GUILayout.BeginVertical(); ParameterHeader(); GUILayout.EndVertical(); break; } GUILayout.EndVertical(); HandleSelection(ref selectedProperty, this); }
// COPY PROPERTY // // override public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint) { base.CopyProperty(originalProperty, theOwnerBlueprint); ColorProperty originalColorProperty = originalProperty as ColorProperty; constant = originalColorProperty.constant; randomMin = originalColorProperty.randomMin; randomMax = originalColorProperty.randomMax; curve = ScriptableObject.CreateInstance <VectorCurve>(); curve.Initialize(originalColorProperty.curve); curveMin = ScriptableObject.CreateInstance <VectorCurve>(); curveMin.Initialize(originalColorProperty.curveMin); curveMax = ScriptableObject.CreateInstance <VectorCurve>(); curveMax.Initialize(originalColorProperty.curveMax); usePerComponentRandom = originalColorProperty.usePerComponentRandom; Randomize(); dummyTexture = new Texture2D(1, 1); }
// COPY PROPERTY // // override public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint) { base.CopyProperty(originalProperty, theOwnerBlueprint); VectorProperty originalVectorProperty = originalProperty as VectorProperty; constant = originalVectorProperty.constant; randomMin = originalVectorProperty.randomMin; randomMax = originalVectorProperty.randomMax; curve = ScriptableObject.CreateInstance <VectorCurve>(); curve.Initialize(originalVectorProperty.curve); curveMin = ScriptableObject.CreateInstance <VectorCurve>(); curveMin.Initialize(originalVectorProperty.curveMin); curveMax = ScriptableObject.CreateInstance <VectorCurve>(); curveMax.Initialize(originalVectorProperty.curveMax); usePerComponentRandom = originalVectorProperty.usePerComponentRandom; useExtremes = originalVectorProperty.useExtremes; hideW = originalVectorProperty.hideW; Randomize(); }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; if (ownerStack.stackFunction != AmpsHelpers.eStackFunction.Shared) { weight.ShowProperty(ref selectedProperty, false); if (blendMode.displayData == null) { blendMode.displayData = () => blendModesDisplayData; // We have to do this here because delegates are not serialized. } blendMode.ShowProperty(ref selectedProperty, false); } if (selectedProperty != previousSelection) { shouldRepaint = true; } }
// SHOW PROPERTY // // override public void ShowProperty(ref BaseProperty selectedProperty, bool isReadOnly) { GUILayout.BeginVertical(GetStyle(selectedProperty)); base.ShowProperty(ref selectedProperty, isReadOnly); GUI.SetNextControlName(AmpsHelpers.stringControlName); if (isReadOnly) { GUI.enabled = false; } value = GUILayout.TextField(value); if (isReadOnly) { GUI.enabled = true; } GUILayout.EndVertical(); HandleSelection(ref selectedProperty, this); }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup(""); if (property.displayData == null) { property.displayData = () => AmpsHelpers.curveInputDisplayData; // We have to do this here because delegates are not serialized. } property.ShowProperty(ref selectedProperty, false); sampleFromParent.ShowProperty(ref selectedProperty, false); modifyX.ShowProperty(ref selectedProperty, false); modifyY.ShowProperty(ref selectedProperty, false); modifyZ.ShowProperty(ref selectedProperty, false); modifyW.ShowProperty(ref selectedProperty, false); if (selectedProperty != previousSelection) { shouldRepaint = true; } }
//============================================================================// #region GUI // SHOW PROPERTIES // // override public void ShowProperties(ref bool shouldRepaint) { base.ShowProperties(ref shouldRepaint); BaseProperty previousSelection = selectedProperty; PropertyGroup(""); inputMeshCount.constant = inputMeshes.Length; inputMeshCount.ShowProperty(ref selectedProperty, false); if (inputMeshCount.GetValue() > 0 && inputMeshCount.GetValue() != inputMeshes.Length) { MeshProperty[] newMeshes = new MeshProperty[(int)inputMeshCount.GetValue()]; for (int i = 0; i < newMeshes.Length; i++) { if (i <= inputMeshes.Length - 1) { newMeshes[i] = inputMeshes[i]; } else { newMeshes[i] = ScriptableObject.CreateInstance <MeshProperty>(); newMeshes[i].Initialize("Mesh " + i); AddProperty(newMeshes[i], false); } } inputMeshes = newMeshes; } foreach (MeshProperty m in inputMeshes) { m.ShowProperty(ref selectedProperty, false); } if (selectedProperty != previousSelection) { shouldRepaint = true; } }