//--------------------------------------------------------------------------------------------/ // Methods //--------------------------------------------------------------------------------------------/ /// <summary> /// Adds the extension to this behaviour /// </summary> /// <param name="extension"></param> public void Add(IExtensionBehaviour extension) { MonoBehaviour behaviour = (MonoBehaviour)extension; behaviour.hideFlags = ExtensibleBehaviour.extensionFlags; extensionBehaviours.Add(behaviour); }
private void AddExtension(int extensionTypeIndex) { Type extensionType = extensionTypes[extensionTypeIndex]; IExtensionBehaviour extension = target.gameObject.AddComponent(extensionType) as IExtensionBehaviour; if (extension == null) { StratusDebug.Error($"Failed to construct extension of type {extensionType.Name}"); return; } StratusDebug.Log($"Adding extension {extensionType.Name}"); target.Add(extension); Undo.RecordObject(target, extensionType.Name); serializedObject.ApplyModifiedProperties(); this.SetExtensionIndex(); this.RefreshExtensions(); }
/// Retrieves the extensible that the extension is for /// </summary> /// <typeparam name="T"></typeparam> /// <param name="extension"></param> /// <returns></returns> public static T GetExtensible <T>(IExtensionBehaviour extension) where T : ExtensibleBehaviour { return(extensionOwnershipMap[extension] as T); }
/// <summary> /// Retrieves the extension of the given type, if its present /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public bool HasExtension(IExtensionBehaviour behaviour) { return(this.extensionBehaviours.Contains((MonoBehaviour)behaviour)); //return this.HasExtension(behaviour.GetType()); }