示例#1
0
    private UiMonoWithMethods GenerateButtonInformation(TargetManagerMonoWithNameAndMethods mono, GameObject incTarget = null, string source = "")
    {
        GameObject target = null;

        if (incTarget != null)
        {
            target = incTarget;
        }
        else
        {
            target = this.target;
        }

        if (target == null)
        {
            Debug.Log("GenButtons No Target!");
            return(null);
        }

        var result = new UiMonoWithMethods
        {
            MonoName = mono.Name,
            Object   = target,
            Methods  = mono.Methods.Select(y => new UiMethodNameWithParameters
            {
                Name       = y.Name,
                Parameters = y.Parameters,
            }).ToArray(),
            Source = source,
        };

        return(result);
    }
示例#2
0
    /// <summary>
    /// Registers new monos as well as changes to previous monos and creates
    /// the interface necessary for said mono.
    /// </summary>
    public void RegisterNewOrChangedMono(UiMonoWithMethods monoData)
    {
        var target = monoData.Object;

        /// If new target set up the data structure for it.
        if (!this.monosPerObjectData.ContainsKey(target))
        {
            this.monosPerObjectData[target] = new List <UiMonoGroupInformation>();
        }

        var listOfMonoData = this.monosPerObjectData[target];

        /// If we already have data with the same mono name, destroy it.
        if (listOfMonoData.Any(x => x.MonoName == monoData.MonoName))
        {
            this.RemoveDestroyedMono(target, monoData.MonoName, false);
        }

        /// Creates the inteface as well as meta data.
        var createResult = this.CreateScriptUI(monoData.MonoName, monoData.Methods);

        ///All the data we need to visualise the UI
        var monoGroup = new UiMonoGroupInformation
        {
            MonoName        = monoData.MonoName,
            WholeHeight     = createResult.FinalHeight,
            Methods         = createResult.Parent,
            MonoButtonLabel = createResult.ButtonLabel,
            Collapsed       = false,
            CollapsedHeight = createResult.CollapsedHeight,
            GrandParent     = createResult.GrandParent,
            Source          = monoData.Source,
        };

        /// Setting up the mono name label to be able to callapse and expand the method
        createResult.LabelButtonScritp.SetUp(monoGroup, this);

        /// Storing the resulting UI data
        listOfMonoData.Add(monoGroup);

        /// If the new UI ifromation is for current target - display the updated version
        if (this.currentTarget != null && this.currentTarget == target)
        {
            this.DisplayInterfaceForTarger(target);
        }
    }