How do I change a model of a person to another model? - unity3d

I have a model of a person in my project and I found another .obj file online. I imported it into the project and changed the name of that to the name of the original object. I also changed the name of the new material to the name of the old material. Then I deleted the original file and the object does not show up on the scene anymore. Any help would be greatly appreciated! P.s. I am using unity version 5.3.4.

Unity does not reference elements by their names. If you delete the referenced object then reference will be lost, unity will not lookup for another object with same name.
So, to display object_2 in place of object_1 you have to manually change the reference from object_1 to object_2 in the inspector. Or if object_1 is directly placed in the scene then simply delete the object_1 from scene and drag & drop object_2 from project to scene hierarchy.

You need to locate your model in the Project tab and drag it to your Hierarchy tab

Related

UI Toolkit Custom Inspector Disappeared in Playmode Unity

I have created a custom inspector using the UI Toolkit. The way I initialize the UI Document is as follows:
public VisualTreeAsset uXML;
This uXML is assigned through the inspector. Then in CreateInspectorGUI:
root = new VisualElement();
if (uXML == null)
{
Debug.Log("UI Document is " + documentName + " null");
return root;
}
uXML.CloneTree(root);
The root is the main root of the UI document (I am using UI Toolkit).
The problem is that when I enter play mode, the Inspectors disappears as shown:
I’m going to assume that you used a “Default Reference” for your editor script. Unfortunately, the default reference is only deserialised when you're in "Edit" mode. As soon as you go to "Play" mode, the reference is null.
The general way to get around the issue is to search for your asset when you create the inspector window:AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/PathToYourFiles/YourFile.uxml")
Unfortunately, if you move your files somewhere else, you need to go in an update the string file location. Because it's a string path, there's no reference to follow the file if you move or rename the file. It's not clean, but it's easy, and gives you your inspector when in Play mode.
I did a quick search on the issue. Looking at this document, it seems Unity also suggest using Addressables or the Resources folder.
Because you don't really want the assets to follow you into a final build, I prefer placing them into an Editor folder, and just making sure I'm careful when moving or renaming the files. In one project, I made an automated process that "found" the file for me. It involved using a ScriptableObject and Assembly Reloads but I'm still in two minds whether the effort was worth it.

Should I add the information in both side

I am new to unity ,plz forgive me asking these questions
It bumps out : default reference will only be applied in edit mode
Is it important, what is that?
Should I need to add the information(food and border ) to both sides?
The second image are default references. If you set them they are automatically applied after adding this script to an object.
They are not required. And only apply to a script added via the Editor (not by script!). What matters later on runtime are only the values on the GameObject.
Further you can only reference assets from the Assets folder here. They make sense e.g. if you have a button script that uses a certain Click sound, a texture and e.g. a prefab. For these three you now could already define default values so someone using your component doesn't have to assign everything everytime but already has the default references as a kind of fallback.
So in your case it would only make sense, if the borders are prefabs from the Assets that are spawned by this script. The FoodPrefab is even called like this and makes sense to have as a default reference so you don't have to drag it into each and every instance of SpawnFood you create.
And btw just by looking at your settings you should probably directly make your fields of type RectTransform so you can't accidentally reference another object there.

How to add the new unity uxml(via ui builder) to game screen?

I installed the new Unity UI Builder. Everything works just fine...
But how do I add the uxml to my scene or how do I attache it to camera?
I tried to drag and drop the uxml to camera and I searched for a component, but I couldn't find anything... Is there any official documentation?
You must use an gameObject with PanelRenderer.cs attached to it:
For now, I only know you have to set UXML file and USS file. In play mode, by magic (I still don't understand how unity does it), it will render.
In the Github project you can see how things are for now. UIElementsUniteCPH2019RuntimeDemo
EDIT:
The project linked above uses UI Builder 0.8.
Runtime support is still not available using the packet manager.
You can add the preview version to your project by adding the following line to your manifest.json (it's located in the projects Packages-folder)
"com.unity.ui.runtime": "0.0.4-preview"
You may want to check whether a newer version is available.
Keep in mind that the preview version is intended for previews only. The api and workflow might change with newer versions.
Once runtime support is enabled you can use the Panel Renderer as described above.
In Unity 2021.2, when you add a UI Document to the hierarchy, a PanelSettings asset is automatically created and assigned to the that UI Document.
Simply add your uxml file to the UI Document -- there is no Panel Renderer component anymore.
Even though the UI Builder offers a preview of the menu over the actual game scene, there is no way to use that menu in a game using Unity's functionality or packages. To do that we need to use the code that comes with the demo by Damian Campeanu from Unite Copenhagen 2019 that you can find here: https://github.com/Unity-Technologies/UIElementsUniteCPH2019RuntimeDemo.
The demo has following structure.
Structure of the project
The files that we are interested in are located in Assets/UIRuntime folder. Simply copy this folder into Assets folder of your project.
After copying the the folder,create empty game object, and add two components in the inspector. Panel Scaler and Panel Renderer.
Game menu object with panel scaler and panel renderer components
Panel Scaller is responsible for scalling your menu for the display. Choose "Constant Physical Size" and 96 for both Reference and Fallback DPI. Those are the values from the original demo and 96 DPI is a typical pixel density for most computer screens (it is different on mobiles and high density screens).
Panel Renderer is the place where you will set your UXML and USS (Unity Style Sheet) files (Uxml and Unity Style Sheet fields. Leave the last two of fields empty, and tick the "Enable Live Updates" checkbox. This will enable you to show the updates in the game viewport as you make them.
I wanted to comment under existing answer by Pablo but I'm new so I can't.

Move a file after download to folder in C#

Hi i'm downloading a file in to unity but i need to move the file in to a folder. How can i do this in C#?
Do you mean how to put the game object as a child of another? (That's what it looks like from your screenshot)
If so, you can accomplish that by setting your game-object's transform's parent to the transform of the "folder" you want to put it into.
Something like:
teapot.transform.SetParent(NEWTest.transform);
http://docs.unity3d.com/ScriptReference/Transform.SetParent.html has more information.

Creating a Theme / Template for iOS application?

I am creating an application where there are some views i want to be available in each and every UIView Controller just like a master page in Web Development. i have created those views but how to add them to all the view controllers in the application automatically?
You should add them to mainWindow if you need to display them in all viewcontrollers.
Hope it helps you.
You need to convert the project and all the views that you created to a template first and then create a new project and use that template. Here is a guide I have used:
This guide explains how to create new project templates in Xcode. Project templates appear in the list of project types in the New Project dialog.
1.Create a new project and setup everything as you'd like (NIB files, graphics, sounds, settings, code etc)
Optionally, build and make sure the project works
Use Finder and locate the project folder for your project you created in step 1
Open another Finder window and navigate to /Library/Application Support/Apple/Developer Tools/Project Templates/. You have two options here:
Create a new folder for your custom project templates - this will appear as a category when creating a new project in XCode
Choose an already existing folder (eg Application) - this will place the project template in that category
5.Open the new/chosen category folder and create a new folder inside. You can name this new folder whatever you like and it will appear as the project template name.
6.Copy all files from the project folder in step 3 to the new template folder created in step 5.
7.Try to create a new project in Xcode. You should see your project template in one of the original categories or in the category you created, whichever you decided.
Note: If you built the project, delete the build folder from the template folder.
Hope this would help you out.
Create a base view controller class which will have all these UIViews added in its view. Additionally, you can also implement the events of these particular views in the controller. Other controllers that you create need to extend from this base view controller class.