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 /
This question was closed Jul 19, 2014 at 07:04 AM by tanoshimi for the following reason:

Duplicate Question

avatar image
2
Question by Atreyal · Jul 19, 2014 at 07:02 AM · editorinspectorserializationnoobproperties

Showing properties from a base class in inspector?

Trying to show properties in the inspector of a base class on the child class of mine that I am making. So far The only things I can get to show are the private variables in the base class. I can see them if I enter debug on the inspector which is ok but not really what I am going for. Still new to this and have been searching for hours on google and the like trying to find an answer. Tried making a custom editor but I could not get that to work and I haven't messed around with the editor too much. Here is the code for the base class, just property declaration and constructors. The only items that pop up in inspector are Recharge delay flag and Reactivation counter.

 using UnityEngine;
 using System.Collections;
 using System.IO;
 [System.Serializable]
 
 public abstract class ShipComponent : MonoBehaviour
 {
     [SerializeField]
     public virtual int compHP {get;private set;}   //current component hit points
     protected int compEnergyRechargeRate {get;private set;} //set var on how fast this component recharges
     public int compEnergy{get;private set;} //duh
     protected string compName {get;private set;} //whats a name anyways??
     protected bool isDestroyed {get;private set;} //is this a useable component, or destroyed
     protected bool canUse {get;private set;} // is this an activatable component
     protected bool isShielded {get;private set;}//do we need to mitigate for shield damage or is this an unshielded component like a missile. Are shields on as well
     [SerializeField]
     protected string ownerName {get; private set;} //who does this belong to, useful so i can find a certain players component without getting every component in game.
     [SerializeField]
     protected abstract bool isRepairable {get;}//will this fix itself over time
     [SerializeField]
     protected abstract int maxHP {get;}
     [SerializeField]protected abstract int maxEnergy{get;}
     [SerializeField]
     protected abstract int compEnergyOnUse {get;} //how much energy this comp uses per activation
     [SerializeField]
     protected abstract int compEnergyContinuous {get;}// how much energy used after activated and continuously held down, useful for active shielding
     [SerializeField]
     private bool rechargeDelayFlag;
     protected float reactivationDelay {get;private set;}
     [SerializeField]
     private float reactivationCounter;
     
     protected ShipComponent(int compEnergyRechargeRate, bool canUse,string ownerName, float reactivationDelay)
     {
         this.compHP = this.maxHP;
         this.compEnergyRechargeRate = compEnergyRechargeRate;
         this.compEnergy = this.maxEnergy;
         this.isDestroyed = false;
         this.canUse = canUse;
         this.isShielded = false;
         this.ownerName = ownerName;
         this.rechargeDelayFlag = false;
         this.reactivationDelay = reactivationDelay;
     }


here is the code for the child class:

 using UnityEngine;
 using System.Collections;
 [System.Serializable]
 public class EngineScript : ShipComponent {
 
 public EngineScript() : base(0,true,"Roger",1.0f){}//contructor
         
     #region implemented abstract members of ShipComponent
     [SerializeField]
     protected override bool isRepairable 
     {get {return true;}}
     [SerializeField]
     protected override int maxHP 
     {get {return 100;}}
     [SerializeField]
     protected override int maxEnergy 
     {get {return 100;}}
     
     [SerializeField]protected override int compEnergyOnUse
     {get {return 0;}}
     
     protected override int compEnergyContinuous
      {get {    return 0;}}
 
     #endregion

 

I know it is a bit messy but been messing with it to try and figure it out but not having much luck. Anyone able to point me to my error?

Comment
Add comment · Show 3
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 Atreyal · Jul 19, 2014 at 01:20 AM 0
Share

hmm link didn't work but yes, my googlefu is not working on this question but ill see what I can find in the Wiki. TYV$$anonymous$$

avatar image Atreyal · Jul 19, 2014 at 01:36 AM 0
Share

Ah yep believe this is what I was looking for. Guess I just have to figure out how to make editor scripts work. TYVm much better example then what I found.

avatar image tanoshimi · Jul 19, 2014 at 07:05 AM 0
Share

Closing but +1 Lo0Nuhtik's comment/answer :)

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

If I have a bool method, how can I see in the inspector whether it returns true or false? 2 Answers

Custom Inspector. Aligning properties? 1 Answer

Populating list of custom class through inspector 1 Answer

Why can't a MonoBehaviour subtype with generic arguments be serialized in a list since Unity 4.5? 0 Answers

Saving editor-only variables 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