x


can you make a prefab but without a model?

is it possible to create prefab that contains only script, and can be paced onto any 3d object , then this will have all the scripts. other wise its a case of insert the asset (model) then attach all the scripts to that model . create a prefab from that . but has to be done time and again .

more ▼

asked Jul 29 '12 at 07:09 PM

thedodgeruk gravatar image

thedodgeruk
92 8 24 49

Hello. Did you find any suggestions useful? Please post a comment or mark an answer, for future reference by other people searching this 'site.

Sep 18 '12 at 10:14 AM alucardj
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Create an Empty GameObject, then you can put that to a prefab.

In Unity, GameObject > Create Empty.

However, If you want to then attach a 3D object to it, you'll have to make the Prefab the parent or child of that object.

more ▼

answered Jul 29 '12 at 07:17 PM

alucardj gravatar image

alucardj
13.5k 34 55 86

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

I think you can do that by placing all the scripts on an empty gameobject. make that gameobject into a prefab, then placing the prefab onto anything that you like.

But you must be careful what scripts you place in the prefab taking into account the variables it has and names it has stored.

more ▼

answered Jul 29 '12 at 08:16 PM

Xicer gravatar image

Xicer
24 5 7

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

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 29 '12 at 07:31 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:

x1250
x1089
x571
x417
x80

asked: Jul 29 '12 at 07:09 PM

Seen: 383 times

Last Updated: Nov 09 '12 at 04:48 AM