當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.Component類代碼示例

本文整理匯總了C#中UnityEngine.Component的典型用法代碼示例。如果您正苦於以下問題:C# Component類的具體用法?C# Component怎麽用?C# Component使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Component類屬於UnityEngine命名空間,在下文中一共展示了Component類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExtractRigInfo

 //Should only be created as part of our base framework
 public static AiRig ExtractRigInfo(Component c)
 {
     var rig = c.GetComponent<AiRig>();
     if (rig == null)
         c.GetComponentInParent<AiRig>();
     return rig;
 }
開發者ID:Miista,項目名稱:TerrainGeneration,代碼行數:8,代碼來源:AiRig.cs

示例2: getAttributesFrom

 public override Dictionary<string, object> getAttributesFrom(Component component)
 {
     Dictionary<string, object> scriptAttributes = new Dictionary<string, object>();
     addScriptFieldsToDictionary (scriptAttributes, component);
     addScriptPropertiesToDictionary (scriptAttributes, component);
     return scriptAttributes;
 }
開發者ID:Raysangar,項目名稱:BadPrincess-LevelEditor,代碼行數:7,代碼來源:ScriptAttributesGetter.cs

示例3: CreateChild

 public static Component CreateChild(this Transform parent, Component child)
 {
     Component go = GameObject.Instantiate(child);
     go.transform.SetParent(parent);
     go.transform.Reset();
     return go;
 }
開發者ID:quangthinhnguyen,項目名稱:Unity3d-AMCore,代碼行數:7,代碼來源:TransformExtention.cs

示例4: Process

        public void Process(Component @object)
        {
            var label = (UILabel)@object;
            // 圖片字體! 打包字
            if (label.bitmapFont != null)
            {
                string uiFontPath = KDepBuild_NGUI.BuildUIFont(label.bitmapFont);
                //CResourceDependencies.Create(label, CResourceDependencyType.BITMAP_FONT, uiFontPath);
                KAssetDep.Create<KBitmapFontDep>(label, uiFontPath);

                label.bitmapFont = null;
            }
            else if (label.trueTypeFont != null)
            {
                string fontPath = KDependencyBuild.BuildFont(label.trueTypeFont);

                //CResourceDependencies.Create(label, CResourceDependencyType.FONT, fontPath);
                KAssetDep.Create<KUILabelDep>(label, fontPath);
                label.trueTypeFont = null; // 挖空依賴的數據
            }
            else
            {
                Logger.LogWarning("找不到Label的字體: {0}, 場景: {1}", label.name, EditorApplication.currentScene);
            }
        }
開發者ID:s3chugo,項目名稱:KEngine,代碼行數:25,代碼來源:KDepBuild_NGUI.cs

示例5: ComponentField

        public static Component ComponentField(Rect position, GUIContent label, Component value, System.Type inheritsFromType, bool allowSceneObjects, System.Type targetComponentType)
        {
            if (inheritsFromType == null) inheritsFromType = typeof(Component);
            else if (!typeof(Component).IsAssignableFrom(inheritsFromType) && !typeof(IComponent).IsAssignableFrom(inheritsFromType)) throw new TypeArgumentMismatchException(inheritsFromType, typeof(IComponent), "Type must inherit from IComponent or Component.", "inheritsFromType");
            if (targetComponentType == null) throw new System.ArgumentNullException("targetComponentType");
            if (!typeof(Component).IsAssignableFrom(targetComponentType)) throw new TypeArgumentMismatchException(targetComponentType, typeof(Component), "targetComponentType");
            if (value != null && !targetComponentType.IsAssignableFrom(value.GetType())) throw new TypeArgumentMismatchException(value.GetType(), inheritsFromType, "value must inherit from " + inheritsFromType.Name, "value");

            if (TypeUtil.IsType(inheritsFromType, typeof(Component)))
            {
                return EditorGUI.ObjectField(position, label, value, inheritsFromType, true) as Component;
            }
            else
            {
                value = EditorGUI.ObjectField(position, label, value, typeof(Component), true) as Component;
                var go = GameObjectUtil.GetGameObjectFromSource(value);
                if (go != null)
                {
                    foreach (var c in go.GetComponents(inheritsFromType))
                    {
                        if (TypeUtil.IsType(c.GetType(), targetComponentType))
                        {
                            return c as Component;
                        }
                    }
                }
            }

            return null;
        }
