Exemple #1
0
        void OnGUI()
        {
            _repository = _repository ?? new ComponentRepository();

            GUILayout.BeginHorizontal();
            GUILayout.Label("生成コードの名前空間");
            _repository.ForwarderNamespace = GUILayout.TextField(_repository.ForwarderNamespace);
            GUILayout.EndHorizontal();

            if (GUILayout.Button("チェックが入った型の転送コンポーネントを生成する"))
            {
                _repository.GenerateForwarder();
                AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                _repository = null;
            }

            _currentSceneScroll = GUILayout.BeginScrollView(_currentSceneScroll);

            foreach (var c in _repository.DllComponents)
            {
                if (!c.HasForwarder)
                {
                    c.IsChecked = GUILayout.Toggle(c.IsChecked, c.DllType.Name);
                }
                else
                {
                    GUILayout.Label("(済) " + c.DllType.Name);
                }
            }

            GUILayout.EndScrollView();
        }
Exemple #2
0
        /// <summary>
        /// プロジェクト中の全プレハブを取得。
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <PrefabInfo> GetAllPrefabs(ComponentRepository repository)
        {
            var prefabPaths = AssetDatabase.GetAllAssetPaths().Where(x => x.EndsWith(".prefab"));

            foreach (var path in prefabPaths)
            {
                yield return(new PrefabInfo(path, repository));
            }
        }
        void OnGUI()
        {
            if (_objects == null || _repository == null)
            {
                _repository         = new ComponentRepository();
                _currentSceneScroll = Vector2.zero;
                _objects            = ForwardingGameObjectInfo.FromCurrentScene(_repository);
            }

            if (GUILayout.Button("転送"))
            {
                _objects.Forward();
                _objects = null;
                return;
            }

            GUILayout.Label("このシーン中のコンポーネントの転送の可否:");
            _currentSceneScroll = GUILayout.BeginScrollView(_currentSceneScroll);

            foreach (var obj in _objects)
            {
                if (!obj.DllComponents.Any())
                {
                    continue;
                }

                var message = obj.DllComponents.All(x => x.HasForwarder)
                    ? "転送可能"
                    : "不可";

                GUILayout.BeginHorizontal();
                GUILayout.Label(obj.Target.name, _width100);
                GUILayout.Label(message);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("", _width100);
                var valid = string.Join(", ", obj.DllComponents.Where(x => x.HasForwarder).Select(x => x.DllType.Name).ToArray());
                GUILayout.Label("可能: " + valid);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("", _width100);
                var invalid = string.Join(", ", obj.DllComponents.Where(x => !x.HasForwarder).Select(x => x.DllType.Name).ToArray());
                GUILayout.Label("不可: " + invalid);
                GUILayout.EndHorizontal();

                GUILayout.Space(4);
            }

            GUILayout.EndScrollView();
        }
Exemple #4
0
 void OnLostFocus()
 {
     _repository = null;
     _objects    = null;
 }
Exemple #5
0
 void OnProjectChange()
 {
     _repository = null;
     _objects    = null;
 }
Exemple #6
0
 void OnLostFocus()
 {
     _repository = null;
 }
Exemple #7
0
 public PrefabInfo(string prefabPath, ComponentRepository repository)
 {
     _prefabRoot = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);
     _repository = repository;
 }
Exemple #8
0
        private static IEnumerable <ForwardingGameObjectInfo> FromCurrentSceneInternal(ComponentRepository repo)
        {
            var transforms = Object.FindObjectsOfType <Transform>();

            foreach (var t in transforms)
            {
                yield return(new ForwardingGameObjectInfo(t.gameObject, repo));
            }
        }
Exemple #9
0
 /// <summary>
 /// 現在開いているシーン中の全オブジェクトから
 /// </summary>
 /// <param name="repo"></param>
 /// <returns></returns>
 public static IEnumerable <ForwardingGameObjectInfo> FromCurrentScene(ComponentRepository repo)
 {
     return(FromCurrentSceneInternal(repo).ToArray());
 }
Exemple #10
0
        private static IEnumerable <ForwardingCompomentInfo> GetDllComponents(GameObject go, ComponentRepository repo)
        {
            foreach (var c in go.GetComponents <Component>())
            {
                if (c == null)
                {
                    continue;
                }

                var ct = c.GetType();
                var ci = repo.Find(ct);
                if (ci != null)
                {
                    yield return(ci);
                }
            }
        }
Exemple #11
0
 public ForwardingGameObjectInfo(GameObject target, ComponentRepository repo)
 {
     Target        = target;
     DllComponents = GetDllComponents(target, repo).ToArray();
 }
Exemple #12
0
 void OnLostFocus()
 {
     _repository = null;
     _prefabs    = null;
 }
Exemple #13
0
 void OnProjectChange()
 {
     _repository = null;
     _prefabs    = null;
 }
Exemple #14
0
 void OnHierarchyChange()
 {
     _repository = null;
     _prefabs    = null;
 }
 void OnHierarchyChange()
 {
     _repository = null;
     _objects    = null;
 }