Пример #1
0
        public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawer.BeginProperty(position, property, label);

            VehicleModule =
                SerializedPropertyHelper.GetTargetObjectOfProperty(drawer.serializedProperty) as VehicleModule;
            if (VehicleModule == null)
            {
                Debug.LogError(
                    "VehicleModule is not a target object of ModuleDrawer. Make sure all modules inherit from VehicleModule.");
                drawer.EndProperty();
                return(false);
            }


            bool expanded = drawer.Header(VehicleModule.GetType().Name);

            if (Application.isPlaying && VehicleModule.VehicleController != null)
            {
                if (VehicleModule.VehicleController.stateSettings != null)
                {
                    DrawStateSettingsBar(
                        position,
                        VehicleModule.VehicleController.stateSettings.LODs.Count,
                        drawer.FindProperty("state.isOn"),
                        drawer.FindProperty("state.isEnabled"),
                        drawer.FindProperty("state.lodIndex"));
                }
            }

            return(expanded);
        }
Пример #2
0
        /// <summary>
        ///     Adds a module to the game object. Equivalent to using AddComponent followed by UpdateModulesList().
        ///     Can be called only in play mode, after the vehicle has been initialized.
        /// </summary>
        public TM AddModule <TW, TM>()
            where TW : ModuleWrapper
            where TM : VehicleModule
        {
            if (vc == null)
            {
                return(null);
            }

            VehicleModule module = vc.gameObject.AddComponent <TW>().GetModule();

            modules.Add(module);
            return(module as TM);
        }
Пример #3
0
 /// <summary>
 ///     Sets wrapper's module.
 /// </summary>
 /// <param name="vehicleModule"></param>
 public abstract void SetModule(VehicleModule vehicleModule);