0
Planned

Option to create objects as children

gabin.deboulogne 1 month ago updated by Lazlo Bonin (Lead Developer) 1 month ago 4 1 duplicate

Hi,

When i create an object with "ctrl + shift + click" the created object is not childed to the object its created on.

 I debuged your code and i found this.


The set parent first param returns null instead of the raycast hit transform
I was able to fix this bug by changing the line 96 in Creator.cs from

instance.transform.SetParent(_hit.Value.transform.parent, true);

To 

instance.transform.SetParent(_hit.Value.transform, true);

With this change the created object parent is correctly set
No offence but it makes more sense that the created object parent is set to the raycast hit transform instead of the raycast hit transform own parent

I made my tests in an empty scene with only one primitive 3d cube and with peek default settings

Unity Version:
2020.1.5f1
Peek Version:
1.3.0

Duplicates 1

Not a Bug

Hi Gabin,

This is by design. The underlying logic is that when creating a scene and placing multiple objects, you normally want objects to be side by side, not deeply nested.

In Peek v.1.3.1, you now also get the option to place objects at the root instead.

I'll treat this ticket as a feature request to add a setting to place objects as children.

Hi, 

Your logic only works if the raycast hit is childed to something

I've added a check in the code so object are childed whether or not they have a parent

//Peek 1.3.1, creator.cs line 107
parent = _hit.Value.transform.parent != null ? _hit.Value.transform.parent : _hit.Value.transform

Hi Tab Games,

Glad you're enjoying the asset :) And thanks for the suggestion.

Another user suggested something similar this week, so I'll merge your thread.

Currently, in Peek 1.3.1, there are 3 options for where Peek will place new objects created via the Creator:

  • Root: At the root of the active scene
  • Sibling: As a sibling of the picked object (next to it in the hierarchy)
  • Sibling Except Prefabs (default): Same as sibling, but does not create objects within prefab instances; it will bubble up until it's outside a prefab instance.

I'll add another option for "Child" in a future version.