Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by BeastPro · Jun 21, 2015 at 11:27 AM · unity 5error messagecs

Help with a building system.

I have this error due to the package in using works on unity 4 but not unity 5

here is the script

 /*
  * Advanced Building System - nDev Studio
  * Version 1.1
  * */
 using UnityEngine;
 using System.Collections;
 
 public class AdvancedBuildingScript : MonoBehaviour {
     //Inspector
     public GameObject Player;
     public bool allowCameraMod = true;
     public GameObject CamHolder, CamTargetPos, CamStartPos;
     public Transform spawnPos;
     public Transform[] BuildingObjects;
     public static int CurrentObj = 1;
     public KeyCode enterBuildMod = KeyCode.Tab, changeCamMod = KeyCode.L, changeRotMod = KeyCode.P, changeMoveMod = KeyCode.O;
     public KeyCode forward = KeyCode.UpArrow, backward = KeyCode.DownArrow, left = KeyCode.LeftArrow, right = KeyCode.RightArrow, up = KeyCode.PageUp, down = KeyCode.PageDown, placeObject = KeyCode.KeypadEnter;
     public Vector3 defaultObjPos;
     public Quaternion defaultObjRot;
     public bool playSounds = true;
     public AudioClip placeSound,errorSound;
     public AudioSource audioSource;
     public bool displayObjName = true;
     public GUISkin GuiSkin;
     //
     bool rotateMod = false;
     bool stepMod = false;
     bool cameraMod = false;
     bool buildMod = false;
 
     void PlaySound(AudioClip clip)
     {
         audioSource.clip = clip;
         audioSource.Play ();
     }
 
     void Start()
     {
         ControlObject (spawnPos, spawnPos, true);
     }
     void Update()
     {
         //Enter/Exit Building Mode
         if (Input.GetKeyDown (enterBuildMod)) {
                         if (buildMod == true) {
                                  ControlObject (spawnPos, spawnPos, true);
                                 buildMod = false;
 
                         } else if (buildMod == false) {
                                 buildMod = true;
                         }
                 }
 
                 
         if (buildMod == true) {
                         RenderObject (BuildingObjects [CurrentObj]);
                         ControlObject (spawnPos,BuildingObjects [CurrentObj],false);
                 } else {
             //Reset Cam
             float cameraspeed = 4.0f;
             float increment = 0.0f;
             if (increment <= 1)
                 increment += cameraspeed / 100;
             
             CamHolder.transform.position = Vector3.Lerp (CamHolder.transform.position, CamStartPos.transform.position, increment);
             Player.GetComponent<MouseLook> ().enabled = true;
             cameraMod = false;
             ResetObjects();
                 }
     }
 
     void ControlObject(Transform obj, Transform objToSpawn, bool reset)
     {
         if (reset == false) {
                         //Move Camera
                         float cameraspeed = 4.0f;
                         float increment = 0.0f;
             if (cameraMod == true && allowCameraMod == true) {
                                 if (increment <= 1)
                                         increment += cameraspeed / 100;
                 
                                 CamHolder.transform.position = Vector3.Lerp (CamHolder.transform.position, CamTargetPos.transform.position, increment);
                                 Player.GetComponent<MouseLook> ().enabled = false; //HERE CHANGE THE nDEVMOUSELOOK WITH YOUR MOUSELOOK SCRIPT NAME
             } else {
                                 if (increment <= 1)
                                         increment += cameraspeed / 100;
                 
                                 CamHolder.transform.position = Vector3.Lerp (CamHolder.transform.position, CamStartPos.transform.position, increment);
                                 Player.GetComponent<MouseLook> ().enabled = true;
                 
                         }
                         //End Move Camera
                         if (Input.GetKeyDown (changeCamMod)) {
                                 if (cameraMod == true)
                                         cameraMod = false;
                                 else
                                         cameraMod = true;
                         }
                         if (Input.GetKeyDown (changeRotMod)) {
                                 if (rotateMod == true)
                                         rotateMod = false;
                                 else
                                         rotateMod = true;
                         }
                         if (Input.GetKeyDown (changeMoveMod)) {
                                 if (stepMod == true)
                                         stepMod = false;
                                 else
                                         stepMod = true;
                 
                         }
                         //Block Movement
                         if (rotateMod == false) {
                                 if (stepMod == false) {
                                         //Smooth Mod
                                         if (Input.GetKey (forward)) {
                                                 obj.Translate (Vector3.forward * (Time.deltaTime + 0.05f));
                                         }
                                         if (Input.GetKey (backward)) {
                                                 obj.Translate (Vector3.back * (Time.deltaTime + 0.05f));
                                         }
                                         if (Input.GetKey (left)) {
                                                 obj.Translate (Vector3.left * (Time.deltaTime + 0.05f));
                                         }
                                         if (Input.GetKey (right)) {
                                                 obj.Translate (Vector3.right * (Time.deltaTime + 0.05f));
                                         }        
                                         if (Input.GetKey (up)) {
                                                 obj.Translate (Vector3.up * (Time.deltaTime + 0.05f));
                                         }
                                         if (Input.GetKey (down)) {
                                                 obj.Translate (Vector3.down * (Time.deltaTime + 0.05f));
                                         }
                                 } else if (stepMod == true) {
                                         //Step Mod
                                         if (Input.GetKeyDown (forward)) {
                                                 obj.Translate (Vector3.forward * BuildingObjects [CurrentObj].localScale.x);
                                         }
                                         if (Input.GetKeyDown (backward)) {
                                                 obj.Translate (Vector3.back * BuildingObjects [CurrentObj].localScale.x);
                                         }
                                         if (Input.GetKeyDown (left)) {
                                                 obj.Translate (Vector3.left * BuildingObjects [CurrentObj].localScale.z);
                                         }
                                         if (Input.GetKeyDown (right)) {
                                                 obj.Translate (Vector3.right * BuildingObjects [CurrentObj].localScale.z);
                                         }        
                                         if (Input.GetKeyDown (up)) {
                                                 obj.Translate (Vector3.up * (BuildingObjects [CurrentObj].localScale.y));
                                         }
                                         if (Input.GetKeyDown (down)) {
                                                 obj.Translate (Vector3.down * (BuildingObjects [CurrentObj].localScale.y));
                                         }
                                 }
                 
                         }
                         //Block Rotation
                         if (rotateMod == true) {
                                 if (Input.GetKey (forward)) {
                                         obj.Rotate (Vector3.left * (Time.deltaTime + 1));
                                 }
                                 if (Input.GetKey (backward)) {
                                         obj.Rotate (Vector3.right * (Time.deltaTime + 1));
                                 }
                                 if (Input.GetKey (left)) {
                                         obj.Rotate (Vector3.up * (Time.deltaTime + 1));
                                 }
                                 if (Input.GetKey (right)) {
                                         obj.Rotate (Vector3.down * (Time.deltaTime + 1));
                                 }        
                         }
             
                         //Place Object
                         if (Input.GetKeyDown (placeObject)) {
                                 if (BuildingObjects [CurrentObj].GetComponent<BuildingObj> ().ObjectAmount > 0) {
                                         BuildingObjects[CurrentObj].GetComponent<BuildingObj>().enablePreview = false;
                                         Instantiate (BuildingObjects [CurrentObj].gameObject, obj.position, obj.rotation);
                                         BuildingObjects [CurrentObj].GetComponent<BuildingObj> ().ObjectAmount -= 1;
 
                     if (playSounds == true)
                     {
                         PlaySound (placeSound);
                     }
                                 } else {
                                         Debug.Log ("Not enough Objects");
                                         CurrentObj = 0;
                     if (playSounds == true)
                     {
                         PlaySound (errorSound);
                     }
                                 }
                         }
 
                 } else if (reset == true) {
                         obj.localPosition = defaultObjPos;
                         obj.localRotation = defaultObjRot;
                 }
     }
 
     void RenderObject (Transform obj)
     {
         if (CurrentObj == 0)
         {
            cameraMod = false;
            ResetObjects ();
         } 
         else 
         {
             if (BuildingObjects[CurrentObj].GetComponent<BuildingObj>().ObjectAmount > 0)
             {
                 BuildingObjects[CurrentObj].active = true;
                 BuildingObjects[CurrentObj].GetComponent<BuildingObj>().enablePreview = true;
             }
             else
             {
                 CurrentObj = 0;
                 Debug.Log ("Not Enough Objects");
             }
         }
     }
 
     public void ResetObjects()
     {
         foreach (Transform obj in BuildingObjects) 
         {
             obj.active = false;
         }
     }
 
     public void AddObjectAmount(int objIndex,int addAmount)
     {
         BuildingObjects [objIndex].GetComponent<BuildingObj> ().ObjectAmount += addAmount;
     }
 
     void OnGUI()
     {
         GUI.skin = GuiSkin;
         if (displayObjName == true && buildMod == true) 
         {
             string currentObjName = BuildingObjects[CurrentObj].GetComponent<BuildingObj>().ObjectName;
             GUI.Label (new Rect(20,20,250,30),currentObjName);
         }
     }
 }


and here is the error "AdvancedBuildingScript.cs(211,61): error CS1061: type 'UnityEngine.Transform' does not contain a definition for 'active' and no extension method 'active' of type 'UnityEngine.Transforms' could be found (are you missing a using directive or an assembly reference:)

How do i fix this error? "P.s I am awful at coding"

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image savlon · Jun 21, 2015 at 12:08 PM 0
Share

Change obj.active to obj.gameObject.SetActive (...) - reference here http://docs.unity3d.com/ScriptReference/GameObject.SetActive.html - look at more tutorials...

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

UNetWeaver error after update 0 Answers

Timer doesn't count 0 Answers

I keep getting the same error when installing Unity. Please Help! 0 Answers

Visual Studio Code doesn't work for with unity 2 Answers

CommandInvokationFailure: Gradle build failed 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges