Example #1
0
        private void DoMethodCall()
        {
            if (className == null || string.IsNullOrEmpty(className.Value))
            {
                Finish();
                return;
            }

            if (cachedClassName != className.Value || cachedMethodName != methodName.Value)
            {
                errorString = string.Empty;
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }

            object result = null;

            if (cachedParameterInfo.Length == 0)
            {
                result = cachedMethodInfo.Invoke(null, null);
            }
            else
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    var parameter = parameters[i];
                    parameter.UpdateValue();
                    parametersArray[i] = parameter.GetValue();
                }

                result = cachedMethodInfo.Invoke(null, parametersArray);
            }

            if (!storeResult.IsNone)
            {
                storeResult.SetValue(result);
            }

                        #if UNITY_EDITOR
            if (debug || LinkerData.DebugAll)
            {
                UnityEngine.Debug.Log("<Color=blue>CallStaticMethod</Color> on " + this.Fsm.GameObjectName + ":" + this.Fsm.Name + "\n" +
                                      "<Color=red>TargetType</Color>\t\t" + cachedType + "\n" +
                                      "<Color=red>Assembly</Color>\t\t" + cachedType.Assembly.FullName + "\n" +
                                      "<Color=red>Method</Color>\t\t\t" + cachedMethodInfo.Name + "\n");

                LinkerData.RegisterClassDependancy(cachedType, cachedType.ToString());
            }
                        #endif
        }
Example #2
0
        public override void OnEnter()
        {
            targetProperty.GetValue();

                        #if UNITY_EDITOR
            if (debug || LinkerData.DebugAll)
            {
                UnityEngine.Debug.Log("<Color=blue>GetProperty</Color> on " + this.Fsm.GameObjectName + ":" + this.Fsm.Name + "\n" +
                                      "<Color=red>TargetType</Color>\t\t" + targetProperty.TargetTypeName + "\n" +
                                      "<Color=red>Assembly</Color>\t\t" + targetProperty.TargetType.Assembly.FullName + "\n" +
                                      "<Color=red>Property</Color>\t\t\t" + targetProperty.PropertyName + " <" + targetProperty.PropertyType + ">\n");

                LinkerData.RegisterClassDependancy(targetProperty.TargetType, targetProperty.TargetTypeName);
            }
                        #endif

            if (!everyFrame)
            {
                Finish();
            }
        }
Example #3
0
        public override void OnEnter()
        {
            parametersArray = new object[parameters.Length];

            DoMethodCall();

                        #if UNITY_EDITOR
            if (debug || LinkerData.DebugAll)
            {
                UnityEngine.Debug.Log("<Color=blue>CallMethod</Color> on " + this.Fsm.GameObjectName + ":" + this.Fsm.Name + "\n" +
                                      "<Color=red>TargetType</Color>\t\t" + cachedType + "\n" +
                                      "<Color=red>Assembly</Color>\t\t" + cachedType.Assembly.FullName + "\n" +
                                      "<Color=red>Method</Color>\t\t\t" + cachedMethodInfo.Name + "\n");

                LinkerData.RegisterClassDependancy(cachedType, cachedType.ToString());
            }
                        #endif

            if (!everyFrame)
            {
                Finish();
            }
        }
Example #4
0
        void DoInvokeMethod(GameObject go)
        {
            if (go == null)
            {
                return;
            }

            component = go.GetComponent(ReflectionUtils.GetGlobalType(behaviour.Value)) as MonoBehaviour;

            if (component == null)
            {
                LogWarning("InvokeMethod: " + go.name + " missing behaviour: " + behaviour.Value);
                return;
            }

            if (repeating.Value)
            {
                component.InvokeRepeating(methodName.Value, delay.Value, repeatDelay.Value);
            }
            else
            {
                component.Invoke(methodName.Value, delay.Value);
            }

                        #if UNITY_EDITOR
            if (debug || LinkerData.DebugAll)
            {
                UnityEngine.Debug.Log("<Color=blue>InvokeMethod</Color> on " + this.Fsm.GameObjectName + ":" + this.Fsm.Name + "\n" +
                                      "<Color=red>TargetType</Color>\t\t" + component.GetType() + "\n" +
                                      "<Color=red>Assembly</Color>\t\t" + component.GetType().Assembly.FullName + "\n" +
                                      "<Color=red>Method</Color>\t\t\t" + methodName.Value + "\n");

                LinkerData.RegisterClassDependancy(component.GetType(), component.GetType().ToString());
            }
                        #endif
        }
