Draw specified Object Inspector into Rect - unity3d

I was wondering if there was any method for drawing a default inspector for a given object into a Rect, similar to the other GUI methods?
I'm looking for a simple way of drawing various inspectors for linked objects into a custom EditorWindow.
I had tried to instance the specific editor as of course that contains DrawDefaultIspector, but I just get masses of exceptions from inside SerializePropertyBindings.
Is there a method to draw the default inspector for a given object?

Just found a solution to this using this post.
I just want to show the default inspector, so I can create an instance of a base Editor then fire OnInspectorGUI() in my EditorWindow.OnGUI() code:
void OnGUI()
{
Editor editor = Editor.CreateEditor(this.linkedObject);
editor.OnInspectorGUI();
}
(Obviously I should probably only recreate that editor when the linkedObject changes, but just for the sake of clarity.)
Doesn't allow me to draw into a Rect, but I assume I can cover that requirement with a scroll panel or similar.

Related

Adding an Outline to a TextMeshPro Text

Good day, I want to add an outline to my textmeshpro, but the Outline component doesn't seem to work. I also tried the outline settings on the inspector, but it edits all textmeshpro in mys scene. I want to have different outline for every game object that uses textmeshpro.
You can try setting it programmatically:
void Awake()
{
TextMeshPro textmeshPro = GetComponent<TextMeshPro>();
textmeshPro.outlineWidth = 0.2f;
textmeshPro.outlineColor = new Color32(255, 128, 0, 255);
}
I have had issues with TextMeshPro and some fonts before, though, which I haven't been able to fix and I could never find the root cause.
That seems to be the normal behaviour of the component, because the material instance is the same for all the components.
http://digitalnativestudios.com/forum/index.php?topic=630.0
If you change the material you can check that the outline then applies individually:
If you want the exact same material in all your components, which is the desirable thing, I would duplicate the desired font and material in editor, and add one different material instance to each of the components.
To create the outline externally on TMP I created a custom shader and posted on Unity's forum: https://forum.unity.com/threads/tmpro-draw-external-outline-before-faces.503999/#post-7619947

Filtering an object field in Unity Editor Extension

I'm looking to use Unity's ObjectField to have users search for objects of a particular type. I know the constructor allows for a typeOf(objectType), but that does not seem to allow for filtering on custom components.
Essentially, a previous editor script I have sets up objects, and places a unique custom script on each of the components, but I've been unsuccessful in utilizing the ObjectField to search for just those objects. If I change the typeOf in my object field to be my component, it is always empty, despite there being many prefabs with that script attached in my project.
Has anyone had any success with this? Using GameObject finds them, but this finds all game objects. Is there any way to restrict this? Or to keep it only looking at particular folders?
Adding a filter while the field itself stays as type Object is a bit tricky. Here's one way.
Use ShowObjectPicker
Try opening a custom ObjectPicker. To do so you'll have to hide the default object picker and call one with a set searchFilter. It is quite a bit of work.
Setting searchFilter
Use https://docs.unity3d.com/ScriptReference/EditorGUIUtility.ShowObjectPicker.html with a searchFilter that matches the component you add to every object you want to show up in an ObjectPicker. for example "t:objectType".
There's some good information on using ShowObjectPicker at https://answers.unity.com/questions/554012/how-do-i-use-editorguiutilityshowobjectpicker-c.html
Hide default object picker
Here's a post with a way to hide the default object picker Is there any way to hide the "Object picker" of an EditorGUILayout.ObjectField in Unity Isnpector?
Show picker
You'll need to create your own Editor GUI.Button to bring up the ShowObjectPicker with the custom searchFilter.
Assets searchFilter
As a sidenote, to do the same with file assets use a "l:labelName" fileFilter instead of "t:objectType". You can set the label with the Unity Editor UI as shown here:
or with "ref:relative/path/from/assets/to/material/material.mat"

how can i regist my own property to unity native animator?

I want to edit some custom proeprty of my own script, 'TopazObject' in Unity native system. But it doesn't appear to animation window.
If the property is public then it is going to show up in the animation tab. Make sure its public. If you have a variable. If you want a variable with a custom class type to be visible there I think there is no way to do it.

Inspector variable for selecting a function to be called (Unity3D)

The latest versions of NGUI have this great tool that lets you pick which function within any of the target's scripts will be called when you click on it.
Basically, it's a select box within the inspector that gets automatically filled with all the functions from all the scripts attached to the game object.
How can I generate a function list that fills up automatically like this?
I don't want to have to maintain an enum with all the possible functions (including some that the current object might not have)
I tried looking at the code NGUI used, but it was a bit too complicated for me to understand right now.
If you want to do it like in NGUI then use the tools that are available within NGUI itself and define a public variable like this:
public List<EventDelegate> DelegateList = new List<EventDelegate>();
With this, you can drop MonoBehaviour scripts in the Inspector field and can then select public methods/delegates contained in that script.
You can then invoke them like this:
void Start() {
EventDelegate.Execute(DelegateList);
}
Now every method in your delegate list will be invoked. You can see this for example in the UIButton script where this is used to handle the OnClick delegates.

tinymce - resize/scale handelers are not in the same place as resize object

Tinymce re-size/scale handlers are not appearing in the same place where the re-sizable/scalable object are, but far below the object.
I am using inline feature, this issue is happening with all re-sizable, like table, image etc.
Here is the screenshot of issue:
I got the solution, position of parent of re-sizable object need to be relative