Exemplo n.º 1
0
    // ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출(For External class call)*/

    public void DoNotify_OnAwake(MonoBehaviour pObjectOwner)
    {
        _pObjectOwner = pObjectOwner;
        if (p_listExecute == null)
        {
            Debug.LogError(pObjectOwner.name + nameof(DoNotify_OnAwake) + " p_listExecute Is Null", pObjectOwner);
            return;
        }

        for (int i = 0; i < p_listExecute.Count; i++)
        {
            CLASS_EXECUTER pExecute = p_listExecute[i];
            if (pExecute == null)
            {
                Debug.LogError(pObjectOwner.name + " " + nameof(DoNotify_OnAwake) + " ExecuteItem Is Null", pObjectOwner);
                continue;
            }

#if STRIX_LIBRARY
            SCManagerGetComponent.DoUpdateGetComponentAttribute(pObjectOwner, pExecute);
#endif
            pExecute.p_pOwnerList = this;
            pExecute.IExecuter_OnAwake(this, _pObjectOwner);
        }

        OnAwake();
    }
Exemplo n.º 2
0
    // ========================== [ Division ] ========================== //

    virtual protected void OnAwake()
    {
        if (_bIsExcuteAwake == false)
        {
            SCManagerGetComponent.DoUpdateGetComponentAttribute(this);
            _bIsExcuteAwake = true;
        }
    }
 private void InitComponent <ComponentType>(ref ComponentType pComponent, string strComponentName)
     where ComponentType : Component
 {
     pComponent = SCManagerGetComponent.GetComponentInChildren_SameName(this, strComponentName, typeof(ComponentType), true) as ComponentType;
     if (pComponent == null)
     {
         GameObject pObject = new GameObject(strComponentName);
         pComponent = pObject.AddComponent <ComponentType>();
         pObject.transform.SetParent(transform);
         pObject.transform.DoResetTransform();
     }
 }
Exemplo n.º 4
0
    // ========================== [ Division ] ========================== //

    virtual protected void OnAwake()
    {
        if (_bIsExcuteAwake == false)
        {
            _bIsExcuteAwake = true;
            SCManagerGetComponent.DoUpdateGetComponentAttribute(this);

            if (gameObject.activeSelf && Application.isPlaying)
            {
                StopCoroutine("OnAwakeCoroutine");
                StartCoroutine("OnAwakeCoroutine");
            }
        }
    }
Exemplo n.º 5
0
 public void Awake()
 {
     SCManagerGetComponent.DoUpdateGetComponentAttribute(this);
 }
        private void OnEnable()
        {
            MemberInfo pMemberInfo = null;

            #region Initialize
            MemberInfo[] arrMembers = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            for (int i = 0; i < arrMembers.Length; i++)
            {
                if (arrMembers[i].Name.Equals(nameof(GetComponent_Attribute)))
                {
                    pMemberInfo = arrMembers[i];
                    break;
                }
            }

            GameObject pObjectChild = new GameObject("Child");
            pObjectChild.transform.parent = transform;
            #endregion Initialize


            string strTestCase = ETestCase.GetComponent_DefulatProperty.ToString();
            for (int i = 0; i < iTestCase; i++)
            {
                SCManagerProfiler.DoStartTestCase(strTestCase);
                GetComponent_Property = null;
                GetComponent_Property = transform;
                GetComponent_Property.GetType();
                SCManagerProfiler.DoFinishTestCase(strTestCase);
            }

            strTestCase = ETestCase.GetComponet_Function.ToString();
            for (int i = 0; i < iTestCase; i++)
            {
                SCManagerProfiler.DoStartTestCase(strTestCase);
                GetComponent_Function = null;
                GetComponent_Function = GetComponent <Transform>();
                GetComponent_Function.GetType();
                SCManagerProfiler.DoFinishTestCase(strTestCase);
            }

            strTestCase = ETestCase.GetComponetsInChildren_Function.ToString();
            for (int i = 0; i < iTestCase; i++)
            {
                SCManagerProfiler.DoStartTestCase(strTestCase);
                GetComponentsChildren_Children_Function = null;
                GetComponentsChildren_Children_Function = GetComponentsInChildren <Transform>();
                GetComponentsChildren_Children_Function[0].GetType();
                SCManagerProfiler.DoFinishTestCase(strTestCase);
            }

            strTestCase = ETestCase.GetComponet_Attribute_Individual.ToString();
            for (int i = 0; i < iTestCase; i++)
            {
                SCManagerProfiler.DoStartTestCase(strTestCase);
                GetComponent_Attribute = null;
                SCManagerGetComponent.DoUpdateGetComponentAttribute(this, this, pMemberInfo);
                GetComponent_Attribute.GetType();
                SCManagerProfiler.DoFinishTestCase(strTestCase);
            }

            strTestCase = ETestCase.GetComponet_Attribute_All.ToString();
            for (int i = 0; i < iTestCase; i++)
            {
                SCManagerProfiler.DoStartTestCase(strTestCase);
                GetComponentsChildren_Children_Attribute = null;
                SCManagerGetComponent.DoUpdateGetComponentAttribute(this);
                GetComponentsChildren_Children_Attribute[0].GetType();
                SCManagerProfiler.DoFinishTestCase(strTestCase);
            }

            SCManagerProfiler.DoPrintResult_PrintLog_IsError(true);
        }
    public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
    {
        Color pColorOrigin = GUI.color;

        GUI.enabled = false;

        object pObjectFieldOwner = prop.serializedObject.targetObject;

        System.Type pTypeCurrentPropertyOwner = fieldInfo.ReflectedType;
        bool        bTargetIsMono             = pTypeCurrentPropertyOwner.IsSubclassOf(typeof(MonoBehaviour));

        if (bTargetIsMono)
        {
            SCManagerGetComponent.DoUpdateGetComponentAttribute(prop.serializedObject.targetObject as MonoBehaviour);
        }
        else
        {
            // Unity Editor의 PropertyDrawer에선 현재 그리고 있는 프로퍼티의 오너 인스턴스가 무조건 Monobehaviour를 통해 얻어오는데,
            // PropertyDrawer의 현재 그리고 있는 프로퍼티 오너가 Mono가 아닐 경우, Mono에서부터 현재 그리고 있는 프로퍼티 오너의 인스턴스를 찾아야 한다..

            // 프로퍼티의 경우 Play Mode가 Edit일 때 찾지 못하는 에러가 있음 ( Play 중일땐 정상 )
            int iIndex = prop.propertyPath.IndexOf('.');
            if (iIndex != -1)
            {
                string      strFieldOwnerName  = prop.propertyPath.Substring(0, iIndex);
                System.Type pMonobehaviourType = prop.serializedObject.targetObject.GetType();

                MemberInfo pMemberInfo_Owner = null;
                pMemberInfo_Owner = FindMember(strFieldOwnerName, pMemberInfo_Owner, pMonobehaviourType.GetFields(BindingFlags.Public | BindingFlags.Instance));
                if (pMemberInfo_Owner == null)
                {
                    pMemberInfo_Owner = FindMember(strFieldOwnerName, pMemberInfo_Owner, pMonobehaviourType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance));
                }
                if (pMemberInfo_Owner == null)
                {
                    pMemberInfo_Owner = FindMember(strFieldOwnerName, pMemberInfo_Owner, pMonobehaviourType.GetProperties(BindingFlags.Public | BindingFlags.Instance));
                }
                if (pMemberInfo_Owner == null)
                {
                    pMemberInfo_Owner = FindMember(strFieldOwnerName, pMemberInfo_Owner, pMonobehaviourType.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance));
                }

                if (pMemberInfo_Owner != null)
                {
                    pObjectFieldOwner = pMemberInfo_Owner.GetValue_Extension(prop.serializedObject.targetObject);
                    SCManagerGetComponent.DoUpdateGetComponentAttribute(prop.serializedObject.targetObject as MonoBehaviour, pObjectFieldOwner);
                }
            }
        }

        label.text = "'" + _pAttribute.strComponentName + "'";
        switch (CalculateCheckState(prop, pObjectFieldOwner))
        {
        case ECheckState.NotYet:
            GUI.color  = Color.yellow;
            label.text = "Wait-" + label.text;
            break;

        case ECheckState.Checked:
            GUI.color  = Color.green;
            label.text = "Check-" + label.text;
            break;

        case ECheckState.Fail:
            GUI.color  = Color.red;
            label.text = "Fail-" + label.text;
            break;
        }

        EditorGUI.BeginProperty(position, label, prop);
        EditorGUI.PropertyField(position, prop, label);
        EditorGUI.EndProperty();

        GUI.enabled = true;
        GUI.color   = pColorOrigin;
    }
    protected override void DrawPropertyLayout(GUIContent label)
    {
        var property  = this.Property;
        var attribute = this.Attribute;

        object pObjectFieldOwner = property.ParentValues[0];
        bool   bTargetIsMono     = property.ParentValues[0] is MonoBehaviour;

        if (bTargetIsMono)
        {
            SCManagerGetComponent.DoUpdateGetComponentAttribute(property.ParentValues[0] as MonoBehaviour);
        }
        else
        {
            pObjectFieldOwner = property.ParentValues[0];
            SCManagerGetComponent.DoUpdateGetComponentAttribute(property.Parent.ParentValues[0] as MonoBehaviour, property.ParentValues[0]);
        }


        PropertyContext <TitleContext> context;

        if (property.Context.Get(this, "Title", out context))
        {
            context.Value = new TitleContext()
            {
                TitleHelper    = new StringMemberHelper(property, const_strTitle),
                SubtitleHelper = new StringMemberHelper(property, const_strSubTitle),
            };
        }

        if (property != property.Tree.GetRootProperty(0))
        {
            EditorGUILayout.Space();
        }

        SirenixEditorGUI.Title(const_strTitle, const_strSubTitle, TextAlignment.Left, true, true);

        GUI.enabled = false;
        GUIHelper.PushIndentLevel(EditorGUI.indentLevel + 1);
        foreach (var pPropertyChild in property.Children)
        {
            ChildRequireComponentAttribute pAttribute = pPropertyChild.Info.GetAttribute <ChildRequireComponentAttribute>();
            if (pAttribute != null)
            {
                pPropertyChild.Label.text = "`" + pAttribute.strComponentName + "`";

                ECheckState eCheckState = ECheckState.NotYet;
                eCheckState = CalculateCheckState(property, pPropertyChild);

                switch (eCheckState)
                {
                case ECheckState.NotYet:
                    GUI.contentColor           = Color.yellow;
                    pPropertyChild.Label.image = EditorIcons.UnityWarningIcon;
                    break;

                case ECheckState.Checked:
                    GUI.contentColor           = Color.green;
                    pPropertyChild.Label.image = EditorIcons.Checkmark.Raw;
                    break;

                case ECheckState.Fail:
                    GUI.contentColor           = Color.red;
                    pPropertyChild.Label.image = EditorIcons.X.Raw;
                    break;
                }
            }

            pPropertyChild.Draw(pPropertyChild.Label);
        }

        GUI.contentColor = Color.white;
        GUIHelper.PopIndentLevel();
        GUI.enabled = true;
    }
 public override object GetComponent(MonoBehaviour pTargetMono, Type pElementType)
 {
     return(SCManagerGetComponent.Event_GetComponentInParents(pTargetMono, pElementType));
 }
 public override object GetComponent(MonoBehaviour pTargetMono, Type pElementType)
 {
     return(SCManagerGetComponent.Event_GetComponentInChildren(pTargetMono, pElementType, bInclude_DeActive, bSearch_By_ComponentName, strComponentName));
 }