Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Thanish-ahmed · Aug 30, 2016 at 03:00 PM · c#destroypermanent

how to destroy object permanantly throught c#

Im creating a button in my game where the player is able to subscribe my YouTube channel and earn coins. So when i click on the the subscribe button and i earn coins but when i restart the scene, The subscribe button in the game appears again. The subscribe button is supposed to be clicked once because the player can only subscribe my channel once. So basically i want to call a function and say the object should destroy permantly and must save.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by etaxi341 · Aug 30, 2016 at 03:14 PM

I would recommend you to check if the guy is subscribed to your channel and only if not enable the gameobject.

Or another method could be that you save in the PlayerPrefs a bool when the button has been pressed. When this bool is true the button is not there.

You can just hide the button by adding a script to it which checks OnEnable if the bool is true and then set the Gameobject Inactive

Comment
Add comment · Show 2 · Share
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 Thanish-ahmed · Aug 30, 2016 at 04:45 PM 0
Share

Thanks for your quick reply. I understand the logic but I don't know how to code. Would you please help me with the code as I'm new to coding. It would be a great help! @etaxi341

avatar image etaxi341 Thanish-ahmed · Aug 30, 2016 at 05:42 PM 0
Share

Ok so I will show you how to do it with PlayerPrefs :) So first the ClickButton method gets called when you press the Button (You have to set it to the button by yourself)

The Start $$anonymous$$ethod wil be called when the Object should be loaded. While loading the Object it will check if the button was clicked already. if yes then hide the gameobject.

 void ClickButton()
 {
 PlayerPrefs.setInt("clickedYoutube", 1);
 PlayerPrefs.Save();
 //And here open your youtube
 
 HideButton();
 }
 
 void Start()
 {
 HideButton();
 }
 
 void HideButton()
 {
 if (PlayerPrefs.getInt("clickedYoutube") == 1)
 gameObject.enabled = false; // This disables the gameobject if the player already clicked once at the button.
 }
avatar image
0

Answer by trevorchico · Aug 31, 2016 at 05:40 AM

http://answers.unity3d.com/questions/726178/how-do-i-use-playerprefs-to-save-my-score.html

PlayerPrefs will be the easiest, you can find example code on the unity forums like this one^

Comment
Add comment · Show 1 · Share
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 Thanish-ahmed · Aug 31, 2016 at 07:58 AM 0
Share

Thanks for your reply! As I said, I'm new to coding. Would you $$anonymous$$d completing the code for me with the load level code above! This is a great help as I'm in the final stage of publishing my game!

@trevorchico

avatar image
0

Answer by Thanish-ahmed · Aug 31, 2016 at 07:54 AM

Hey, I really appreciate your work, But things dont seem to be good. I have attached my code below ( Load URL CODE). Currently im having a button and when i click the button the url opens successfully. Please combine your code with mine and reply. Thanks!

using UnityEngine;

namespace Zigzag {

 public class ZIRLoadLevel : MonoBehaviour
 {


     public void LoadURL(string urlName)
     {
         Application.OpenURL(urlName);
     }
     


     
 }

}

@etaxi341

Comment
Add comment · Share
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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Destroy an enemy without destroying the player 1 Answer

Help with Spawning & Destroying Background Objects in 2D 2 Answers

Instantiating Objects 1 Answer


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