Exemple #1
0
        /** ********************************************************************************
        * @summary オブジェクトのメンバの数値を設定
        ***********************************************************************************/
        public static void SetModuleValue(object particleSystemModule, ModuleCopyPasteBase moduleCopyPasteBase)
        {
            var flag = BindingFlags.Instance
                       | BindingFlags.Public
                       | BindingFlags.NonPublic
                       | BindingFlags.DeclaredOnly;

            MemberValue[] memberValues       = moduleCopyPasteBase.GetMemberValues().ToArray();
            var           particleModuleType = particleSystemModule.GetType();

            for (var index = 0; index < memberValues.Length; index++)
            {
                var value = memberValues.ElementAt(index).Value;
                switch (memberValues[index].MemberType)
                {
                case MemberTypes.Property:
                {
                    var prop = particleModuleType.GetProperty(memberValues[index].MemberName, flag);
                    if (prop != null && prop.CanWrite)
                    {
                        prop.SetValue(particleSystemModule, value);
                    }
                    break;
                }

                case MemberTypes.Field:
                {
                    var field = particleModuleType.GetField(memberValues[index].MemberName, flag);
                    field?.SetValue(particleSystemModule, value);
                    break;
                }
                }
            }
        }
 private void CreateModuleData()
 {
     moduleDataArray = moduleDataArray ?? new ModuleCopyPasteBase[System.Enum.GetNames(typeof(ModuleType)).Length];
     moduleDataArray = new ModuleCopyPasteBase[]
     {
         ModuleCopyPasteBase.Create(ModuleType.Main),
         ModuleCopyPasteBase.Create(ModuleType.Emission),
         ModuleCopyPasteBase.Create(ModuleType.Shape),
         ModuleCopyPasteBase.Create(ModuleType.VelocityOverLifetime),
         ModuleCopyPasteBase.Create(ModuleType.LimitVelocityOverLifetime),
         ModuleCopyPasteBase.Create(ModuleType.InheritVelocity),
         ModuleCopyPasteBase.Create(ModuleType.ForceOverLifetime),
         ModuleCopyPasteBase.Create(ModuleType.ColorOverLifetime),
         ModuleCopyPasteBase.Create(ModuleType.ColorBySpeed),
         ModuleCopyPasteBase.Create(ModuleType.SizeOverLifetime),
         ModuleCopyPasteBase.Create(ModuleType.SizeBySpeed),
         ModuleCopyPasteBase.Create(ModuleType.RotationOverLifetime),
         ModuleCopyPasteBase.Create(ModuleType.RotationBySpeed),
         ModuleCopyPasteBase.Create(ModuleType.ExternalForces),
         ModuleCopyPasteBase.Create(ModuleType.Noise),
         ModuleCopyPasteBase.Create(ModuleType.Collision),
         ModuleCopyPasteBase.Create(ModuleType.Triggers),
         ModuleCopyPasteBase.Create(ModuleType.SubEmitters),
         ModuleCopyPasteBase.Create(ModuleType.TextureSheetAnimation),
         ModuleCopyPasteBase.Create(ModuleType.Lights),
         ModuleCopyPasteBase.Create(ModuleType.Trails),
         ModuleCopyPasteBase.Create(ModuleType.CustomData),
         ModuleCopyPasteBase.Create(ModuleType.Renderer),
     };
 }
