示例#1
0
        private void SharedVariableGUI()
        {
            var           binding = (SingleTargetedBinding)target;
            List <string> keys;

            if (acceptedTypes.Length > 0)
            {
                keys = SharedVariableKeys.GetKeys(acceptedTypes);
            }
            else
            {
                keys = SharedVariableKeys.GetAllKeys();
            }

            var idx = keys.IndexOf(binding.targetVariableName);

            if (idx == -1)
            {
                idx = 0;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("TargetVariable");
            var newIdx = EditorGUILayout.Popup(idx, keys.ToArray());

            EditorGUILayout.EndHorizontal();

            binding.targetVariableName = keys[newIdx];
        }
示例#2
0
        void OnGUI()
        {
            if (folds == null)
            {
                folds = new Dictionary <string, bool>();
            }

            var keys      = SharedVariableKeys.GetAllSharedVariables();
            var noResults = true;

            search = EditorGUILayout.TextField("Search ", search);
            scroll = EditorGUILayout.BeginScrollView(scroll);

            foreach (var pair in keys)
            {
                var key   = pair.Key;
                var value = pair.Value;

                if (string.IsNullOrEmpty(search) == false &&
                    pair.Key.Contains(search) == false)
                {
                    continue;
                }

                if (folds.ContainsKey(key) == false)
                {
                    folds[key] = false;
                }

                folds[key] = EditorGUILayout.Foldout(folds[key], key);
                if (folds[key])
                {
                    EditorGUI.indentLevel++;
                    foreach (var prop in value.properties)
                    {
                        EditorGUILayout.LabelField(
                            " " + prop.DeclaringType.Name + "::" + prop.Name + " : " + prop.PropertyType.Name);
                    }
                    EditorGUI.indentLevel--;
                }

                noResults = false;
            }
            EditorGUILayout.EndScrollView();

            if (noResults)
            {
                EditorGUILayout.LabelField("No Results");
            }
        }
示例#3
0
        private void OnSharedVariable()
        {
            scroll = EditorGUILayout.BeginScrollView(scroll);
            foreach (var key in SharedVariableKeys.GetAllKeys())
            {
                var prev   = selectedVariableNames.Contains(key);
                var toggle = EditorGUILayout.ToggleLeft(key, prev);

                if (toggle && prev == false)
                {
                    selectedVariableNames.Add(key);
                }
                else if (toggle == false && prev == true)
                {
                    selectedVariableNames.Remove(key);
                }
            }
            EditorGUILayout.EndScrollView();

            var allObjects      = GameObject.FindObjectsOfTypeAll(typeof(GameObject));
            var selectedObjects = new List <UnityEngine.Object>();

            foreach (GameObject obj in allObjects)
            {
                var bindings = obj.GetComponents <SingleTargetedBinding>();
                if (bindings.Length == 0)
                {
                    continue;
                }

                foreach (var binding in bindings)
                {
                    if (binding.subscriptionType == SubscriptionType.SharedVariable &&
                        selectedVariableNames.Any(x => x == binding.targetVariableName))
                    {
                        selectedObjects.Add(obj);
                        break;
                    }
                }
            }

            Selection.objects = selectedObjects.ToArray();
        }