public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label) { Object asset = null; SerializedProperty assetGUIDProperty = _property.FindPropertyRelative("assetGUID"); if (!string.IsNullOrEmpty(assetGUIDProperty.stringValue)) { asset = GUIDToAsset(assetGUIDProperty.stringValue, NamedAttribute.resourceType); } Object newAsset = EditorGUI.ObjectField(_position, UpperSeparatedName(_property.name), asset, NamedAttribute.resourceType, false); if (asset != newAsset) { object current = _property.serializedObject.targetObject; string[] fields = _property.propertyPath.Split('.'); for (int i = 0; i < fields.Length; i++) { string fieldName = fields[i]; if (fieldName.Equals("Array")) { fieldName = fields[++i]; string indexString = fieldName.Substring(5, fieldName.Length - 6); int index = int.Parse(indexString); System.Type type = current.GetType(); if (type.IsArray) { System.Array array = current as System.Array; current = array.GetValue(index); } else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List <>)) { IList list = current as IList; current = list[index]; } } else { FieldInfo field = current.GetType().GetField(fields[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); current = field.GetValue(current); } } AssetLink obj = current as AssetLink; SetAsset.Invoke(obj, new object[] { newAsset }); // obj.asset = newAsset; _property.serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(_property.serializedObject.targetObject); } }
public TxTemplate MakeTransferTransaction(List <UnspentOutput> unspentOutputs, List <Output> outputs, dynamic metadata) { var inputTemplates = new List <InputTemplate>(); foreach (var uo in unspentOutputs) { var tx = uo.Tx; var fulfilledOutput = tx.Outputs[uo.OutputIndex]; var transactionLink = new Fulfill { OutputIndex = uo.OutputIndex, TransactionId = tx.Id }; inputTemplates.Add(makeInputTemplate(fulfilledOutput.PublicKeys, transactionLink)); } var assetLink = new AssetLink { Id = unspentOutputs[0].Tx.Operation == Transaction.CREATE.ToString() ? unspentOutputs[0].Tx.Id : unspentOutputs[0].Tx.Asset.Id }; return(MakeTrasnsaction(Transaction.TRANSFER.ToString(), assetLink, metadata, outputs, inputTemplates)); }