Example #1
0
        public override void OnInspectorGUI()
        {
            if (m_boxStyle == null)
            {
                InitStyles();
            }

            serializedObject.Update();

            DrawPropertiesExcluding(serializedObject, m_excludedProps);

            if (m_depth == 0 && target is ParallelAnimationAsset)
            {
                EditorGUILayout.HelpBox("Root is Parallel", MessageType.Info);
            }

            if (m_depth == 0 && m_copyBuffer != null)
            {
                GUILayout.BeginHorizontal(EditorStyles.helpBox);
                EditorGUILayout.ObjectField("CopyBuffer", m_copyBuffer, typeof(TweenAsset), false);
                if (GUILayout.Button("Clear", EditorStyles.miniButton, GUILayout.Width(40)))
                {
                    m_copyBuffer = null;
                }
                GUILayout.EndHorizontal();
            }

            var oldColor = GUI.backgroundColor;

            GUI.backgroundColor = m_colors[m_depth % m_colors.Length];
            ++m_depth;

            for (int i = 0; i < Sequence.arraySize; i++)
            {
                var prop = Sequence.GetArrayElementAtIndex(i);
                if (prop.objectReferenceValue == null)
                {
                    Sequence.DeleteArrayElementAtIndex(i);
                    continue;
                }

                Assert.IsNotNull(prop.objectReferenceValue);
                var asset = (TweenAsset)prop.objectReferenceValue;

                bool enabled = (asset.hideFlags & HideFlags.NotEditable) == 0;

                using (new GUILayout.VerticalScope(m_boxStyle))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        var prefix     = enabled ? "▼ " : "► ";
                        var newEnabled = GUILayout.Toggle(enabled, prefix + asset.Title, EditorStyles.miniLabel, GUILayout.ExpandWidth(true));
                        if (newEnabled != enabled)
                        {
                            if (newEnabled)
                            {
                                asset.hideFlags &= ~HideFlags.NotEditable;
                            }
                            else
                            {
                                asset.hideFlags |= HideFlags.NotEditable;
                            }
                            GUI.FocusControl(null);
                            EditorUtility.SetDirty(asset);
                        }

                        var newName = EditorGUILayout.DelayedTextField(GUIContent.none, asset.name, m_nameStyle, GUILayout.MinWidth(10), GUILayout.ExpandWidth(true));
                        if (newName != asset.name)
                        {
                            Rename(asset, newName);
                            GUI.FocusControl(null);
                        }

                        var oldEnabled = GUI.enabled;
                        GUI.enabled = oldEnabled && i > 0;
                        if (GUILayout.Button(m_moveUpContent, EditorStyles.miniButtonLeft, GUILayout.Width(20)))
                        {
                            Sequence.MoveArrayElement(i, i - 1);
                        }

                        GUI.enabled = oldEnabled && i < Sequence.arraySize - 1;
                        if (GUILayout.Button(m_moveDownContent, EditorStyles.miniButtonMid, GUILayout.Width(20)))
                        {
                            Sequence.MoveArrayElement(i, i + 1);
                        }

                        var sequence     = asset as SequenceAnimationAsset;
                        var parallel     = asset as ParallelAnimationAsset;
                        var hasSubAssets = (sequence != null && sequence.sequence.Any()) || (parallel != null && parallel.parallel.Any());

                        GUI.enabled = oldEnabled && !hasSubAssets;
                        if (GUILayout.Button(m_copyContent, EditorStyles.miniButtonMid, GUILayout.Width(20)))
                        {
                            m_copyBuffer = (TweenAsset)asset;
                        }

                        GUI.enabled = oldEnabled && !hasSubAssets;
                        if (GUILayout.Button(m_removeContent, EditorStyles.miniButtonRight, GUILayout.Width(20)))
                        {
                            RemoveItem(new RemoveItemRequest {
                                index = i
                            });
                            continue;
                        }
                        GUI.enabled = oldEnabled;
                    }

                    if (enabled)
                    {
                        Editor editor;
                        if (!m_editors.TryGetValue(asset, out editor))
                        {
                            m_editors.Add(asset, editor = Editor.CreateEditor(asset));
                        }

                        editor.OnInspectorGUI();
                    }
                }
            }

            bool canPaste = m_copyBuffer != null;

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(m_addContent, canPaste ? EditorStyles.miniButtonLeft : EditorStyles.miniButton))
            {
                var types = System.AppDomain.CurrentDomain
                            .GetAssemblies()
                            .SelectMany(asm => asm.GetTypes())
                            .Where(type => type.GetCustomAttributes(typeof(TweenMenuItemAttribute), false).Length > 0);

                var menu = new GenericMenu();
                foreach (var type in types)
                {
                    var items = type.GetCustomAttributes(typeof(TweenMenuItemAttribute), false);
                    foreach (var itemObj in items)
                    {
                        var item = (TweenMenuItemAttribute)itemObj;
                        menu.AddItem(new GUIContent(item.Name), false, AddItemByRequest, new AddItemRequest
                        {
                            type = type,
                            attr = item,
                        });
                    }
                }
                menu.ShowAsContext();
            }

            if (canPaste && GUILayout.Button(m_pasteContent, EditorStyles.miniButtonRight, GUILayout.Width(20)))
            {
                AddItemByPrototype(m_copyBuffer);
                m_copyBuffer = null;
            }

            GUILayout.EndHorizontal();

            GUI.backgroundColor = oldColor;
            --m_depth;

            serializedObject.ApplyModifiedProperties();
        }
