예제 #1
0
        private static void     RemoveType()
        {
            if (DragObjectDrawer.initialDictionary == null)
            {
                DragObjectDrawer.InitializeInitialDictionaries();
            }

            Selection.selectionChanged -= DragObjectDrawer.OnSelectionChanged;
            DragObjectDrawer.s_DrawerTypeForType.SetValue(null, DragObjectDrawer.initialDictionary);
            DragObjectDrawer.UpdateInspector();
        }
예제 #2
0
        private static void     AddType()
        {
            if (DragObjectDrawer.overridenDictionary == null)
            {
                DragObjectDrawer.InitializeDragDictionaries();
            }

            Selection.selectionChanged += DragObjectDrawer.OnSelectionChanged;
            DragObjectDrawer.s_DrawerTypeForType.SetValue(null, DragObjectDrawer.overridenDictionary);
            DragObjectDrawer.UpdateInspector();
        }
예제 #3
0
        private static void     OnGUISettings()
        {
            if (HQ.Settings == null)
            {
                return;
            }

            if (DragObjectDrawer.ScriptAttributeUtility == null)
            {
                EditorGUILayout.HelpBox("NG Tools has detected a change in Unity code. Please contact the author.", MessageType.Error);

                if (GUILayout.Button("Contact the author") == true)
                {
                    ContactFormWizard.Open(ContactFormWizard.Subject.BugReport, "DragObjectDrawer is incompatible with " + Utility.UnityVersion + ".");
                }
                return;
            }

            DraggableObjectSettings settings = HQ.Settings.Get <DraggableObjectSettings>();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Allows to drag & drop between Object fields in Inspector.", GeneralStyles.WrapLabel);
            bool active = EditorGUILayout.Toggle("Drag & Drop with Object", settings.active);

            if (EditorGUI.EndChangeCheck() == true)
            {
                HQ.InvalidateSettings();

                if (active == true)
                {
                    DragObjectDrawer.AddType();
                }
                else
                {
                    DragObjectDrawer.RemoveType();
                }

                settings.active = active;
            }
        }
예제 #4
0
        static DragObjectDrawer()
        {
            if (DragObjectDrawer.ScriptAttributeUtility != null)
            {
                DragObjectDrawer.s_DrawerTypeForType = UnityAssemblyVerifier.TryGetField(DragObjectDrawer.ScriptAttributeUtility, "s_DrawerTypeForType", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                DragObjectDrawer.BuildDrawerTypeForTypeDictionary = UnityAssemblyVerifier.TryGetMethod(DragObjectDrawer.ScriptAttributeUtility, "BuildDrawerTypeForTypeDictionary", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                DragObjectDrawer.DrawerKeySet = UnityAssemblyVerifier.TryGetNestedType(DragObjectDrawer.ScriptAttributeUtility, "DrawerKeySet", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

                if (DragObjectDrawer.DrawerKeySet != null)
                {
                    DragObjectDrawer.drawer = UnityAssemblyVerifier.TryGetField(DragObjectDrawer.DrawerKeySet, "drawer", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                    DragObjectDrawer.type   = UnityAssemblyVerifier.TryGetField(DragObjectDrawer.DrawerKeySet, "type", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                }

                if (DragObjectDrawer.s_DrawerTypeForType == null ||
                    DragObjectDrawer.BuildDrawerTypeForTypeDictionary == null ||
                    DragObjectDrawer.DrawerKeySet == null ||
                    DragObjectDrawer.drawer == null ||
                    DragObjectDrawer.type == null)
                {
                    DragObjectDrawer.ScriptAttributeUtility = null;
                }
            }

            HQ.SettingsChanged += () =>
            {
                if (HQ.Settings == null)
                {
                    return;
                }

                if (HQ.Settings.Get <DraggableObjectSettings>().active == true)
                {
                    DragObjectDrawer.AddType();
                }
                else
                {
                    DragObjectDrawer.RemoveType();
                }
            };
        }