コード例 #1
0
 /// <summary>
 /// Free all resources when the part is destroyed
 /// </summary>
 public void OnDestroy()
 {
     if (resourceSwitch != null)
     {
         resourceSwitch.removeResourceChangeListener(this);
         resourceSwitch = null;
     }
 }
コード例 #2
0
        /// <summary>
        /// Find the material and resource switch when started
        /// </summary>
        /// <param name="state">The startstate of the partmodule</param>
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            initSwitchableResources();

            Transform textureTransform = part.FindModelTransform(transformName);

            if (textureTransform != null)
            {
                material = textureTransform.GetComponent <Renderer>().material;
            }

            for (int i = 0; i < part.Modules.Count; i++)
            {
                if (part.Modules[i] is IConfigurableResourceModule)
                {
                    resourceSwitch = (IConfigurableResourceModule)part.Modules[i];
                    resourceSwitch.addResourceChangeListener(this);
                    break;
                }
            }
        }