bsimser / Inventory-Pro

https://devdog.io
MIT License
2 stars 0 forks source link

Position now on Visually Equip equipment is broken #287

Closed bsimser closed 5 years ago

bsimser commented 5 years ago

Original report by Anonymous.


Line 78ish: currentEquippable = (EquippableInventoryItem)PrefabUtility.InstantiatePrefab(t as EquippableInventoryItem);

in public class EquippableInventoryItemEditor : InventoryItemBaseEditor

returns null and doesn't allow a prefab to be created to visually equip an item.

Changing this line to: currentEquippable = Instantiate(t);

Does instantiate a prefab but clicking Save Now does not update the position. Trying to do so manually doesn't apply the transforms back appropriately.

bsimser commented 5 years ago

Original comment by KungFuBrad (Bitbucket: KungFuBrad, GitHub: KungFuBrad).


Update line 78 to:

Selection.activeObject = AssetDatabase.LoadMainAssetAtPath("Assets/MMDatabases/Items/" + target.name + ".prefab");
GameObject initialItem = PrefabUtility.InstantiatePrefab(Selection.activeObject as GameObject) as GameObject;
currentEquippable = initialItem.GetComponent();

and line 117ish (serializedObject.ApplyModifiedProperties();) to:

PrefabUtility.ApplyPrefabInstance(currentEquippable.gameObject, InteractionMode.AutomatedAction);

bsimser commented 5 years ago

Original comment by György Nagy (Bitbucket: Benedicht, GitHub: Benedicht).


@{5bbd166be4fc9c508d20115d} Attached a new version of EquippableInventoryItemEditor.cs, please try it out and let me know how it works.

Tivadar

bsimser commented 5 years ago

Original comment by KungFuBrad (Bitbucket: KungFuBrad, GitHub: KungFuBrad).


So it sort of works. It does indeed add it to the appropriate parent slot but the transform isn’t correct. What I mean by that is the rotation and position and size is off.

Progress though, happy to test next version.

bsimser commented 5 years ago

Original comment by György Nagy (Bitbucket: Benedicht, GitHub: Benedicht).


@KungFuBrad

Attached a new version, it should fix the position and rotation saving.

bsimser commented 5 years ago

Original comment by György Nagy (Bitbucket: Benedicht, GitHub: Benedicht).


@{5bbd166be4fc9c508d20115d} Can we consider this issue fixed?

bsimser commented 5 years ago

Original comment by KungFuBrad (Bitbucket: KungFuBrad, GitHub: KungFuBrad).


Yes please, sorry I responded to this in the Discord channel.

Thanks!