開發者ID:XianWorld,項目名稱:spacepuppy-unity-framework,代碼行數:30,代碼來源:SPEditorGUI.cs

示例6: Start

        new void Start()
        {
            base.Start ();
            if (entity == null) {
                Debug.LogError("Serenity Method Trigger miss a gameObject");
                return;
            }
            if (method == null) {
                MethodInfo mi = entity.GetType().GetMethod(methodName);
                foreach(Component comp in entity.GetComponents<Component>()) {
                    mi = comp.GetType().GetMethod(methodName);
                    if(mi!=null)
                    {
                        component = comp;
                        break;
                    }
                }
                if(mi==null)
                {
                    Debug.LogError ("Serenity Method Trigger miss a boolean-returned method with name "+methodName);
                }
                else {

                    method = mi;
                }
            } else {
                methodName = method.Name;
            }
        }
開發者ID:TsubameDono,項目名稱:Evolution,代碼行數:29,代碼來源:SerenityMethodTrigger.cs

示例7: Init

        public override void Init(Reactor reactor)
        {
            base.Init(reactor);

            ComponentMethod cm = null;
            try {
                cm = reactor.FindMethod(actionMethod);
            } catch (ArgumentNullException e) {
                Debug.LogError("[Action Node] Could not find method :" + actionMethod + "\n" + NodeNamesInStack());
                throw e;
            }
            if(cm == null) {
                Debug.LogError("Could not load action method: " + actionMethod);
            } else {
                if(cm.methodInfo.ReturnType == typeof(IEnumerator<NodeResult>)) {
                    component = cm.component;
                    methodInfo = cm.methodInfo;
                    if( methodParams != null )
                    {
                        methodParams.ConvertParams(methodInfo);
                    }
                } else {
                    Debug.LogError("Action method has invalid signature: " + actionMethod);
                }
            }
        }
開發者ID:s76,項目名稱:testAI,代碼行數:26,代碼來源:Action.cs

示例8: Reset

 public override void Reset()
 {
     GameObject = null;
     Component = null;
     ScreenPosition = null;
     SendEvent = null;
 }
開發者ID:Jashengmato,項目名稱:TouchScript,代碼行數:7,代碼來源:LongPressed.cs

示例9: FromComponent

        public static KISItemModuleWrapper FromComponent(Component component)
        {
            if (component != null)
                return new KISItemModuleWrapper(component);

            return null;
        }
開發者ID:zerosofadown,項目名稱:Agile.Ksp,代碼行數:7,代碼來源:KISItemModuleWrapper.cs

示例10: WriteToJson

        public void WriteToJson(IResMgr resmgr, GameObject node, Component component, MyJson.JsonNode_Object json)
        {
            SkinnedMeshRenderer ic = component as SkinnedMeshRenderer;
            //json["type"] = new MyJson.JsonNode_ValueString(this.comptype.Name.ToLower());//必須的一行
            //放到外麵去了

            //材質
            MyJson.JsonNode_Array mats = new MyJson.JsonNode_Array();

            json["mats"] = mats;

            foreach (var m in ic.sharedMaterials)
            {
                string hash = resmgr.SaveMat(m);
                mats.Add(new MyJson.JsonNode_ValueString(hash));
            }

            //bounds
            json["center"] = new MyJson.JsonNode_ValueString(StringHelper.ToString(ic.localBounds.center));
            json["size"] = new MyJson.JsonNode_ValueString(StringHelper.ToString(ic.localBounds.size));

            //mesh
            json["mesh"] = new MyJson.JsonNode_ValueString(resmgr.SaveMesh(ic.sharedMesh));

            json["rootboneobj"] = new MyJson.JsonNode_ValueNumber(ic.rootBone.gameObject.GetInstanceID());
            MyJson.JsonNode_Array bones = new MyJson.JsonNode_Array();
            foreach (var b in ic.bones)
            {
                bones.Add(new MyJson.JsonNode_ValueNumber(b.gameObject.GetInstanceID()));
            }
            json["boneobjs"] = bones;
            ic.rootBone.GetInstanceID();
        }