Example #2
0
    static IEnumerator SpawnPrefab(string prefabName, Transform _from, Transform _target, float delay, DropType dtype, float gold, bool boss = false)
    {
        yield return(new WaitForSeconds(delay));

        Debug.Log(prefabName + "  " + _from.name);
        GameObject coinTrans = G_GameInfo.SpawnInGameObj(prefabName, _from.transform.position, _from.transform.localRotation);

        if (coinTrans == null)
        {
            yield break;
        }

        Debug.Log(prefabName + "  " + _from.name);

        Transform trGbox = coinTrans.transform.FindChild("GoldBox_001");
        Transform trWbox = coinTrans.transform.FindChild("woodbox_001");
        Transform trCoin = coinTrans.transform.FindChild("coin");

        switch (dtype)
        {
        case DropType.treasureChest:
            if (trGbox != null)
            {
                trGbox.gameObject.SetActive(true);
            }
            if (trWbox != null)
            {
                trWbox.gameObject.SetActive(false);
            }
            if (trCoin != null)
            {
                trCoin.gameObject.SetActive(false);
            }
            break;

        case DropType.WoodBox:
            if (trGbox != null)
            {
                trGbox.gameObject.SetActive(false);
            }
            if (trWbox != null)
            {
                trWbox.gameObject.SetActive(true);
            }
            if (trCoin != null)
            {
                trCoin.gameObject.SetActive(false);
            }
            break;

        case DropType.Exp:

            break;

        case DropType.Gold:
        default:
            if (trGbox != null)
            {
                trGbox.gameObject.SetActive(false);
            }
            if (trWbox != null)
            {
                trWbox.gameObject.SetActive(false);
            }
            if (trCoin != null)
            {
                trCoin.gameObject.SetActive(true);
            }
            //SoundManager.instance.PlaySfxSound(eUISfx.DropGold, false);
            break;
        }

        float   itemAdd    = dtype != DropType.Gold ? 3 : 0;
        Vector3 spawnedPos = coinTrans.transform.position;
        Vector3 addPos     = Random.insideUnitSphere * (float)Random.Range(0 + itemAdd, 2 + itemAdd);

        addPos.y = 0;
        coinTrans.transform.position = spawnedPos + addPos;

        //< 각도를 랜덤으로 잡아줌
        coinTrans.transform.localRotation = Quaternion.Euler(new Vector3(0, Random.Range(0, 360), 0));

        if (dtype == DropType.Gold)
        {
            //< 사이즈 조금더 보정해줌
            coinTrans.transform.localScale = Vector3.one * 1.2f;
        }
        else
        {
            coinTrans.transform.localScale = Vector3.one * 0.4f;
        }

        TweenAsset asset = coinTrans.GetComponent <TweenAsset>();

        if (asset != null)
        {
            asset.StartTween(_target, boss, gold, dtype);
        }
    }