Example #5
0
    public override void OnInspectorGUI()
    {
        LinkerData _target = target as LinkerData;

        FsmEditorStyles.Init();

        //GUILayout.Box("Hello",FsmEditorStyles.LargeTitleWithLogo,GUILayout.Height(42f));
        GUI.Box(new Rect(0f, 0f, Screen.width, 42f), "Linker Wizard", FsmEditorStyles.LargeTitleWithLogo);


        GUILayout.Label("1: Make sure you installed them actions");

        if (GUILayout.Button("Install Actions"))
        {
            Debug.Log("importing package " + Application.dataPath + "/" + ActionsPackagePath);

            AssetDatabase.ImportPackage(Application.dataPath + "/" + ActionsPackagePath, true);
        }


        GUILayout.Label("2: Check 'debug' for tracking all reflections");

        EditorGUI.indentLevel++;
        bool _debug = EditorGUILayout.Toggle("Debug", _target.debug);

        EditorGUI.indentLevel--;
        if (_debug != _target.debug)
        {
            _target.debug = _debug;
            EditorUtility.SetDirty(_target);
        }

        GUILayout.Label("3: Run your scenes from start to finish");
        GUILayout.Label("   Check the preview below for usages as they come ");

        if (_target.linkerEntries.Count > 0)
        {
            GUILayout.Label("4: Update Linker xml file");
            if (GUILayout.Button("Update Linker content"))
            {
                UpdateLinkerContent(_target);
                GUIUtility.ExitGUI();
            }
            if (_target.LinkContentUpdateDone)
            {
                GUILayout.Label("5: You can now publish and test on device");
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Ping link.xml"))
                {
                    EditorGUIUtility.PingObject(_target.Asset);
                }
                if (GUILayout.Button("Select link.xml"))
                {
                    Selection.activeObject = _target.Asset;
                    EditorGUIUtility.PingObject(_target.Asset);
                }
                GUILayout.EndHorizontal();
            }
        }


        GUILayout.BeginHorizontal(GUILayout.Height(25));
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        FsmEditorGUILayout.Divider();
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();
        GUILayout.Label("preview", GUILayout.ExpandWidth(false));
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        FsmEditorGUILayout.Divider();
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();


        foreach (KeyValuePair <string, List <string> > entry in _target.linkerEntries)
        {
            GUILayout.Label(entry.Key);
            foreach (string _item in entry.Value)
            {
                GUILayout.Label("    " + _item);
            }
        }
    }
Example #6
0
    public void UpdateLinkerContent(LinkerData _target)
    {
        _target.LinkContentUpdateDone = false;

        _target.Asset = PlayMakerEditorUtils.GetAssetByName("link.xml") as TextAsset;

        string _assetPath = Application.dataPath + "/link.xml";


        // create xml doc
        XmlDocument _doc = new XmlDocument();

        XmlNode _rootNode;

        if (_target.Asset != null)
        {
            _assetPath = AssetDatabase.GetAssetPath(_target.Asset);
            _doc.LoadXml(_target.Asset.text);
            _rootNode = _doc.SelectSingleNode("linker");
        }
        else
        {
            _rootNode = _doc.CreateNode(XmlNodeType.Element, "linker", null);
            _doc.AppendChild(_rootNode);
        }

        if (_rootNode == null)
        {
            Debug.LogError("Link.xml seems to be badly formatted");
            return;
        }

        foreach (KeyValuePair <string, List <string> > entry in _target.linkerEntries)
        {
            string assemblyName = entry.Key;

            XmlNode _assemblyNode = _doc.SelectSingleNode("//assembly[@fullname='" + assemblyName + "']");
            if (_assemblyNode == null)
            {
                _assemblyNode = _doc.CreateNode(XmlNodeType.Element, "assembly", null);
                _rootNode.AppendChild(_assemblyNode);

                XmlAttribute _fullnameAttr = _doc.CreateAttribute("fullname");
                _fullnameAttr.Value = assemblyName;
                _assemblyNode.Attributes.Append(_fullnameAttr);
            }

            foreach (string _type in entry.Value)
            {
                XmlNode _typeNode = _assemblyNode.SelectSingleNode("./type[@fullname='" + _type + "']");
                if (_typeNode == null)
                {
                    _typeNode = _doc.CreateNode(XmlNodeType.Element, "type", null);
                    _assemblyNode.AppendChild(_typeNode);

                    XmlAttribute _fullnameAttr = _doc.CreateAttribute("fullname");
                    _fullnameAttr.Value = _type;
                    _typeNode.Attributes.Append(_fullnameAttr);

                    XmlAttribute _preserveAttr = _doc.CreateAttribute("preserve");
                    _preserveAttr.Value = "all";
                    _typeNode.Attributes.Append(_preserveAttr);
                }
            }
        }

        Debug.Log("Updated and Saving linker xml content to : " + _assetPath);
        _doc.Save(_assetPath);

        AssetDatabase.Refresh();
        EditorUtility.FocusProjectWindow();
        _target.Asset = AssetDatabase.LoadAssetAtPath(_assetPath, typeof(TextAsset)) as TextAsset;

        _target.LinkContentUpdateDone = true;
    }