x


duplicate a prefab then change the model?

most of the assets that i am using are of a basic sort of model , and use then same scripts. i can drag the model to the screen then spend time adding all the scripts and make these a prefab, which takes time with about 40 differnt models were only 1 or two things need changing in the scipts public part.

what i would like to do is place model add all the scripts then make this a prefab. then duplicate the prefab and change the model, is this possible ?

more ▼

asked Jul 30 '12 at 12:29 PM

thedodgeruk gravatar image

thedodgeruk
92 8 24 49

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

i don't know way to easy move configured component from one object to another with saving target's configured components... but...

i found an easy way to create a preconfigured components on gameobjects. script below makes a menu with fast adding preconfigured rigidbody to object. you can use this way to add any preconfigured component. also, you can do it in runtime (just use method's content in runtime script)

also, don't forget that you can set default values for monobehaviours in script. then script will add with these default values.

using UnityEditor;
using UnityEngine;
using System.Collections;
public class FastMenu : MonoBehaviour {

    [MenuItem("UnityAnswers/Add Preconfigured Rigidbody")]
    static void AddPreconfiguredRigidbody()
    {
        GameObject go = Selection.activeGameObject;
        if (go)
        {
            Rigidbody rb = go.GetComponent<Rigidbody>();
            if (!rb) { rb = go.AddComponent<Rigidbody>(); }
            rb.mass = 100;
            rb.drag = 0.5f;
            rb.angularDrag = 0.5f;
            rb.constraints = RigidbodyConstraints.FreezeRotation;
        }
    }
}
more ▼

answered Jul 30 '12 at 12:46 PM

ScroodgeM gravatar image

ScroodgeM
7.6k 2 6

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1364
x1259
x574
x379
x61

asked: Jul 30 '12 at 12:29 PM

Seen: 493 times

Last Updated: Jul 30 '12 at 12:46 PM