Exemple #3
0
        /** ********************************************************************************
        * @summary 情報の表示
        ***********************************************************************************/
        private void DrawClipboardBox()
        {
            using (new EditorGUILayout.VerticalScope(Config.BoxClipboardOption))
            {
                EditorGUILayout.LabelField("■ Clipboard");
                clipboardScrollPos = EditorGUILayout.BeginScrollView((clipboardScrollPos));

                foreach (var moduleType in Config.TargetModules)
                {
                    ModuleCopyPasteBase moduleData = copyPaste.GetModule(moduleType);
                    CustomUI.DrawModule(moduleData);
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndScrollView();
            }
        }
Exemple #4
0
        /** ********************************************************************************
        * @summary モジュール別 Copy/Pasteボタンの描画
        ***********************************************************************************/
        private void DrawModuleCopyPaste(ModuleType moduleType)
        {
            using (new EditorGUILayout.HorizontalScope(GUI.skin.box))
            {
                ModuleCopyPasteBase module = copyPaste.GetModule(moduleType);
                module.IsToggle = EditorGUILayout.ToggleLeft($"■ {moduleType}", module.IsToggle);  // チェックボックス
                // EditorGUILayout.LabelField($"■ {moduleType}", Config.LabelCopyPasteOption); // モジュール名
                EditorGUI.BeginDisabledGroup(true);

                // EditorGUILayout.TextField($"{module.CopyNameStamp}", GUILayout.ExpandWidth(true));
                EditorGUILayout.TextField($"{module.CopyNameStamp}", Config.TextCopyNameOption); // コピー情報の表示
                EditorGUI.EndDisabledGroup();

                // ペーストボタン
                if (GUILayout.Button("Paste", Config.ButtonStyle, Config.ButtonOption))
                {
                    var ps = Selection.activeGameObject.GetComponent <ParticleSystem>();

                    // Undo登録
                    Undo.RegisterCompleteObjectUndo(ps.gameObject, "Paste ParticleSystem Module");

                    if (ps == null)
                    {
                        return;
                    }

                    bool needRestart = ps.gameObject.activeSelf;
                    if (needRestart)
                    {
                        ps.gameObject.SetActive(false);
                    }

                    copyPaste.Paste(ps, moduleType);
                    EditorSceneManager.MarkSceneDirty(ps.gameObject.scene);

                    if (needRestart)
                    {
                        ps.gameObject.SetActive(true);
                        ps.Play();
                    }

                    Debug.Log($"Paste : {moduleType}");
                }
            }
        }
Exemple #5
0
        public static void DrawModule(ModuleCopyPasteBase module)
        {
            using (new EditorGUILayout.VerticalScope(Config.BoxClipboardModuleOption))
            {
                using (new EditorGUILayout.VerticalScope(GUI.skin.box))
                {
                    if (module.HasValue)
                    {
                        module.IsOpen = EditorGUILayout.Foldout(module.IsOpen, $"{module.ModuleType}");

                        if (module.IsOpen)
                        {
                            EditorGUI.indentLevel++;
                            foreach (var member in module.GetMemberValues())
                            {
                                DrawMember(member);
                            }

                            var internalValues = module.GetInternalValues();
                            if (internalValues != null)
                            {
                                foreach (var value in internalValues)
                                {
                                    using (new EditorGUILayout.HorizontalScope())
                                    {
                                        EditorGUILayout.TextArea(value.ToString());
                                    }
                                }
                            }

                            EditorGUI.indentLevel--;
                        }
                        // EditorGUI.EndDisabledGroup();
                    }
                }

            }
        }
        public static ModuleCopyPasteBase Create(ModuleType moduleType)
        {
            ModuleCopyPasteBase instance = null;

            switch (moduleType)
            {
            case ModuleType.Main:
                instance = new ModuleCopyPasteBaseMain();
                break;

            case ModuleType.Emission:
                instance = new ModuleCopyPasteBaseEmission();
                break;

            case ModuleType.Shape:
                instance = new ModuleCopyPasteBaseShape();
                break;

            case ModuleType.VelocityOverLifetime:
                instance = new ModuleCopyPasteBaseVelocityOverLifetime();
                break;

            case ModuleType.LimitVelocityOverLifetime:
                instance = new ModuleCopyPasteBaseLimitVelocityOverLifetime();
                break;

            case ModuleType.InheritVelocity:
                instance = new ModuleCopyPasteBaseInheritVelocity();
                break;

            case ModuleType.ForceOverLifetime:
                instance = new ModuleCopyPasteBaseForceOverLifetime();
                break;

            case ModuleType.ColorOverLifetime:
                instance = new ModuleCopyPasteBaseColorOverLifetime();
                break;

            case ModuleType.ColorBySpeed:
                instance = new ModuleCopyPasteBaseColorBySpeed();
                break;

            case ModuleType.SizeOverLifetime:
                instance = new ModuleCopyPasteBaseSizeOverLifetime();
                break;

            case ModuleType.SizeBySpeed:
                instance = new ModuleCopyPasteBaseSizeBySpeed();
                break;

            case ModuleType.RotationOverLifetime:
                instance = new ModuleCopyPasteBaseRotationOverLifetime();
                break;

            case ModuleType.RotationBySpeed:
                instance = new ModuleCopyPasteBaseRotationBySpeed();
                break;

            case ModuleType.ExternalForces:
                instance = new ModuleCopyPasteBaseExternalForces();
                break;

            case ModuleType.Noise:
                instance = new ModuleCopyPasteBaseNoise();
                break;

            case ModuleType.Collision:
                instance = new ModuleCopyPasteBaseCollision();
                break;

            case ModuleType.Triggers:
                instance = new ModuleCopyPasteBaseTriggers();
                break;

            case ModuleType.SubEmitters:
                instance = new ModuleCopyPasteBaseSubEmitters();
                break;

            case ModuleType.TextureSheetAnimation:
                instance = new ModuleCopyPasteBaseTextureSheetAnimation();
                break;

            case ModuleType.Lights:
                instance = new ModuleCopyPasteBaseLights();
                break;

            case ModuleType.Trails:
                instance = new ModuleCopyPasteBaseTrails();
                break;

            case ModuleType.CustomData:
                instance = new ModuleCopyPasteBaseCustomData();
                break;

            case ModuleType.Renderer:
                instance = new ModuleCopyPasteBaseRenderer();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(moduleType), moduleType, null);
            }

            instance.ModuleType = moduleType;
            return(instance);
        }