microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Make classes more extendable #7

Closed floAr closed 8 years ago

floAr commented 8 years ago

Scenarios: Gina is a developer. She wants to extend the GazeManager to provide a property for a field directly in front of the users gaze. Desired code

40         private Vector3 gazeOrigin; 
41         private Vector3 gazeDirection; 
40         public Vector3 AheadOfGaze{ get { return gazeOrigin+gazeDirection; } }

Problem:

  1. By changing the GazeManager Gina needs to propagate this change to all customers using her scripts.
  2. Changing parts of the HoloToolkit itself locks Gina out from future updates and requires clients to change their HoloToolkit too (removing the 'drop-in-and-run' factor)

Proposed solution: Make classes partial. Partial classes allow Gina to extend them using her own scripts and export her packages as a drop in component working on top of the base toolkit. In GinaGazeManager.cs:

public partial class GazeManager{
 public Vector3 AheadOfGaze{ get { return gazeOrigin+gazeDirection; } }
}
NeerajW commented 8 years ago

@floAr thank you for filing this issue and the great suggestion around making these classes partial. The HoloToolkit moderators will triage the issues and get back to you with some suggestions.

NeerajW commented 8 years ago

@floAr this seems like a good addition. Would you like to do this work? If yes, we recommend waiting for the refactor branch work to finish and then work on this.

floAr commented 8 years ago

@NeerajW Yep, you can assign it to me