開發者ID:lightszero,項目名稱:EgretUnity,代碼行數:33,代碼來源:ComponetParser_SkinnedMeshRenderer.cs

示例11: Reset

 public override void Reset()
 {
     GameObject = null;
     Component = null;
     ScreenFlickVector = null;
     SendEvent = null;
 }
開發者ID:Jashengmato,項目名稱:TouchScript,代碼行數:7,代碼來源:Flicked.cs

示例12: Apply

        public object Apply(Type targetType, Injector activeInjector, Dictionary<string, object> injectParameters)
        {
            if (parentObject == null)
            {
                object contextViewObj = (IContextView) activeInjector.GetInstance(typeof(IContextView));
                if(contextViewObj != null)
                {
                    object contextView = ((IContextView) contextViewObj).view;
                    if(contextView != null)
                    {
                        if (contextView is Transform) parentObject = (Transform) contextView;
                        else if (contextView is GameObject) parentObject = ((GameObject) contextView).transform;
                    }
                }
            }
            if (parentObject == null)
            {
                destroyGameObjectWhenComplete = true;
                parentObject = new GameObject("Unity Component Provider").transform;
            }
            component = parentObject.gameObject.AddComponent(componentType);

            //TODO: Make auto InjectInto configurable
            activeInjector.InjectInto(component);

            if (_postApply != null)
            {
                _postApply(this, component);
            }
            return component;
        }
開發者ID:mikecann,項目名稱:robotlegs-sharp-framework,代碼行數:31,代碼來源:UnityComponentProvider.cs

示例13: OnExecute

        /////////
        protected override Status OnExecute(Component agent, IBlackboard blackboard)
        {
            if (nestedFSM == null || nestedFSM.primeNode == null){
                return Status.Failure;
            }

            if (status == Status.Resting){
                CheckInstance();
            }

            if (status == Status.Resting || nestedFSM.isPaused){
                status = Status.Running;
                nestedFSM.StartGraph(agent, blackboard, OnFSMFinish);
            }

            if (!string.IsNullOrEmpty(successState) && nestedFSM.currentStateName == successState){
                nestedFSM.Stop();
                return Status.Success;
            }

            if (!string.IsNullOrEmpty(failureState) && nestedFSM.currentStateName == failureState){
                nestedFSM.Stop();
                return Status.Failure;
            }

            return status;
        }
開發者ID:nemish,項目名稱:cubematters,代碼行數:28,代碼來源:NestedFSM.cs

示例14: OnExecute

        protected override Status OnExecute(Component agent, IBlackboard blackboard)
        {
            currentProbability = probability;
            for (var i = 0; i < outConnections.Count; i++){

                if (failedIndeces.Contains(i))
                    continue;

                if (currentProbability > childWeights[i].value){
                    currentProbability -= childWeights[i].value;
                    continue;
                }

                status = outConnections[i].Execute(agent, blackboard);
                if (status == Status.Success || status == Status.Running)
                    return status;

                if (status == Status.Failure){
                    failedIndeces.Add(i);
                    var newTotal = GetTotal();
                    for (var j = 0; j < failedIndeces.Count; j++){
                        newTotal -= childWeights[j].value;
                    }
                    probability = Random.Range(0, newTotal);
                    return Status.Running;
                }
            }

            return Status.Failure;
        }
開發者ID:nemish,項目名稱:cubematters,代碼行數:30,代碼來源:ProbabilitySelector.cs

示例15: Serialize

 public ComponentData Serialize(Component component) {
     var placedItem = (PlacedItem) component;
     return new PlacedItemData {
         Id = placedItem.CatalogEntry.Id,
         Unique = placedItem.UniqueInSlot
     };
 }
開發者ID:Exosphir,項目名稱:exosphir,代碼行數:7,代碼來源:PlacedItemConverter.cs


注:本文中的UnityEngine.Component類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。