public override void Action(int instanceId, string pathName, string resourceFile) { var obj = EditorUtility.InstanceIDToObject(instanceId); AssetDatabase.CreateAsset(obj, AssetDatabase.GenerateUniqueAssetPath(pathName)); ProjectWindowUtil.FrameObjectInProjectWindow(instanceId); m_Property.objectReferenceValue = obj; m_Property.serializedObject.ApplyModifiedProperties(); m_Property.serializedObject.Dispose(); m_Property.Dispose(); }
public void Dispose() { SerializedProperty[] properties = this.m_Properties; for (int i = 0; i < properties.Length; i++) { SerializedProperty serializedProperty = properties[i]; if (serializedProperty != null) { serializedProperty.Dispose(); } } this.m_SerializedObject.Dispose(); this.m_Object = null; this.m_SerializedObject = null; this.m_Properties = null; }
//Copy One Module's Values private void GenericModuleCopy(SerializedProperty ss, SerializedProperty sd, bool depthBreak = true) { while(true) { //Next Property if(!ss.NextVisible(true)) { break; } sd.NextVisible(true); //If end of module: break if(depthBreak && ss.depth == 0) { break; } bool found = true; switch(ss.propertyType) { case SerializedPropertyType.Boolean : sd.boolValue = ss.boolValue; break; case SerializedPropertyType.Integer : sd.intValue = ss.intValue; break; case SerializedPropertyType.Float : sd.floatValue = ss.floatValue; break; case SerializedPropertyType.Color : sd.colorValue = ss.colorValue; break; case SerializedPropertyType.Bounds : sd.boundsValue = ss.boundsValue; break; case SerializedPropertyType.Enum : sd.enumValueIndex = ss.enumValueIndex; break; case SerializedPropertyType.ObjectReference : sd.objectReferenceValue = ss.objectReferenceValue; break; case SerializedPropertyType.Rect : sd.rectValue = ss.rectValue; break; case SerializedPropertyType.String : sd.stringValue = ss.stringValue; break; case SerializedPropertyType.Vector2 : sd.vector2Value = ss.vector2Value; break; case SerializedPropertyType.Vector3 : sd.vector3Value = ss.vector3Value; break; case SerializedPropertyType.AnimationCurve : sd.animationCurveValue = ss.animationCurveValue; break; #if !UNITY_3_5 case SerializedPropertyType.Gradient : copyGradient(ss,sd); break; #endif default: found = false; break; } if(!found) { found = true; switch(ss.type) { default: found = false; break; } } } //Apply Changes sd.serializedObject.ApplyModifiedProperties(); ss.Dispose(); sd.Dispose(); }