// COPY PROPERTY // // override public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint) { base.CopyProperty(originalProperty, theOwnerBlueprint); MeshProperty originalMeshProperty = originalProperty as MeshProperty; value = originalMeshProperty.value; }
// GET VALUE // // public Mesh GetValue() { Mesh returnValue = null; switch (dataMode) { case eDataMode.Constant: returnValue = value; break; case eDataMode.Reference: if (reference != null) { MeshProperty theReference = (MeshProperty)reference.property; if (theReference != null) { returnValue = theReference.GetValue(); } } break; case eDataMode.Parameter: if (wasParameterQueried == false) { parameter = ownerBlueprint.ownerEmitter.GetParameter(parameterName, AmpsHelpers.eParameterTypes.Mesh); wasParameterQueried = true; } if (parameter != null) { returnValue = parameter.GetMeshValue(); } else { returnValue = value; } break; } return(returnValue); }
//============================================================================// #if UNITY_EDITOR // INITIALIZE // // override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint) { base.Initialize(theOwnerStack, theOwnerBlueprint); subMenuName = AmpsHelpers.formatEnumString(eCategories.Shapes.ToString()); type = "Mesh sampler"; SetDefaultName(); sampledMesh = ScriptableObject.CreateInstance <MeshProperty>(); sampledMesh.Initialize("Mesh"); AddProperty(sampledMesh, true); sampledMeshElement = ScriptableObject.CreateInstance <DropdownProperty>(); sampledMeshElement.Initialize("Element", 0, theOwnerBlueprint); AddProperty(sampledMeshElement, true); samplingOrder = ScriptableObject.CreateInstance <DropdownProperty>(); samplingOrder.Initialize("Order", 0, theOwnerBlueprint); AddProperty(samplingOrder, true); isEmitterRelative = ScriptableObject.CreateInstance <BoolProperty>(); isEmitterRelative.Initialize("Emitter relative?", theOwnerBlueprint); AddProperty(isEmitterRelative, true); implementsVisualization = false; }
//============================================================================// #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; } }